-
Notifications
You must be signed in to change notification settings - Fork 23
/
prometheus-config-map.yml.j2
109 lines (106 loc) · 4.21 KB
/
prometheus-config-map.yml.j2
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
---
global:
evaluation_interval: 5s
scrape_interval: 5s
scrape_configs:
- job_name: prometheus
static_configs:
- targets:
- "localhost:9090"
- job_name: mcp-ssl-services
scheme: https
tls_config:
insecure_skip_verify: true
kubernetes_sd_configs:
- role: service
namespaces:
names:
- {{ namespace }}
# we use relabeling mechanism of Prometheus to decide if a service is a scrape target.
# same mechanism is used to find out the metrics endpoint path.
# see example config here: https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml
relabel_configs:
# if the service that is currently checked has the annotation "org.aerogear.metrics/ssl_endpoint", keep it. it will be a scrape target.
- action: keep
regex: \/.*
source_labels:
# explanation of: __meta_kubernetes_service_annotation_org_aerogear_metrics_ssl_endpoint
# 1. __meta_kubernetes_service_annotation_ : comes from https://prometheus.io/docs/prometheus/latest/configuration/configuration/#service
# 2. org_aerogear_metrics_ssl_endpoint : the annotation we're looking for. but '.' and '/' are converted to '_'
- __meta_kubernetes_service_annotation_org_aerogear_metrics_ssl_endpoint
- source_labels:
- __address__
target_label: __param_target
- source_labels:
- __param_target
target_label: instance
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels:
- __meta_kubernetes_namespace
target_label: kubernetes_namespace
- source_labels:
- __meta_kubernetes_service_name
target_label: kubernetes_name
# set __metrics_path__ from the value of the annotation. Value of __metrics_path__ will be the endpoint path that Prometheus will do requests.
- source_labels: [__meta_kubernetes_service_annotation_org_aerogear_metrics_ssl_endpoint]
regex: (.+)
target_label: __metrics_path__
- job_name: mcp-plain-services
scheme: http
kubernetes_sd_configs:
- role: service
namespaces:
names:
- {{ namespace }}
relabel_configs:
- action: keep
regex: \/.*
source_labels:
- __meta_kubernetes_service_annotation_org_aerogear_metrics_plain_endpoint
- source_labels:
- __address__
target_label: __param_target
- source_labels:
- __param_target
target_label: instance
- action: labelmap
regex: __meta_kubernetes_service_label_(.+)
- source_labels:
- __meta_kubernetes_namespace
target_label: kubernetes_namespace
- source_labels:
- __meta_kubernetes_service_name
target_label: kubernetes_name
- source_labels: [__meta_kubernetes_service_annotation_org_aerogear_metrics_plain_endpoint]
regex: (.+)
target_label: __metrics_path__
# auto discovery for pods as scrape targets
# set org.aerogear.metrics/plain_endpoint: /metrics as an annotation on the pod to make it targeted by Prometheus
# see https://github.com/prometheus/prometheus/blob/03a9e7f72e072c6d29f422425d8acd91a957836b/documentation/examples/prometheus-kubernetes.yml#L246
# unlike services, no SSL support for pods
- job_name: mcp-plain-pods
scheme: http
kubernetes_sd_configs:
- role: pod
namespaces:
names:
- {{ namespace }}
relabel_configs:
- action: keep
regex: (.+)
source_labels: [__meta_kubernetes_pod_annotation_org_aerogear_metrics_plain_endpoint]
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- source_labels: [__meta_kubernetes_namespace]
target_label: kubernetes_namespace
- source_labels: [__meta_kubernetes_pod_name]
action: replace
target_label: kubernetes_pod_name
- source_labels: [__meta_kubernetes_pod_annotation_org_aerogear_metrics_plain_endpoint]
regex: (.+)
target_label: __metrics_path__