Skip to content

Atlas monitoring

๐Ÿ”ญ Monitoring MongoDB Atlasยถ

This guide explains how to monitor MongoDB Atlas clusters using Prometheus and Kubernetes secrets. It covers both private and public endpoint scraping for various environments.


๐Ÿ›ก๏ธ Creating Kubernetes Secrets for Prometheus Authenticationยถ

Use the following command to create a Kubernetes secret for Prometheus authentication:

kubectl create secret generic atlas-prom --from-literal=password='your_password_here'

Alternatively, define the secret in a manifest:

apiVersion: v1
kind: Secret
metadata:
  name: atlas-prom
  namespace: monitoring
data:
  password: your_password_here
type: Opaque

Security Best Practice

Store sensitive credentials such as Prometheus passwords in Kubernetes secrets to avoid exposing them in plain text.


๐Ÿ“ˆ Prometheus Scrape Configuration Exampleยถ

Configure Prometheus to scrape metrics from MongoDB Atlas using basic authentication and HTTP service discovery:

- job_name: "indosat-sia-prod-mongo-metrics"
  scrape_interval: 10s
  metrics_path: /metrics
  scheme: https
  basic_auth:
    username: prom_user_669509e9d930873050bd0c1b
    password: your_password_here
  http_sd_configs:
    - url: https://cloud.mongodb.com/prometheus/v1.0/groups/669509e9d930873050bd0c1b/discovery?targetScheme=PRIVATE
      refresh_interval: 60s
      basic_auth:
        username: prom_user_669509e9d930873050bd0c1b
        password: OWT05GmraLAi2vKM

๐ŸŒŽ Atlas US-ATnT Environmentยถ

๐Ÿ”’ Private Endpoint Scrapingยถ

- job_name: "US-ATnT-mongo-metrics"
  scrape_interval: 30s
  metrics_path: /metrics
  scheme: https
  basic_auth:
    username: prom_user_67c54c8083f8942c14ba95e9
    password: your_password_here
  http_sd_configs:
    - url: https://cloud.mongodb.com/prometheus/v1.0/groups/67c54c8083f8942c14ba95e9/discovery?targetScheme=PRIVATE
      refresh_interval: 60s
      basic_auth:
        username: prom_user_67c54c8083f8942c14ba95e9
        password: fwafPmeeGZr87CdW

๐ŸŒ Public Endpoint Scrapingยถ

- job_name: "US-ATnT-mongo-metrics-pub"
  scrape_interval: 30s
  metrics_path: /metrics
  scheme: https
  basic_auth:
    username: prom_user_67c54c8083f8942c14ba95e9
    password: your_password_here
  http_sd_configs:
    - url: https://cloud.mongodb.com/prometheus/v1.0/groups/67c54c8083f8942c14ba95e9/discovery
      refresh_interval: 60s
      basic_auth:
        username: prom_user_67c54c8083f8942c14ba95e9
        password: fwafPmeeGZr87CdW

Endpoint Selection

  • Use the targetScheme=PRIVATE parameter for private endpoint scraping.
  • Omit the parameter for public endpoint scraping.

Credential Management

  • Always rotate credentials regularly and avoid hardcoding sensitive information in