Skip to content

Commit

Permalink
Reorder relabeling rules to prevent pod label from overwriting config…
Browse files Browse the repository at this point in the history
… defined labels
  • Loading branch information
slim-bean authored and Ed committed Aug 6, 2019
1 parent b5d8c77 commit 07f9584
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion production/helm/loki-stack/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: loki-stack
version: 0.14.0
version: 0.15.0
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Loki: like Prometheus, but for logs."
Expand Down
2 changes: 1 addition & 1 deletion production/helm/promtail/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: promtail
version: 0.10.0
version: 0.11.0
appVersion: 0.0.1
kubeVersion: "^1.10.0-0"
description: "Responsible for gathering logs and sending them to Loki"
Expand Down
20 changes: 10 additions & 10 deletions production/helm/promtail/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ data:
regex: ^$
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
Expand All @@ -50,8 +52,6 @@ data:
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container_name
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
Expand All @@ -78,6 +78,8 @@ data:
regex: ^$
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
Expand All @@ -97,8 +99,6 @@ data:
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container_name
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
Expand Down Expand Up @@ -131,6 +131,8 @@ data:
regex: ^$
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
Expand All @@ -150,8 +152,6 @@ data:
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container_name
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
Expand Down Expand Up @@ -186,6 +186,8 @@ data:
regex: ^$
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
Expand All @@ -205,8 +207,6 @@ data:
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container_name
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
Expand Down Expand Up @@ -234,6 +234,8 @@ data:
regex: ^$
source_labels:
- __service__
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- action: replace
replacement: $1
separator: /
Expand All @@ -253,8 +255,6 @@ data:
source_labels:
- __meta_kubernetes_pod_container_name
target_label: container_name
- action: labelmap
regex: __meta_kubernetes_pod_label_(.+)
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
Expand Down
14 changes: 8 additions & 6 deletions production/ksonnet/promtail/scrape_config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ config + {
regex: '^$',
},

// Include all the other labels on the pod.
// Perform this mapping before applying additional label replacement rules
// to prevent a supplied label from overwriting any of the following labels.
{
action: 'labelmap',
regex: '__meta_kubernetes_pod_label_(.+)',
},

// Rename jobs to be <namespace>/<name, from pod name label>
{
source_labels: ['__meta_kubernetes_namespace', '__service__'],
Expand Down Expand Up @@ -53,12 +61,6 @@ config + {
target_label: 'container_name',
},

// Also include all the other labels on the pod.
{
action: 'labelmap',
regex: '__meta_kubernetes_pod_label_(.+)',
},

// Kubernetes puts logs under subdirectories keyed pod UID and container_name.
{
source_labels: [pod_uid, '__meta_kubernetes_pod_container_name'],
Expand Down

0 comments on commit 07f9584

Please sign in to comment.