-
Notifications
You must be signed in to change notification settings - Fork 37
/
prometheus-configmap.yaml
119 lines (118 loc) · 4.99 KB
/
prometheus-configmap.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
apiVersion: v1
kind: ConfigMap
metadata:
name: prometheus-config
labels:
app: prometheus-demo
namespace: monitoring
data:
prometheus.yml: |-
global:
scrape_interval: 5s
evaluation_interval: 5s
scrape_configs:
- job_name: 'kubedb-databases'
honor_labels: true
scheme: http
kubernetes_sd_configs:
- role: endpoints
# by default Prometheus server select all kubernetes services as possible target.
# relabel_config is used to filter only desired endpoints
relabel_configs:
# keep only those services that has "prometheus.io/scrape","prometheus.io/path" and "prometheus.io/port" anootations
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape, __meta_kubernetes_service_annotation_prometheus_io_port]
separator: ;
regex: true;(.*)
action: keep
# currently KubeDB supported databases uses only "http" scheme to export metrics. so, drop any service that uses "https" scheme.
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: drop
regex: https
# only keep the stats services created by KubeDB for monitoring purpose which has "-stats" suffix
- source_labels: [__meta_kubernetes_service_name]
separator: ;
regex: (.*-stats)
action: keep
# service created by KubeDB will have "kubedb.com/kind" and "kubedb.com/name" annotations. keep only those services that have these annotations.
- source_labels: [__meta_kubernetes_service_label_kubedb_com_kind]
separator: ;
regex: (.+)
action: keep
# read the metric path from "prometheus.io/path: <path>" annotation
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
# read the port from "prometheus.io/port: <port>" annotation and update scrapping address accordingly
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
# add service namespace as label to the scrapped metrics
- source_labels: [__meta_kubernetes_namespace]
separator: ;
regex: (.*)
target_label: namespace
replacement: $1
action: replace
# add service name as a label to the scrapped metrics
- source_labels: [__meta_kubernetes_service_name]
separator: ;
regex: (.*)
target_label: service
replacement: $1
action: replace
# add stats service's labels to the scrapped metrics
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- job_name: 'pgpool'
honor_labels: true
scheme: http
kubernetes_sd_configs:
- role: endpoints
# by default Prometheus server select all kubernetes services as possible target.
# relabel_config is used to filter only desired endpoints
relabel_configs:
# keep only those services that has "prometheus.io/scrape","prometheus.io/path" and "prometheus.io/port" anootations
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scrape, __meta_kubernetes_service_annotation_prometheus_io_port]
separator: ;
regex: true;(.*)
action: keep
# currently KubeDB supported databases uses only "http" scheme to export metrics. so, drop any service that uses "https" scheme.
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_scheme]
action: drop
regex: https
# only keep the stats services created by KubeDB for monitoring purpose which has "-stats" suffix
- source_labels: [__meta_kubernetes_service_name]
separator: ;
regex: (pgpool-stats)
action: keep
# read the metric path from "prometheus.io/path: <path>" annotation
- source_labels: [__meta_kubernetes_service_annotation_prometheus_io_path]
action: replace
target_label: __metrics_path__
regex: (.+)
# read the port from "prometheus.io/port: <port>" annotation and update scrapping address accordingly
- source_labels: [__address__, __meta_kubernetes_service_annotation_prometheus_io_port]
action: replace
target_label: __address__
regex: ([^:]+)(?::\d+)?;(\d+)
replacement: $1:$2
# add service namespace as label to the scrapped metrics
- source_labels: [__meta_kubernetes_namespace]
separator: ;
regex: (.*)
target_label: namespace
replacement: $1
action: replace
# add service name as a label to the scrapped metrics
- source_labels: [__meta_kubernetes_service_name]
separator: ;
regex: (.*)
target_label: service
replacement: $1
action: replace
# add stats service's labels to the scrapped metrics
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)