Hi,
I’m a bit new to Loki and i need some help. I want to ship only a specific k8s namespace (kube-system) to Loki using Pormtail.
I’m trying to limit the Promtail to this namespace using regex. However, i still see other namespaces in the logs. What could be the issue?
---
config:
positions:
filename: /run/promtail/positions.yaml
clients:
- url: http://loki-gateway/loki/api/v1/push
tenant_id: 1
snippets:
extraScrapeConfigs: |
- job_name: kubernetes-pods-kube-system
kubernetes_sd_configs:
- role: pod
pipeline_stages:
- docker: {}
- cri: {}
- json:
expressions:
message: message
relabel_configs:
# Select only pods from the kube-system namespace
- action: keep
source_labels: [__meta_kubernetes_namespace]
regex: kube-system
# Ensure that only container logs are scraped from the correct log path
- source_labels: [__meta_kubernetes_pod_container_name]
target_label: __path__
replacement: /var/log/pods/*/*/*.log