prometheus-mongodb-exporter

by Prometheus

Helm chartv4.1.0App 0.55.0Verified publisher

A Prometheus exporter for MongoDB metrics

About this chart

Prometheus MongoDB Exporter

A Prometheus exporter for MongoDB metrics.

Installs the MongoDB Exporter for Prometheus. The MongoDB Exporter collects and exports oplog, replica set, server status, sharding and storage engine metrics.

Usage

The chart is distributed as an OCI Artifact as well as via a traditional Helm Repository.

  • OCI Artifact: oci://ghcr.io/prometheus-community/charts/prometheus-mongodb-exporter
  • Helm Repository: https://prometheus-community.github.io/helm-charts with chart prometheus-mongodb-exporter

The installation instructions use the OCI registry. Refer to the helm repo command documentation for information on installing charts via the traditional repository.

Install Chart

helm install [RELEASE_NAME] oci://ghcr.io/prometheus-community/charts/prometheus-mongodb-exporter

See configuration below.

See helm install for command documentation.

Uninstall Chart

helm uninstall [RELEASE_NAME]

This removes all the Kubernetes components associated with the chart and deletes the release.

See helm uninstall for command documentation.

Upgrading Chart

helm upgrade [RELEASE_NAME] [CHART] --install

See helm upgrade for command documentation.

Upgrading an existing Release to a new major version

A major chart version change (like v1.2.3 -> v2.0.0) indicates that there is an incompatible breaking change needing manual actions.

From 3.x to 4.x

The exporter Pod no longer mounts a Kubernetes service account token: serviceAccount.automountServiceAccountToken now defaults to false and also applies to the Pod. The exporter does not call the Kubernetes API. If you add containers that need API credentials, set it back to true.

podSecurityContext now defaults to seccompProfile: RuntimeDefault, so together with the existing securityContext the exporter meets the restricted Pod Security Standard. The helm test Pod uses a pinned busybox image (tests.image) and the same restrictions.

The Pod spec changes, so the exporter restarts once on upgrade.

From 2.x to 3.x

This version uses the original percona/mongodb_exporter Docker image again, as described in the readme and Chart.yaml. It's maintained and it uses frequent Docker builds, so this is preferable for security reasons.

The command arguments of the exporter have changed. If you have custom extraArgs settings you have to adjust them. Because of the newer version of the exporter image metrics may vary though, so you might need to adjust your dashboard queries or try out the "--compatible-mode" parameter in extraArgs.

The mongodb.uri variable got "mongodb://mongodb:27017" as default parameter.

Chart API was raisded to v2, so Helm 2 is not supported anymore.

The servicemonitor has been disabled by default as prometheus operator might not be installed in cluster.

Configuration

See Customizing the Chart Before Installing. To see all configurable options with detailed comments, visit the chart's values.yaml, or run these configuration commands:

helm show values oci://ghcr.io/prometheus-community/charts/prometheus-mongodb-exporter

MongoDB Server Connection

To use the chart, ensure the mongodb.uri is populated with a valid MongoDB URI or an existing secret (in the releases namespace) containing the key defined on existingSecret.key, with the URI is referred via existingSecret.name. If no secret key is defined, the default value is mongodb-uri.

If the MongoDB server requires authentication, credentials should be populated in the connection string as well. The MongoDB Exporter supports connecting to either a MongoDB replica set member, shard, or standalone instance.

Service Monitor

The chart comes with a ServiceMonitor for use with the Prometheus Operator. By default, the ServiceMonitor is disabled. You can enable the ServiceMonitor by setting serviceMonitor.enabled to true. For the ServiceMonitor to be detected by the Prometheus Operator, you must add the selector label to serviceMonitor.additionalLabels. You can find this label under spec.serviceMonitorSelector of the Prometheus CRD.

If you're not using the Prometheus Operator, you can instead populate the podAnnotations as below:

podAnnotations:
  prometheus.io/scrape: "true"
  prometheus.io/port: "9216"

Deploy prometheus-mongodb-exporter with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has prometheus-mongodb-exporter on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartprometheus-mongodb-exporter is pinned at v4.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply