MongoDB

Metrics, Dashboards, Alerts and more for MongoDB Integration in Sysdig Monitor.
MongoDB

This integration is enabled by default.

Versions supported: > v4.2

This integration uses a standalone exporter that is available in UBI or scratch base image.

This integration has 28 metrics.

Timeseries generated: 500 series per instance

List of Alerts

AlertDescriptionFormat
[MongoDB] Instance DownMongo server detected down by instancePrometheus
[MongoDB] Uptime less than one hourMongo server detected down by instancePrometheus
[MongoDB] Asserts detectedMongo server detected down by instancePrometheus
[MongoDB] High LatencyHigh latency in instancePrometheus
[MongoDB] High Ticket UtilizationTicket usage over 75% in instancePrometheus
[MongoDB] Recurrent Cursor TimeoutRecurrent cursors timeout in instancePrometheus
[MongoDB] Recurrent Memory Page FaultsRecurrent cursors timeout in instancePrometheus

List of Dashboards

MongoDB Instance Health

The dashboard provides information on the connections, cache hit rate, error rate, latency and traffic of one of the databases of the MongoDB instance. MongoDB Instance Health

MongoDB Database Details

The dashboard provides information on the status, error rate and resource usage of a MongoDB instance. MongoDB Database Details

List of Metrics

Metric name
mongodb_asserts_total
mongodb_connections
mongodb_extra_info_page_faults_total
mongodb_instance_uptime_seconds
mongodb_memory
mongodb_mongod_db_collections_total
mongodb_mongod_db_data_size_bytes
mongodb_mongod_db_index_size_bytes
mongodb_mongod_db_indexes_total
mongodb_mongod_db_objects_total
mongodb_mongod_global_lock_client
mongodb_mongod_global_lock_current_queue
mongodb_mongod_global_lock_ratio
mongodb_mongod_metrics_cursor_open
mongodb_mongod_metrics_cursor_timed_out_total
mongodb_mongod_op_latencies_latency_total
mongodb_mongod_op_latencies_ops_total
mongodb_mongod_wiredtiger_cache_bytes
mongodb_mongod_wiredtiger_cache_bytes_total
mongodb_mongod_wiredtiger_cache_evicted_total
mongodb_mongod_wiredtiger_cache_pages
mongodb_mongod_wiredtiger_concurrent_transactions_out_tickets
mongodb_mongod_wiredtiger_concurrent_transactions_total_tickets
mongodb_network_bytes_total
mongodb_network_metrics_num_requests_total
mongodb_op_counters_total
mongodb_up
net.error.count

Prerequisites

Create Credentials for MongoDB Exporter

If you want to use a non-admin user for the exporter, you will have to create a user and grant the roles to be able to scrape statistics.

In the mongo shell:

use admin
db.auth("<YOUR-ADMIN-USER>", "<YOUR-ADMIN-PASSWORD>")
db.createUser(
   {
      user: "<YOUR-EXPORTER-USER>",
      pwd: "<YOUR-EXPORTER-PASSWORD>",
      roles: [
        { role: "clusterMonitor", db: "admin" },
        { role: "read", db: "admin" },
        { role: "read", db: "local" }
      ]
   }
)

Create Kubernetes Secret for Connection and Authentication

To configure authentication, do the following:

  1. Create a text file with the connection string (mongodb-uri) for your MongoDB by using these examples:
# Basic authentication
mongodb://<YOUR-EXPORTER-USER>:<YOUR-EXPORTER-PASSWORD>@<YOUR-MONGODB-HOST>:<PORT>

# TLS
mongodb://<YOUR-EXPORTER-USER>:<YOUR-EXPORTER-PASSWORD>@<YOUR-MONGODB-HOST>:<PORT>/admin?tls=true&tlsCertificateKeyFile=/etc/mongodb/mongodb-exporter-key.pem&tlsAllowInvalidCertificates=true&tlsCAFile=/etc/mongodb/mongodb-exporter-ca.pem

# SSL
mongodb://<YOUR-EXPORTER-USER>:<YOUR-EXPORTER-PASSWORD>@<YOUR-MONGODB-HOST>:<PORT>/admin?ssl=true&sslclientcertificatekeyfile=/etc/mongodb/mongodb-exporter-key.pem&sslinsecure=true&sslcertificateauthorityfile=/etc/mongodb/mongodb-exporter-ca.pem
  1. Create the secret for the connection string:
kubectl create secret -n Your-Exporter-Namespace generic Your-Mongodb-Uri-Secret-Name \
  --from-file=mongodb-uri=<route-to-file-with-mongodb-uri.txt>
  1. In case of TLS or SSL authentication, create the secret with the private key and the certificate authority (CA). If you do not have a CA file, you can use an empty file instead:
kubectl create secret -n Your-Exporter-Namespace generic mongodb-exporter-auth \
  --from-file=mongodb-key=<route-to-your-private-key.pem> \
  --from-file=mongodb-ca=<route-to-your-ca.pem>

Installation

An automated wizard is present in the Monitoring Integrations in Sysdig Monitor. Expert users can also use the Helm chart for installation: https://github.com/sysdiglabs/integrations-charts/tree/main/charts/mongodb-exporter

Agent Configuration

The default agent job for this integration is as follows:

- job_name: mongodb-default
  tls_config:
    insecure_skip_verify: true
  kubernetes_sd_configs:
  - role: pod
  relabel_configs:
  - action: keep
    source_labels: [__meta_kubernetes_pod_host_ip]
    regex: __HOSTIPS__
  - action: keep
    source_labels:
    - __meta_kubernetes_pod_annotation_promcat_sysdig_com_integration_type
    regex: "mongodb"
  - source_labels: [__meta_kubernetes_pod_phase]
    action: keep
    regex: Running
  - action: replace
    source_labels: [__meta_kubernetes_pod_annotation_promcat_sysdig_com_target_ns]
    target_label: kube_namespace_name
  - action: replace
    source_labels: [__meta_kubernetes_pod_annotation_promcat_sysdig_com_target_workload_type]
    target_label: kube_workload_type
  - action: replace
    source_labels: [__meta_kubernetes_pod_annotation_promcat_sysdig_com_target_workload_name]
    target_label: kube_workload_name
  - action: replace
    replacement: true
    target_label: sysdig_omit_source
  - action: replace
    source_labels: [__address__, __meta_kubernetes_pod_annotation_promcat_sysdig_com_port]
    regex: ([^:]+)(?::\d+)?;(\d+)
    replacement: $1:$2
    target_label: __address__
  - action: replace
    source_labels: [__meta_kubernetes_pod_uid]
    target_label: sysdig_k8s_pod_uid
  - action: replace
    source_labels: [__meta_kubernetes_pod_container_name]
    target_label: sysdig_k8s_pod_container_name