kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch14/lab/monitoring/prometheus-config.yaml

41 lines
1.2 KiB
YAML

apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: kiamol-ch14-lab-monitoring
data:
prometheus.yml: |-
global:
scrape_interval: 30s
scrape_configs:
- job_name: 'lab-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_namespace
action: keep
regex: kiamol-ch14-lab
- source_labels:
- __meta_kubernetes_pod_annotationpresent_prometheus_io_port
- __address__
- __meta_kubernetes_pod_annotation_prometheus_io_port
action: replace
regex: true;([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
target_label: __address__
- source_labels:
- __meta_kubernetes_pod_labelpresent_app
- __meta_kubernetes_pod_label_app
regex: true;(.*)
target_label: job
- source_labels:
- __meta_kubernetes_pod_name
target_label: instance
- source_labels:
- __meta_kubernetes_pod_labelpresent_version
- __meta_kubernetes_pod_label_version
regex: true;(.*)
target_label: version