Prometheus config to only look for pods in specific namespaces and not use ClusterScope?

25 views
Skip to first unread message

Klavs Klavsen

unread,
Jun 24, 2020, 8:10:10 AM6/24/20
to Prometheus Users
How can I make Prometheus not try to use ClusterScope detection and only discover in specific namespaces?

I am running this config:
```
global:
  evaluation_interval: 1m
  scrape_interval: 1m
  scrape_timeout: 10s
rule_files:
- /etc/config/recording_rules.yml
- /etc/config/alerting_rules.yml
scrape_configs:
- job_name: prometheus
  static_configs:
  - targets:
    - localhost:9090
- job_name: kubernetes-pods
  kubernetes_sd_configs:
  - role: pod
    namespaces:
      names:
      - api-testns1
      - api-testns2
  relabel_configs:
  - action: keep
```

But Prometheus is still trying to discover pods using ClusterScope, as I'm getting this error in prometheus server pod:

 Failed to list *v1.Pod: pods is forbidden: User \"system:serviceaccount:api-testmon:prom-server-api-testmon\" cannot list pods at the cluster scope: no RBAC policy matched



Klavs Klavsen

unread,
Jun 24, 2020, 8:22:48 AM6/24/20
to Prometheus Users
I get this error - even if I remove the -job_name: kubernetes-pods entirely.. so maybe its something else in prometheus, that needs disabling?
Reply all
Reply to author
Forward
0 new messages