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

Customize label selector for prometheus-operator-managed ServiceMonitors #2199

Closed
gdemonet opened this issue Jan 21, 2020 · 0 comments · Fixed by #3356
Closed

Customize label selector for prometheus-operator-managed ServiceMonitors #2199

gdemonet opened this issue Jan 21, 2020 · 0 comments · Fixed by #3356
Assignees
Labels
kind:debt Technical debt topic:deployment Bugs in or enhancements to deployment stages topic:docs Documentation topic:monitoring Everything related to monitoring of services in a running cluster topic:solutions Anything related to external "Solutions" integration with the platform

Comments

@gdemonet
Copy link
Contributor

gdemonet commented Jan 21, 2020

Component: monitoring, salt

Why this is needed:

When Solutions (and most likely, their Operators) set up metrics scraping by the Prometheus provided by MetalK8s, they can either:

Our current deployment of prometheus-operator only looks at ServiceMonitors that match the release=prometheus-operator label. This can be too generic if other Prometheus Operators are deployed in the cluster, and doesn't make much sense outside of the Helm chart context.

What should be done:

Instead, we should define and use a custom label for these, e.g. metalk8s.scality.com/monitor="".
We should also document this label clearly in Solution developer docs (see #1994).

Implementation proposal (strongly recommended):

Test plan:


Epic: #1994

@gdemonet gdemonet added topic:docs Documentation topic:deployment Bugs in or enhancements to deployment stages moonshot topic:solutions Anything related to external "Solutions" integration with the platform topic:monitoring Everything related to monitoring of services in a running cluster labels Jan 21, 2020
alexandre-allard added a commit that referenced this issue May 4, 2021
The selector is for Probe, ServiceMonitor and
PrometheusRule objects and it must match the label
`metalk8s.scality.com/monitor: ''`

We also add this labels to all resources deployed
by the kube-prometheus-stack chart as there is
actually no way to only add it to specific
resources (except for PrometheusRule).

Refs: #2199
alexandre-allard added a commit that referenced this issue May 4, 2021
We now use custom label selector
`metalk8s.scality.com/monitor` instead of the
default one `release` and `app` to target
ServiceMonitors, PrometheusRules and Probes.

kube-prometheus chart render command:
```
./charts/render.py prometheus-operator \
  charts/kube-prometheus-stack.yaml \
  charts/kube-prometheus-stack/ \
  --namespace metalk8s-monitoring \
  --service-config grafana \
  metalk8s-grafana-config \
  metalk8s/addons/prometheus-operator/config/grafana.yaml \
  metalk8s-monitoring \
  --service-config prometheus \
  metalk8s-prometheus-config \
  metalk8s/addons/prometheus-operator/config/prometheus.yaml \
  metalk8s-monitoring \
  --service-config alertmanager \
  metalk8s-alertmanager-config \
  metalk8s/addons/prometheus-operator/config/alertmanager.yaml \
  metalk8s-monitoring \
  --service-config dex \
  metalk8s-dex-config \
  metalk8s/addons/dex/config/dex.yaml.j2 metalk8s-auth \
  --drop-prometheus-rules charts/drop-prometheus-rules.yaml \
  > salt/metalk8s/addons/prometheus-operator/deployed/chart.sls
```

Refs: #2199
@alexandre-allard alexandre-allard added the kind:debt Technical debt label May 5, 2021
@alexandre-allard alexandre-allard self-assigned this May 6, 2021
alexandre-allard added a commit that referenced this issue May 7, 2021
The selector is for Probe, ServiceMonitor and
PrometheusRule objects and it must match the label
`metalk8s.scality.com/monitor: ''`

We also add this labels to all resources deployed
by the kube-prometheus-stack chart as there is
actually no way to only add it to specific
resources (except for PrometheusRule).

Refs: #2199
alexandre-allard added a commit that referenced this issue May 7, 2021
We now use custom label selector
`metalk8s.scality.com/monitor` instead of the
default one `release` and `app` to target
ServiceMonitors, PrometheusRules and Probes.

kube-prometheus chart render command:
```
./charts/render.py prometheus-operator \
  charts/kube-prometheus-stack.yaml \
  charts/kube-prometheus-stack/ \
  --namespace metalk8s-monitoring \
  --service-config grafana \
  metalk8s-grafana-config \
  metalk8s/addons/prometheus-operator/config/grafana.yaml \
  metalk8s-monitoring \
  --service-config prometheus \
  metalk8s-prometheus-config \
  metalk8s/addons/prometheus-operator/config/prometheus.yaml \
  metalk8s-monitoring \
  --service-config alertmanager \
  metalk8s-alertmanager-config \
  metalk8s/addons/prometheus-operator/config/alertmanager.yaml \
  metalk8s-monitoring \
  --service-config dex \
  metalk8s-dex-config \
  metalk8s/addons/dex/config/dex.yaml.j2 metalk8s-auth \
  --drop-prometheus-rules charts/drop-prometheus-rules.yaml \
  > salt/metalk8s/addons/prometheus-operator/deployed/chart.sls
```

Refs: #2199
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:debt Technical debt topic:deployment Bugs in or enhancements to deployment stages topic:docs Documentation topic:monitoring Everything related to monitoring of services in a running cluster topic:solutions Anything related to external "Solutions" integration with the platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants