kubernetes-yaml/learn/learn-kubernetes-master/kiamol/ch14/prometheus/update/prometheus-config-kube.yaml

67 lines
2.2 KiB
YAML
Raw Normal View History

apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
namespace: kiamol-ch14-monitoring
data:
prometheus.yml: |-
global:
scrape_interval: 30s
scrape_configs:
- job_name: 'test-pods'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_namespace
action: keep
regex: kiamol-ch14-test
- source_labels:
- __meta_kubernetes_pod_annotationpresent_prometheus_io_scrape
- __meta_kubernetes_pod_annotation_prometheus_io_scrape
regex: true;false
action: drop
- source_labels:
- __meta_kubernetes_pod_annotationpresent_prometheus_io_path
- __meta_kubernetes_pod_annotation_prometheus_io_path
regex: true;(.*)
target_label: __metrics_path__
- source_labels:
- __meta_kubernetes_pod_annotationpresent_prometheus_io_target
- __meta_kubernetes_pod_annotation_prometheus_io_target
regex: true;(.*)
target_label: __param_target
- 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
- job_name: 'cadvisor'
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_namespace
- __meta_kubernetes_pod_labelpresent_app
- __meta_kubernetes_pod_label_app
action: keep
regex: kube-system;true;cadvisor
- job_name: 'kube-state-metrics'
static_configs:
- targets:
- kube-state-metrics.kube-system.svc.cluster.local:8080
- kube-state-metrics.kube-system.svc.cluster.local:8081