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

feat: add servicemonitor additonal labels #354

Merged
merged 3 commits into from
Feb 27, 2024

Conversation

ckav370
Copy link
Contributor

@ckav370 ckav370 commented Feb 27, 2024

what

Add additional Kubernetes labels to the ServiceMonitor as this is often required by the Prometheus operator to identify the Service and pod(s).

why

The current configuration does not support adding labels to the Service Monitor. To add these labels in the case of adding a label for the Prometheus Operator, kustomize can be used or maintaining a separate resource for ServiceMonitor which is unnecessarily complex.

tests

Helm templates with servicemonitor.enabled set to true with test additionalLabels

servicemonitor:
  # to enable a Prometheus servicemonitor, set enabled to true,
  #   and enable the metrics in this file's repoConfig
  #   by setting a value for metrics.prometheus.endpoint
  enabled: true
  interval: "30s"
  path: /metrics
  # Prometheus ServiceMonitor labels
  additionalLabels:
    test-label: test
---
# Source: atlantis/templates/servicemonitor.yaml
apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: release-name-atlantis
  labels:
    app: atlantis
    chart: atlantis-4.21.0
    helm.sh/chart: atlantis-4.21.0
    release: release-name
    heritage: Helm
    test-label: test
spec:
  selector:
    matchLabels:
      app: atlantis
      chart: atlantis-4.21.0
      helm.sh/chart: atlantis-4.21.0
      release: release-name
      heritage: Helm
  namespaceSelector:
    matchNames:
     - default
  endpoints:
  - port: atlantis
    interval: 30s
    path: /metrics

references

#353 -> Link to a Issue :)

@ckav370 ckav370 requested a review from a team as a code owner February 27, 2024 16:09
@ckav370 ckav370 requested review from jamengual and removed request for a team February 27, 2024 16:09
@GMartinez-Sisti
Copy link
Member

Thanks @cblaindnsf !

@GMartinez-Sisti GMartinez-Sisti merged commit 9fb5bfd into runatlantis:main Feb 27, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants