Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorder relabeling rules to prevent pod label from overwriting config define labels #857

Merged
merged 1 commit into from
Aug 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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