Repository navigation
[stable/mongodb-replicaset] Prometheus Metrics export - #6282
Conversation
Adds a sidecar to export replicaset metrics
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/
|
/assign @unguiculus |
|
/assign |
|
@ssalaues , you can find prometheus operator settings in the kafka chart example: https://github.com/kubernetes/charts/blob/master/incubator/kafka/values.yaml#L266-L278 There they automatically deploy the kafka exporter and ServiceMonitor CRD. I suggest this PR do something similar. Check this template: https://github.com/kubernetes/charts/blob/master/incubator/kafka/templates/servicemonitors.yaml |
|
Thanks @agolomoodysaada ! I'll try that out |
Separate metric configuration options from annotations
|
I just added a commit to move away from the always on annotations that was specified before and separate the metrics configuration (had it combined with the annotations before). This will make it easier to setup ServiceMonitor for Prometheus Operator and have it separate from traditional Prometheus Service Discovery. |
| enabled: true | ||
| image: ssalaues/mongodb-exporter | ||
| imageTag: 0.5 | ||
| imagePullPolicy: IfNotPresent |
There was a problem hiding this comment.
Follow best practices:
metrics:
image:
repository:
tag:
pullPolicy:| metrics: | ||
| enabled: true | ||
| image: ssalaues/mongodb-exporter | ||
| imageTag: 0.5 |
| mongo admin "${ssl_args[@]}" --eval "db.createUser({user: '$admin_user', pwd: '$admin_password', roles: [{role: 'root', db: 'admin'}]})" | ||
| if [[ "$METRICS" == "true" ]]; then | ||
| log "Creating cluterMonitor user..." | ||
| mongo admin "${ssl_args[@]}" --eval "db.auth('$admin_user', '$admin_password'); db.createUser({user: '$metrics_user', pwd: '$metrics_password', roles: [{role: 'clusterMonitor', db: 'admin'}]})" |
There was a problem hiding this comment.
The user also needs read on local. See https://github.com/percona/mongodb_exporter
| - name: metrics | ||
| port: {{ .Values.metrics.port }} | ||
| targetPort: metrics | ||
| {{- end }} |
There was a problem hiding this comment.
Be consistent with the rest of the chart and indent as follows:
{{- if .Values.metrics.enabled }}
- name: metrics
port: {{ .Values.metrics.port }}
targetPort: metrics
{{- end }}| -mongodb.tls-cert=/work-dir/mongo.pem | ||
| {{- end }} | ||
| -web.metrics-path={{ .Values.metrics.path }} | ||
| -web.listen-address=:{{ .Values.metrics.port }} |
There was a problem hiding this comment.
There are timeout flags in the latest release I added in percona/mongodb_exporter#100. Please make them configurable as well.
| {{ toYaml .Values.extraLabels | indent 8 }} | ||
| {{- end }} | ||
| annotations: | ||
| {{- if .Values.metrics.enabled }} |
There was a problem hiding this comment.
You still set the annotations when metrics are enable. You don't need them when using the operator. They should be optional.
|
@gianrubio Would you mind having a look as well? |
|
Made the requested changes @unguiculus. Thanks! |
| metrics: | ||
| enabled: true | ||
| image: | ||
| repository: ssalaues/mongodb-exporter |
There was a problem hiding this comment.
Why you are not using the oficial image?
There was a problem hiding this comment.
Unfortunately, there is no official image.
| exec: | ||
| command: | ||
| - sh | ||
| - -ec |
There was a problem hiding this comment.
I think you should specify the command as above for the container using - |- and then adding the complete script instea of line by line as list.
There was a problem hiding this comment.
I added the script lines as requested. Would it be preferred to also combine the sh -ec after the - |- or keep as is?
| # socketTimeout: 3s | ||
| # syncTimeout: 1m | ||
| # prometheusServiceDiscovery: true | ||
| # resources: {} |
There was a problem hiding this comment.
Dont comment out all the values.
metrics:
enabled: false
image:
repository: ssalaues/mongodb-exporter
tag: 0.6.1
pullPolicy: IfNotPresent
port: 9216
path: "/metrics"
socketTimeout: 3s
syncTimeout: 1m
prometheusServiceDiscovery: true
resources: {}|
Added a commit to change the |
|
/ok-to-test |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ssalaues, unguiculus The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
…labels * kubernetes/master: (411 commits) [stable/efs-provisioner] Chart for efs-provisioner, a Kubernetes external-storage provisioner (helm#3233) [stable/filebeat] filebeat fixes (helm#6332) [stable/stolon] Add support for priorityClasses (helm#6607) [stable/external-dns] Add support for priorityClasses (helm#6606) [stable/minio] Add support for priorityClasses (helm#6604) [stable/cluster-autoscaler] Add support for priorityClasses (helm#6603) [stable/oauth2-proxy] Add support for priorityClasses (helm#6586) [stable/elasticsearch-exporter] add support for priorityClasses (helm#6584) [stable/traefik] adding support for traefik wildcard certificates (helm#6015) gcloud-sqlproxy: add tolerations and affinity to the Deployment (helm#6495) Review readme (helm#6399) [stable/mongodb-replicaset] Prometheus Metrics export (helm#6282) [stable/artifactory-ha] Typo fix: livessProbed->livenessProbed (helm#6462) [stable/artifactory] livessProbed->livenessProbed (helm#6461) [incubator/kube-spot-termination-notice-handler] Add Support for Tolerations (helm#5813) [stable/kanister-operator] RBAC changes and kanister profile creation (helm#6280) fix redis-ha NOTE.txt, stable/redis-ha don't create master-0 pod (helm#6131) [stable/concourse] add support for custom envvars for the web containers (helm#6441) upgrade to latest prometheus release 2.3.2 and alertmanager 0.15.1 (helm#6623) cert-manager: fast-forward to upstream 777ce6f4 (helm#6625) ...
|
Thank you for your help in getting this merged @unguiculus |
* [stable/mongodb-replicaset] Prometheus Metrics export Adds a sidecar to export replicaset metrics * 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 * Update metrics config options Separate metric configuration options from annotations * Best practices, cleanup, and requested changes * Consistency and additional requested changes * Switch commands to folded yaml blocks Signed-off-by: Jakob Niggel <[email protected]>
* [stable/mongodb-replicaset] Prometheus Metrics export Adds a sidecar to export replicaset metrics * 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 * Update metrics config options Separate metric configuration options from annotations * Best practices, cleanup, and requested changes * Consistency and additional requested changes * Switch commands to folded yaml blocks
Original PR #5874
What this PR does / why we need it:
Adds Prometheus metrics to the mongodb-replicaset chart using the a readonly clusterMonitor mongodb account for metrics authentication.
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close that issue when PR gets merged): fixes #Special notes for your reviewer:
Fixes from the previous PR
Need clarification on the Prometheus annotations.