Skip to content

Commit

Permalink
[bitnami/mongodb] feat: allow setting targetLabel and `podTargetLab…
Browse files Browse the repository at this point in the history
…els` array on ServiceMonitor

This will allow chart users to include additional labels to prometheus metrics collected on mongodb

Signed-off-by: Umar Hussain <[email protected]>
  • Loading branch information
umarhussain15 committed Nov 19, 2024
1 parent b850cea commit a3d274d
Show file tree
Hide file tree
Showing 5 changed files with 3,540 additions and 229 deletions.
2 changes: 1 addition & 1 deletion bitnami/mongodb/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ maintainers:
name: mongodb
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/mongodb
version: 16.3.0
version: 16.4.0
2 changes: 2 additions & 0 deletions bitnami/mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,8 @@ If you encounter errors when working with persistent volumes, refer to our [trou
| `metrics.serviceMonitor.selector` | Prometheus instance selector labels | `{}` |
| `metrics.serviceMonitor.honorLabels` | Specify honorLabels parameter to add the scrape endpoint | `false` |
| `metrics.serviceMonitor.jobLabel` | The name of the label on the target service to use as the job name in prometheus. | `""` |
| `metrics.serviceMonitor.targetLabels` | Defines the labels which are transferred from the associated Kubernetes Service object onto the ingested metrics. | `[]` |
| `metrics.serviceMonitor.podTargetLabels` | Defines the labels which are transferred from the associated Kubernetes Pod object onto the ingested metrics. | `[]` |
| `metrics.prometheusRule.enabled` | Set this to true to create prometheusRules for Prometheus operator | `false` |
| `metrics.prometheusRule.additionalLabels` | Additional labels that can be used so prometheusRules will be discovered by Prometheus | `{}` |
| `metrics.prometheusRule.namespace` | Namespace where prometheusRules resource should be created | `""` |
Expand Down
8 changes: 8 additions & 0 deletions bitnami/mongodb/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ spec:
{{- if .Values.metrics.serviceMonitor.jobLabel }}
jobLabel: {{ .Values.metrics.serviceMonitor.jobLabel }}
{{- end }}
{{- if and .Values.metrics.serviceMonitor.targetLabels (gt (len .Values.metrics.serviceMonitor.targetLabels) 0)}}
targetLabels:
{{- .Values.metrics.serviceMonitor.targetLabels | toYaml | nindent 4}}
{{- end }}
{{- if and .Values.metrics.serviceMonitor.podTargetLabels (gt (len .Values.metrics.serviceMonitor.podTargetLabels) 0)}}
podTargetLabels:
{{- .Values.metrics.serviceMonitor.podTargetLabels | toYaml | nindent 4}}
{{- end }}
selector:
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 6 }}
{{- if .Values.metrics.serviceMonitor.selector }}
Expand Down
Loading

0 comments on commit a3d274d

Please sign in to comment.