While reading Prometheus Configuration documentation and some sample scrape configurations, I found some kubernetes_sd_configs with role service
& role endpoints
& role pod
- job_name: kube-state-metrics
kubernetes_sd_configs:
- role: endpoints
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- action: keep
regex: prometheus;kube-state-metrics
source_labels:
- __meta_kubernetes_namespace
- __meta_kubernetes_pod_label_component
- honor_labels: true
job_name: prometheus-pushgateway
kubernetes_sd_configs:
- role: service
relabel_configs:
- action: keep
regex: pushgateway
source_labels:
- __meta_kubernetes_service_annotation_prometheus_io_probe
- job_name: node-exporter
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
source_labels:
- __address__
- __meta_kubernetes_pod_container_port_number
target_label: __address__
Looks like all these roles can scrape the metrics from instances,
When shall we use endpoints & when shall we use pod?
EDIT: my real question is, which role (endpoints or pod) shall I use if they both discover the scraping target?
what do you prefer? any examples?