From 4fa2cd394165d8cfe65889168f152dbcbeac2833 Mon Sep 17 00:00:00 2001 From: Salim Salaues Date: Mon, 18 Jun 2018 11:30:31 -0700 Subject: [PATCH] Add Prometheus Exports to Mongodb Replicaset (#5874) * Replicaset Prometheus Metrics export * bugfix: Fix TLS issues 1. Moves context of ssl configuration script into /work-dir where certain files are expected to be created. 2. Specifies the --sslMode=requireSSL flag on the container command when using TLS as specified by mongo docs. https://docs.mongodb.com/manual/tutorial/configure-ssl/ * Documentation on metrics options * Bump Chart Version --- stable/mongodb-replicaset/Chart.yaml | 3 +- stable/mongodb-replicaset/README.md | 21 ++++++ stable/mongodb-replicaset/init/on-start.sh | 3 + stable/mongodb-replicaset/metrics/Dockerfile | 13 ++++ stable/mongodb-replicaset/metrics/Makefile | 27 +++++++ .../templates/mongodb-service.yaml | 8 +++ .../templates/mongodb-statefulset.yaml | 71 ++++++++++++++++++- stable/mongodb-replicaset/values.yaml | 12 ++++ 8 files changed, 155 insertions(+), 3 deletions(-) create mode 100644 stable/mongodb-replicaset/metrics/Dockerfile create mode 100644 stable/mongodb-replicaset/metrics/Makefile diff --git a/stable/mongodb-replicaset/Chart.yaml b/stable/mongodb-replicaset/Chart.yaml index 2009f67e1e..815e790d11 100644 --- a/stable/mongodb-replicaset/Chart.yaml +++ b/stable/mongodb-replicaset/Chart.yaml @@ -1,12 +1,13 @@ name: mongodb-replicaset home: https://github.com/mongodb/mongo -version: 3.4.1 +version: 3.5.0 appVersion: 3.6 description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. icon: https://webassets.mongodb.com/_com_assets/cms/mongodb-logo-rgb-j6w271g1xn.jpg sources: - https://github.com/mongodb/mongo + - https://github.com/percona/mongodb_exporter maintainers: - name: foxish email: ramanathana@google.com diff --git a/stable/mongodb-replicaset/README.md b/stable/mongodb-replicaset/README.md index cc09e44f76..1585947471 100644 --- a/stable/mongodb-replicaset/README.md +++ b/stable/mongodb-replicaset/README.md @@ -51,6 +51,7 @@ The following table lists the configurable parameters of the mongodb chart and t | `tls.enabled` | Enable MongoDB TLS support including authentication | `false` | | `tls.cacert` | The CA certificate used for the members | Our self signed CA certificate | | `tls.cakey` | The CA key used for the members | Our key for the self signed CA certificate | +| `metrics.enabled` | Enable Prometheus compatible metrics for pods and replicasets | `false` | | `auth.enabled` | If `true`, keyfile access control is enabled | `false` | | `auth.key` | Key for internal authentication | `` | | `auth.existingKeySecret` | If set, an existing secret with this name for the key is used | `` | @@ -160,6 +161,26 @@ mongodb with your `mongo.pem` certificate: ```console $ mongo --ssl --sslCAFile=ca.crt --sslPEMKeyFile=mongo.pem --eval "db.adminCommand('ping')" ``` + +## Promethus metrics +Enabling the metrics as follows will allow for each replicaset pod to export Prometheus compatible metrics +on server status, individual replicaset information, replication oplogs, and storage engine. + +```yaml +metrics: + enabled: true + image: ssalaues/mongodb-exporter + imageTag: 0.5 + imagePullPolicy: IfNotPresent + resources: {} + annotations: + prometheus.io/scrape: "true" + prometheus.io/port: "9216" + prometheus.io/path: "/metrics" +``` + +More information on [MongoDB Exporter](https://github.com/percona/mongodb_exporter) metrics available. + ## Readiness probe The default values for the readiness probe are: diff --git a/stable/mongodb-replicaset/init/on-start.sh b/stable/mongodb-replicaset/init/on-start.sh index fa23d6f285..811dca5a9c 100644 --- a/stable/mongodb-replicaset/init/on-start.sh +++ b/stable/mongodb-replicaset/init/on-start.sh @@ -61,6 +61,9 @@ if [ -f "$ca_crt" ]; then pem=/work-dir/mongo.pem ssl_args=(--ssl --sslCAFile "$ca_crt" --sslPEMKeyFile "$pem") +# Move into /work-dir +pushd /work-dir + cat >openssl.cnf <