# MongoDB Receiver

<!-- llms-txt-link: /llms.txt -->

> OpenTelemetry Collector receiver · contrib distribution

This receiver fetches stats from a MongoDB instance using the [golang mongo driver](https://github.com/mongodb/mongo-go-driver). Stats are collected via MongoDB's `dbStats` and `serverStatus` commands.

- **Component ID**: `contrib-mongodbreceiver`
- **Name**: `mongodbreceiver`
- **Type**: receiver
- **Distribution**: contrib
- **Repository**: `opentelemetry-collector-contrib`

## Stability

| Level | Signals |
| --- | --- |
| beta | metrics |
| development | logs |

## Attributes

| Attribute | Type | Description |
| --- | --- | --- |
| `client.address` | string | Hostname or address of the client. |
| `client.port` | int | TCP port used by the client. |
| `collection` | string | The name of a collection. |
| `connection_type` | string | The status of the connection. |
| `db.collection.name` | string | The MongoDB collection being accessed within the database stated in db.namespace. |
| `db.namespace` | string | The name of a database. |
| `db.operation.name` | string | The name of the MongoDB command being executed (e.g. find, aggregate, insert). |
| `db.query.text` | string | The obfuscated MongoDB command statement. |
| `db.system.name` | string | The database management system (DBMS) product as identified by the client instrumentation. |
| `lock_mode` | string | The mode of Lock which denotes the degree of access |
| `lock_type` | string | The Resource over which the Lock controls access |
| `memory_type` | string | The type of memory used. |
| `mongodb.client.app.name` | string | The identifier of the client application which ran the operation, as set by the driver's `appName` connection option. |
| `mongodb.cursor.await_data` | bool | Whether the tailable cursor waits for new data instead of returning immediately. |
| `mongodb.cursor.id` | string | The identifier of the cursor. |
| `mongodb.cursor.no_timeout` | bool | Whether the cursor is configured not to time out when idle. |
| `mongodb.cursor.originating_command` | string | The obfuscated command that originally created the cursor. |
| `mongodb.cursor.returned_batches` | int | The cumulative number of batches returned by the cursor. |
| `mongodb.cursor.returned_documents` | int | The cumulative number of documents returned by the cursor. |
| `mongodb.cursor.tailable` | bool | Whether the cursor is a tailable cursor. |
| `mongodb.lsid.id` | string | The UUID portion of the logical session identifier associated with the MongoDB operation. |
| `mongodb.operation.comment` | slice | The comments attached to the MongoDB command. String comments are reported as-is; array comments are expanded into multiple entries; non-string values are reported as MongoDB Extended JSON. |
| `mongodb.operation.duration` | double | The duration of the MongoDB operation in seconds. |
| `mongodb.operation.id` | string | Identifier of the MongoDB operation. |
| `mongodb.operation.plan.summary` | string | Summary of the execution plan for the MongoDB operation. |
| `mongodb.operation.prepared_read_conflict.count` | int | The number of times the MongoDB operation had to wait for a prepared transaction with a write to commit or abort. |
| `mongodb.operation.state` | string | Simplified state of the MongoDB operation. |
| `mongodb.operation.type` | string | The raw MongoDB operation type from `$currentOp.op` (e.g. query, insert, update, remove, getmore, command). |
| `mongodb.operation.wait.details` | string | Details about what the MongoDB operation is waiting on. |
| `mongodb.operation.wait.type` | slice | The set of wait conditions the MongoDB operation is currently blocked on. Possible values: `lock` (from `waitingForLock`), `flow_control` (from `waitingForFlowControl`), and `latch` (when `waitingForLatch` is a non-empty document). An empty slice indicates the operation is not waiting on any of these conditions. |
| `mongodb.operation.write_conflict.count` | int | The number of times the MongoDB operation conflicted with another write operation on the same document. |
| `mongodb.operation.yield.count` | int | The number of times the MongoDB operation yielded to allow other operations to complete. |
| `mongodb.query.framework` | string | The MongoDB query execution engine that processed this operation. Only present for operations that flow through the query subsystem (reads, read-modify-writes, and getMore continuations); absent for pure inserts, index management, and administrative commands. Known values include `classic` and `sbe`. |
| `mongodb.query.truncated` | bool | Whether the value carried by db.query.text is a truncated rendering of the MongoDB command, as indicated by `$truncated` in the currentOp output. |
| `operation` | string | The MongoDB operation being counted. |
| `operation_latency` | string | The MongoDB operation with regards to latency |
| `type` | string | The result of a cache request. |
| `user.name` | string | Name of the user associated with the operation. |

## Data

- **JSON**: [/data/collector/components/contrib-mongodbreceiver/contrib-mongodbreceiver-4bb3c2ac30d6.json](/data/collector/components/contrib-mongodbreceiver/contrib-mongodbreceiver-4bb3c2ac30d6.json)
- **Explore**: [/collector/components/contrib/mongodbreceiver](/collector/components/contrib/mongodbreceiver)
