Hi,
I’m trying desperately to get kubernetes pod logs to extract labels from the detected fields. I’ve tried a staggering amount of things, read all the docs, yet … I’m stuck.
Here’s the setup:
- Everything running in a local k8s cluster
- Grafana is fine and I can see my logs properly
- Promtail is running and is getting logs properly to Loki for all containers running in the cluster
What I’m trying to achieve:
Given the following log (for example): { "breed" : "german shorthaired pointer", "name" : "Jax", "good_boy" : true }
I want to get the good_boy detected field into the labels. At present, no matter what I do, the good_boy
field remains as a “Detected Field” in Grafana and is never available as a label.
Here’s what my configuration looks like:
- pipeline_stages:
- docker:
- labels:
good_boy:
job_name: kubernetes-pods-name
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: replace
replacement: $1
separator: /
source_labels:
- __meta_kubernetes_namespace
- __service__
target_label: k8s_app
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
- __meta_kubernetes_pod_uid
- __meta_kubernetes_pod_container_name
target_label: __path__
- replacement: /var/log/pods/*$1/*.log
separator: /
source_labels:
- __meta_kubernetes_pod_uid
- __meta_kubernetes_pod_container_name
target_label: __path__
Thanks for any insights!