-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathprometheus-configmap-2.yaml
56 lines (56 loc) · 1.99 KB
/
prometheus-configmap-2.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus
data:
prometheus.yml: |-
global:
scrape_interval: 15s
scrape_configs:
# etcd is living outside of our cluster and we configure
# it directly.
- job_name: 'etcd'
target_groups:
- targets:
- 172.17.4.51:2379
- job_name: 'kubernetes_components'
kubernetes_sd_configs:
- api_servers:
- 'https://kubernetes'
in_cluster: true
# This configures Prometheus to identify itself when scraping
# metrics from Kubernetes cluster components.
tls_config:
ca_file: /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
bearer_token_file: /var/run/secrets/kubernetes.io/serviceaccount/token
# Prometheus provides meta labels for each monitoring targets. We use
# these to select targets we want to monitor and to modify labels attached
# to scraped metrics.
relabel_configs:
# Only scrape apiserver and kubelets.
- source_labels: [__meta_kubernetes_role]
action: keep
regex: (?:apiserver|node)
# Redefine the Prometheus job based on the monitored Kuberentes component.
- source_labels: [__meta_kubernetes_role]
target_label: job
replacement: kubernetes_$1
# Attach all node labels to the metrics scraped from the components running
# on that node.
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
- job_name: 'kubernetes_services'
kubernetes_sd_configs:
- api_servers:
- 'https://kubernetes'
in_cluster: true
relabel_configs:
- source_labels: [__meta_kubernetes_role, __meta_kubernetes_service_annotation_prometheus_io_scrape]
action: keep
regex: endpoint;true
- source_labels: [__meta_kubernetes_service_name]
target_label: job
- source_labels: [__meta_kubernetes_namespace]
target_label: namespace
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)