MongoDB receiver
The MongoDB receiver fetches stats from a MongoDB instance using the golang mongo driver.
The MongoDB receiver fetches metrics from standalone MongoDB clusters, including non-Atlas managed MongoDB servers. The supported pipeline type is metrics
. See Process your data with pipelines for more information.
The receiver collects stats with MongoDB’s dbStats
and serverStatus
commands, and uses the golang mongo driver. See more at Mongo Go driver documentation .
mongodb
monitor type.Prerequisites
The MongoDB receiver supports MongoDB versions 4.0+, 5.0, 6.0, and 7.0.
MongoDB recommends to set up a least privilege user (LPU) with a clusterMonitor
role in order to collect metrics.
For information on MongoDB’s roles, see MongoDB built-in roles .
For an example of how to configure these permissions, see lpu.sh .
Get started
Follow these steps to configure and activate the component:
Deploy the Splunk Distribution of the OpenTelemetry Collector to your host or container platform:
Configure the receiver as described in the next section.
Restart the Collector.
Sample configurations
To activate the MongoDB receiver, add mongodb
to the receivers
section of your configuration file, as shown in the following example:
receivers:
mongodb:
hosts:
- endpoint: localhost:27017
username: otel
password: ${env:MONGODB_PASSWORD}
collection_interval: 60s
initial_delay: 1s
tls:
insecure: true
insecure_skip_verify: true
To complete the configuration, include the receiver in the metrics
pipeline of the service
section of your configuration file. For example:
service:
pipelines:
metrics:
receivers: [mongodb]
Configuration options
The following settings are optional:
hosts
.[localhost:27017]
by default. List ofhost:port
or Unix domain socket endpoints. Thetransport
option is no longer available.For standalone MongoDB deployments this is the hostname and port of the mongod instance.
For replica sets specify the hostnames and ports of the mongod instances that are in the replica set configuration. If the
replica_set
field is specified, nodes are set to be autodiscovered.For a sharded MongoDB deployment, specify a list of the
mongos
hosts.
username
: If authentication is required, provide theclusterMonitor
permissions here.password
: If authentication is required, provide the password here.collection_interval
.1m
by default. This receiver collects metrics on an interval. Valid time units arens
,us
(orµs
),ms
,s
,m
,h
. This value must be a string readable by Golang’s time parseDuration. Learn more at ParseDuration.initial_delay
.1s
by default. Defines how long this receiver waits before starting.replica_set
: If the deployment of MongoDB is a replica set, use this to specify the replica set name which allows for autodiscovery of other nodes in the replica set.timeout
.1m
by default. The timeout of running commands against mongo.tls
: TLS control. By default insecure settings are rejected and certificate verification is on. See more at TLS Configuration Settings.direct_connection
. If true, the driver doesn't try to autodiscover other nodes, and performs instead a direct connection o the host.
Settings
The following table shows the configuration options for the MongoDB receiver:
included
https://raw.githubusercontent.com/splunk/collector-config-tools/main/cfg-metadata/receiver/mongodb.yaml
Metrics
The following metrics, resource attributes, and attributes are available.
included
https://raw.githubusercontent.com/splunk/collector-config-tools/main/metric-metadata/mongodbreceiver.yaml
mongodb.extent.count
is available for versions under 4.4 with mmapv1 storage engine.
Activate or deactivate specific metrics
You can activate or deactivate specific metrics by setting the enabled
field in the metrics
section for each metric. For example:
receivers:
samplereceiver:
metrics:
metric-one:
enabled: true
metric-two:
enabled: false
The following is an example of host metrics receiver configuration with activated metrics:
receivers:
hostmetrics:
scrapers:
process:
metrics:
process.cpu.utilization:
enabled: true
-
If you’re in a MTS-based subscription, all metrics count towards metrics usage.
-
If you’re in a host-based plan, metrics listed as active (Active: Yes) on this document are considered default and are included free of charge.
Learn more at Infrastructure Monitoring subscription usage (Host and metric plans).
Troubleshooting
If you are a Splunk Observability Cloud customer and are not able to see your data in Splunk Observability Cloud, you can get help in the following ways.
Available to Splunk Observability Cloud customers
-
Submit a case in the Splunk Support Portal.
-
Contact Splunk Support.
Available to prospective customers and free trial users
-
Ask a question and get answers through community support at Splunk Answers.
-
Join the Splunk #observability user group Slack channel to communicate with customers, partners, and Splunk employees worldwide. To join, see Chat groups.