'K8 auto discovery in Prometheus with
How do I perform autodiscovery on K8s info for automatic scrapping? I'm trying to info on pods, deployments, clusters, etc. I tried using the following example yml file: https://github.com/helm/charts/tree/master/stable/prometheus
I was able to modify this file with a bunch of searches such as: How to scrape pod level info using prometheus kubernetes? https://prometheus.io/docs/prometheus/latest/configuration/configuration/#kubernetes_sd_config
I still cannot query or see any of this info (list and names of all pods, deployments, etc,). Any ideas? Here's the file:
prometheus:
alertmanager:
enabled: true
persistentVolume:
size: "1Gi"
server:
enabled: true
persistentVolume:
size: "1Gi"
alertmanagers:
- kubernetes_sd_configs:
- role: pod
namespaces:
names:
- default
serverFiles:
prometheus.yml:
scrape_configs:
- job_name: 'kubernetes-services'
kubernetes_sd_configs:
- role: service
namespaces:
names:
- default
- role: pod
namespaces:
names:
- default
- role: endpoints
namespaces:
names:
- default
relabel_configs:
- source_labels: [__meta_kubernetes_service_label_app]
separator: ;
regex: (.*)
replacement: $1
action: keep
- source_labels: [__meta_kubernetes_endpoint_port_name]
separator: ;
regex: prom
replacement: $1
action: keep
- source_labels: [__meta_kubernetes_namespace]
separator: ;
regex: (.*)
target_label: namespace
replacement: $1
action: replace
- source_labels: [__meta_kubernetes_pod_name]
separator: ;
regex: (.*)
target_label: pod
replacement: $1
action: replace
- source_labels: [__meta_kubernetes_service_name]
separator: ;
regex: (.*)
target_label: service
replacement: $1
action: replace
- source_labels: [__meta_kubernetes_service_name]
separator: ;
regex: (.*)
target_label: job
replacement: ${1}
action: replace
- separator: ;
regex: (.*)
target_label: endpoint
replacement: $1
action: replace
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
