Closed
Description
I am running Loki with promtail in kubernetes platform.
Promtail running as a daemonset and promtail configuration as follows ..
scrape_configs:
- job_name: kubernetes-pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: ^$
source_labels:
- __meta_kubernetes_pod_label_name
- action: replace
replacement: $1
separator: /
source_labels:
- __meta_kubernetes_namespace
- __meta_kubernetes_pod_label_name
target_label: job
- action: drop
regex: default
source_labels:
- __meta_kubernetes_namespace
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: instance
- action: replace
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:
- __meta_kubernetes_pod_uid
- __meta_kubernetes_pod_container_name
target_label: __path__
- job_name: kubernetes-pods-app
kubernetes_sd_configs:
- role: pod
relabel_configs:
- source_labels:
- __meta_kubernetes_pod_node_name
target_label: __host__
- action: drop
regex: .+
source_labels:
- __meta_kubernetes_pod_label_name
- action: replace
replacement: $1
separator: /
source_labels:
- __meta_kubernetes_namespace
- __meta_kubernetes_pod_label_app
target_label: job
- action: drop
regex: default
source_labels:
- __meta_kubernetes_namespace
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: instance
- action: replace
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:
- __meta_kubernetes_pod_uid
- __meta_kubernetes_pod_container_name
target_label: __path__
I have a two question?
Q1# How can I capture kubernetes host log (/var/log/messages) along with hostname and what will be config file definition?
I checked with https://github.com/grafana/loki/blob/master/docs/promtail-examples.md
But looks like its for static configuration.
scrape_configs:
- job_name: system
pipeline_stages:
- docker:
static_configs:
- targets:
- localhost
labels:
job: varlogs
host: yourhost
__path__: /var/log/*.log
Q2# How can I DROP all logs from particular namespace (default)
I tried with following but no luck, not sure if I missing anything ...
I added below text in job "kubernetes-pods" & "kubernetes-pods-app"
- action: drop
regex: default
source_labels:
- __meta_kubernetes_namespace