Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[prometheus-blackbox-exporter] define metricRelabelings in selfservicemonitor.yaml to handle additionalMetricsRelabels #4303

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

Sheikh-Abubaker
Copy link
Contributor

@Sheikh-Abubaker Sheikh-Abubaker commented Feb 27, 2024

What this PR does / why we need it

Which issue this PR fixes

(optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close that issue when PR gets merged)

Special notes for your reviewer

Generated ServiceMonitor resource after defining metricRelabelings in selfservicemonitor.yaml, and when additionalMetricsRelabels set to an empty list.

helm template . -f override-values.yaml

---
# Source: prometheus-blackbox-exporter/templates/selfservicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: release-name-prometheus-blackbox-exporter
  namespace: default
  labels:
    helm.sh/chart: prometheus-blackbox-exporter-8.13.0
    app.kubernetes.io/name: prometheus-blackbox-exporter
    app.kubernetes.io/instance: release-name
    app.kubernetes.io/version: "v0.24.0"
    app.kubernetes.io/managed-by: Helm
spec:
  endpoints:
  - path: /metrics
    interval: 30s
    scrapeTimeout: 30s
    scheme: http
    metricRelabelings:
      - action: keep
        regex: prometheus
        sourceLabels:
        - __meta_kubernetes_pod_label_team
      - action: drop
        regex: west_europe
        sourceLabels:
        - __meta_kubernetes_pod_label_datacenter
  jobLabel: "release-name"
  selector:
    matchLabels:
      app.kubernetes.io/name: prometheus-blackbox-exporter
      app.kubernetes.io/instance: release-name
  namespaceSelector:
    matchNames:
      - default

additionalMetricsRelabels changed to empty list due to this warning

helm template . -f override-values.yaml
 coalesce.go:286: warning: cannot overwrite table with non table for prometheus-blackbox-exporter.serviceMonitor.selfMonitor.additionalMetricsRelabels (map[])
# override-values.yaml 

serviceMonitor:
## If true, a ServiceMonitor CRD is created for a prometheus operator
## https://github.com/coreos/prometheus-operator for blackbox-exporter itself
##
selfMonitor:
  enabled: true
  additionalMetricsRelabels:
  - sourceLabels:
    - __meta_kubernetes_pod_label_team
    regex: "prometheus"
    action: keep
  - sourceLabels:
    - __meta_kubernetes_pod_label_datacenter
    regex: west_europe
    action: drop
  additionalRelabeling: []
  labels: {}
  path: /metrics
  interval: 30s
  scrapeTimeout: 30s

Checklist

  • DCO signed
  • Chart Version bumped
  • Title of the PR starts with chart name (e.g. [prometheus-couchdb-exporter])

Signed-off-by: Sheikh-Abubaker <sheikhabubaker761@gmail.com>
@@ -271,7 +271,7 @@ serviceMonitor:
##
selfMonitor:
enabled: false
additionalMetricsRelabels: {}
additionalMetricsRelabels: []
Copy link
Member

@monotek monotek Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will break:

{{- if .Values.podMonitoring.selfMonitor.additionalMetricsRelabels }}
metricRelabeling:
{{- range $targetLabel, $replacement := .Values.podMonitoring.selfMonitor.additionalMetricsRelabels | default $.Values.podMonitoring.defaults.additionalMetricsRelabels }}
- action: replace
targetLabel: {{ $targetLabel | quote }}
replacement: {{ $replacement | quote }}
{{- end }}
{{- end }}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@monotek can you please elaborate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you switch from list to map but map is used elsewhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you switch from list to map

*from map to list right ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you switch from list to map but map is used elsewhere.

what do you suggest should I revert it to map again ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please checkout the latest commit I've reverted additionalMetricsRelabels to map.

@Sheikh-Abubaker Sheikh-Abubaker changed the title [prometheus-blackbox-exporter] defined metricRelabelings in selfservicemonitor.yaml to handle additionalMetricsRelabels [prometheus-blackbox-exporter] define metricRelabelings in selfservicemonitor.yaml to handle additionalMetricsRelabels Mar 21, 2024
Signed-off-by: Sheikh-Abubaker <sheikhabubaker761@gmail.com>
Signed-off-by: Sheikh-Abubaker <sheikhabubaker761@gmail.com>
Signed-off-by: Sheikh-Abubaker <sheikhabubaker761@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants