|
134 | 134 | replacement: '$1',
|
135 | 135 | },
|
136 | 136 |
|
137 |
| - // But also include the namespace as a separate label, for routing alerts |
| 137 | + // But also include the namespace, container, pod as separate labels, |
| 138 | + // for routing alerts and joining with cAdvisor metrics. |
138 | 139 | {
|
139 | 140 | source_labels: ['__meta_kubernetes_namespace'],
|
140 | 141 | action: 'replace',
|
141 | 142 | target_label: 'namespace',
|
142 | 143 | },
|
| 144 | + { |
| 145 | + source_labels: ['__meta_kubernetes_pod_name'], |
| 146 | + action: 'replace', |
| 147 | + target_label: 'pod', // Not 'pod_name', which disappeared in K8s 1.16. |
| 148 | + }, |
| 149 | + { |
| 150 | + source_labels: ['__meta_kubernetes_container_name'], |
| 151 | + action: 'replace', |
| 152 | + target_label: 'container', // Not 'container_name', which disappeared in K8s 1.16. |
| 153 | + }, |
143 | 154 |
|
144 | 155 | // Rename instances to the concatenation of pod:container:port.
|
145 | 156 | // All three components are needed to guarantee a unique instance label.
|
|
169 | 180 | ],
|
170 | 181 | },
|
171 | 182 |
|
172 |
| - // A separate scrape config for kube-state-metrics which doesn't add a namespace |
173 |
| - // label, instead taking the namespace label from the exported timeseries. This |
174 |
| - // prevents the exported namespace label being renamed to exported_namespace, and |
175 |
| - // allows us to route alerts based on namespace. |
| 183 | + // A separate scrape config for kube-state-metrics which doesn't |
| 184 | + // add namespace, container, and pod labels, instead taking |
| 185 | + // those labels from the exported timeseries. This prevents them |
| 186 | + // being renamed to exported_namespace etc. and allows us to |
| 187 | + // route alerts based on namespace and join KSM metrics with |
| 188 | + // cAdvisor metrics. |
176 | 189 | {
|
177 | 190 | job_name: '%s/kube-state-metrics' % $._config.namespace,
|
178 | 191 | kubernetes_sd_configs: [{
|
|
0 commit comments