Promtail scrap logs to scrape logs for one namespace

Hi Team,

I am using the below config to scrape ns from “nirmata” ns but looks like it is not working.
I want only “nirmata” as a ns in grafana, am I missing something in the promtail.yaml file:

client:
backoff_config:
max_period: 5s
max_retries: 20
min_period: 100ms
batchsize: 102400
batchwait: 1s
external_labels: {}
timeout: 10s
positions:
filename: /run/promtail/positions.yaml
server:
http_listen_port: 3101
target_config:
sync_period: 10s
scrape_configs:

  • job_name: kubernetes-pods-name
    pipeline_stages:

    • docker: {}

    kubernetes_sd_configs:

    • role: pod
      relabel_configs:
    • source_labels:
      • __meta_kubernetes_pod_label_name
        target_label: service
    • source_labels:
      • __meta_kubernetes_pod_node_name
        target_label: host
    • action: drop
      regex: ‘’
      source_labels:
      • service
    • action: labelmap
      regex: _meta_kubernetes_pod_label(.+)
    • action: replace
      replacement: $1
      separator: /
      source_labels:
      • __meta_kubernetes_namespace
      • service
        target_label: job
    • action: replace
      source_labels:
      • __meta_kubernetes_namespace
        target_label: namespace
    • action: keep
      regex: nirmata
      source_labels:
      • __meta_kubernetes_namespace
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_name
        target_label: pod
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_container_name
        target_label: container
    • 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
    pipeline_stages:

    • docker: {}

    kubernetes_sd_configs:

    • role: pod
      relabel_configs:
    • action: drop
      regex: .+
      source_labels:
      • __meta_kubernetes_pod_label_name
    • source_labels:
      • __meta_kubernetes_pod_label_app
        target_label: service
    • source_labels:
      • __meta_kubernetes_pod_node_name
        target_label: host
    • action: drop
      regex: ‘’
      source_labels:
      • service
    • action: labelmap
      regex: _meta_kubernetes_pod_label(.+)
    • action: replace
      replacement: $1
      separator: /
      source_labels:
      • __meta_kubernetes_namespace
      • service
        target_label: job
    • action: replace
      source_labels:
      • __meta_kubernetes_namespace
        target_label: namespace
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_name
        target_label: pod
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_container_name
        target_label: container
    • 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-direct-controllers
    pipeline_stages:

    • docker: {}

    kubernetes_sd_configs:

    • role: pod
      relabel_configs:
    • action: drop
      regex: .+
      separator: ‘’
      source_labels:
      • __meta_kubernetes_pod_label_name
      • __meta_kubernetes_pod_label_app
    • action: drop
      regex: ‘[0-9a-z-.]±[0-9a-f]{8,10}’
      source_labels:
      • __meta_kubernetes_pod_controller_name
    • source_labels:
      • __meta_kubernetes_pod_controller_name
        target_label: service
    • source_labels:
      • __meta_kubernetes_pod_node_name
        target_label: host
    • action: drop
      regex: ‘’
      source_labels:
      • service
    • action: labelmap
      regex: _meta_kubernetes_pod_label(.+)
    • action: replace
      replacement: $1
      separator: /
      source_labels:
      • __meta_kubernetes_namespace
      • service
        target_label: job
    • action: keep
      regex: nirmata
      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: pod
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_container_name
        target_label: container
    • 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-indirect-controller
    pipeline_stages:

    • docker: {}

    kubernetes_sd_configs:

    • role: pod
      relabel_configs:
    • action: drop
      regex: .+
      separator: ‘’
      source_labels:
      • __meta_kubernetes_pod_label_name
      • __meta_kubernetes_pod_label_app
    • action: keep
      regex: ‘[0-9a-z-.]±[0-9a-f]{8,10}’
      source_labels:
      • __meta_kubernetes_pod_controller_name
    • action: replace
      regex: ‘([0-9a-z-.]+)-[0-9a-f]{8,10}’
      source_labels:
      • __meta_kubernetes_pod_controller_name
        target_label: service
    • source_labels:
      • __meta_kubernetes_pod_node_name
        target_label: host
    • action: drop
      regex: ‘’
      source_labels:
      • service
    • action: labelmap
      regex: _meta_kubernetes_pod_label(.+)
    • action: replace
      replacement: $1
      separator: /
      source_labels:
      • __meta_kubernetes_namespace
      • service
        target_label: job
    • action: replace
      source_labels:
      • __meta_kubernetes_namespace
        target_label: namespace
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_name
        target_label: pod
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_container_name
        target_label: container
    • 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-static
    pipeline_stages:

    • docker: {}

    kubernetes_sd_configs:

    • role: pod
      relabel_configs:
    • action: drop
      regex: ‘’
      source_labels:
      • __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_label_component
        target_label: service
    • source_labels:
      • __meta_kubernetes_pod_node_name
        target_label: host
    • action: drop
      regex: ‘’
      source_labels:
      • service
    • action: labelmap
      regex: _meta_kubernetes_pod_label(.+)
    • action: replace
      replacement: $1
      separator: /
      source_labels:
      • __meta_kubernetes_namespace
      • service
        target_label: job
    • action: replace
      source_labels:
      • __meta_kubernetes_namespace
        target_label: namespace
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_name
        target_label: pod
    • action: replace
      source_labels:
      • __meta_kubernetes_pod_container_name
        target_label: container
    • replacement: /var/log/pods/$1/.log
      separator: /
      source_labels:
      • __meta_kubernetes_pod_annotation_kubernetes_io_config_mirror
      • __meta_kubernetes_pod_container_name
        target_label: path

It looks like you are missing the namespace matcher in some of the
job definitions, you would likely want it in all of them.