Hi, i am trying to gather logs within my K8s cluster using Grafana+Promtail+Loki.
By default Promtail gathers logs from all namespaces. I want to specify f.e. two specific namespaces.
Can someone explain how to rewrite scrape config file? I have tried to exclude and include namespaces using ‘drop’ and ‘keep’.
scrape_configs:
- job_name: kubernetes-pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
action: keep
regex: kube-system
# [...]
- job_name: kubernetes-pods-app
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
action: keep
regex: kube-system
scrape_configs:
- job_name: kubernetes-pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
action: drop
regex: kube-system
# [...]
- job_name: kubernetes-pods-app
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels: [__meta_kubernetes_namespace]
action: drop
regex: kube-system