Charts: [stable/prometheus-operator] servicemonitor are not loaded

Created on 9 Nov 2018  路  6Comments  路  Source: helm/charts

Is this a request for help?: Maybe


Is this a BUG REPORT or FEATURE REQUEST? (choose one): BUG REPORT

Version of Helm and Kubernetes:

Helm : 2.11.0
K8s : 1.11.3
On Azure AKS

Which chart: stable/prometheus-operator

What happened:

I created a custom ServiceMonitor in my monitoring namespace where I installed the chart:

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  name: monitoring-prometheus-oper-influxdb
  namespace: monitoring
spec:
  jobLabel: influxdb
  selector:
    matchLabels:
      app: influxdb
  namespaceSelector:
    matchNames:
      - prod
  endpoints:
    - port: exporter
      interval: 30s

However it is not pick up by Prometheus. After more tant 20 minutes, I still don't see the target on Prometheus web UI.

What you expected to happen:

The target to be created.

How to reproduce it (as minimally and precisely as possible):

  1. Create an AKS cluster
  2. Install the chart with standard values but with rbac disabled
  3. Create any custom servicemonitor resources.

It is not picked up.

Anything else we need to know: None

lifecyclstale

Most helpful comment

Prometheus has serviceMonitorSelector that only picks up on service monitors with specific labels. If you didn't customize the values file you will need to add the label to the service monitor that matches the release name of your prometheus operator:

release:

Here is an example for nginx-ingress. My chart release for the operator was called monitoring

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    release: monitoring
  name: nginx-ingress
spec:
  selector:
    matchLabels:
      release: nginx
  endpoints:
  - port: metrics

All 6 comments

Prometheus has serviceMonitorSelector that only picks up on service monitors with specific labels. If you didn't customize the values file you will need to add the label to the service monitor that matches the release name of your prometheus operator:

release:

Here is an example for nginx-ingress. My chart release for the operator was called monitoring

apiVersion: monitoring.coreos.com/v1
kind: ServiceMonitor
metadata:
  labels:
    release: monitoring
  name: nginx-ingress
spec:
  selector:
    matchLabels:
      release: nginx
  endpoints:
  - port: metrics

@dojadop : many thanks. It works.

When I read the values.yaml file of the chart, there is a comment above serviceMonitorSelector stating serviceMonitorSelector will limit which servicemonitors are used to create scrape configs in Prometheus. By default all are loaded. So my understanding was that it would load all resources of type servicemonitor per default. Maybe there is a small documentation issue here.

@jbouzekri This is definitely an issue with documentation on this chart, feel free to open PRs for anything that is not correct

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Any further update will cause the issue/pull request to no longer be considered stale. Thank you for your contributions.

Fixed in above PR. You need to use ruleSelectorNilUsesHelmValues=false for rules and serviceMonitorSelecorNilUsesHelmValues=false if you want to set the selectors to empty

Wow @dojadop I spent so long trying to figure out what was wrong with my setup, until I found your comment here about specific labels. Thank you so much!!

Was this page helpful?
0 / 5 - 0 ratings