Limit prometheus to discover pods in specific namespaces ONLY

Viewed 997

I am trying to run Prometheus to ONLY monitor pods in specific namespaces (in openshift cluster).

I am getting "cannot list pods at the cluster scope" - But I have tried to set it to not use ClusterScope (only look in specific namespaces instead)..

I've set:

      prometheus.yml: |
        scrape_configs:
        - job_name: prometheus
          static_configs:
          - targets:
            - localhost:9090
        - job_name: kubernetes-pods
          kubernetes_sd_configs:
          - namespaces:
              names:
              - api-mytestns1
              - api-mytestns2
            role: pod
          relabel_configs:
[cut]

I get this error - even if I remove the -job_name: kubernetes-pods entirely.. so maybe its something else in prometheus, that needs disabling?

1 Answers

I found that one had to overwrite server.alertmanagers with a complete copy of the settings in charts/prometheus/templates/server-configmap.yaml - to override the hardcoded default in those, to try and scrape cluster-wide.

Related