Cannot narrow down log scraping to a certain podlabel

This page summarizes the projects mentioned and recommended in the original post on /r/grafana

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • loki

    Like Prometheus, but for logs.

  • # -- Section for crafting Promtails config file. The only directly relevant value is `config.file` # which is a templated string that references the other values and snippets below this key. # @default -- See `values.yaml` config: # -- The log level of the Promtail server # Must be reference in `config.file` to configure `server.log_level` # See default config in `values.yaml` logLevel: info # -- The port of the Promtail server # Must be reference in `config.file` to configure `server.http_listen_port` # See default config in `values.yaml` serverPort: 3101 # -- The config of clients of the Promtail server # Must be reference in `config.file` to configure `clients` # @default -- See `values.yaml` clients: - url: http://loki:3100/loki/api/v1/push # -- A section of reusable snippets that can be reference in `config.file`. # Custom snippets may be added in order to reduce redundancy. # This is especially helpful when multiple `kubernetes_sd_configs` are use which usually have large parts in common. # @default -- See `values.yaml` snippets: pipelineStages: - match: selector: '{__meta_kubernetes_pod_label_monitoring="true"}' action: keep - cri: {} common: - action: replace source_labels: - __meta_kubernetes_pod_node_name target_label: node_name - action: replace source_labels: - __meta_kubernetes_namespace target_label: namespace - action: replace replacement: $1 separator: / source_labels: - namespace - app target_label: job - action: replace source_labels: - __meta_kubernetes_pod_name target_label: pod - action: replace source_labels: - __meta_kubernetes_pod_container_name target_label: container - action: replace replacement: /var/log/pods/*$1/*.log separator: / source_labels: - __meta_kubernetes_pod_uid - __meta_kubernetes_pod_container_name target_label: __path__ - action: replace replacement: /var/log/pods/*$1/*.log regex: true/(.*) separator: / source_labels: - __meta_kubernetes_pod_annotationpresent_kubernetes_io_config_hash - __meta_kubernetes_pod_annotation_kubernetes_io_config_hash - __meta_kubernetes_pod_container_name target_label: __path__ # If set to true, adds an additional label for the scrape job. # This helps debug the Promtail config. addScrapeJobLabel: false # -- You can put here any keys that will be directly added to the config file's 'limits_config' block. # @default -- empty extraLimitsConfig: "" # -- You can put here any keys that will be directly added to the config file's 'server' block. # @default -- empty extraServerConfigs: "" # -- You can put here any additional scrape configs you want to add to the config file. # @default -- empty extraScrapeConfigs: "" # -- You can put here any additional relabel_configs to "kubernetes-pods" job extraRelabelConfigs: [] scrapeConfigs: | # See also https://github.com/grafana/loki/blob/master/production/ksonnet/promtail/scrape_config.libsonnet for reference - job_name: kubernetes-pods pipeline_stages: {{- toYaml .Values.config.snippets.pipelineStages | nindent 4 }} kubernetes_sd_configs: - role: pod relabel_configs: - source_labels: - __meta_kubernetes_pod_controller_name regex: ([0-9a-z-.]+?)(-[0-9a-f]{8,10})? action: replace target_label: __tmp_controller_name - source_labels: - __meta_kubernetes_pod_label_app_kubernetes_io_name - __meta_kubernetes_pod_label_app - __tmp_controller_name - __meta_kubernetes_pod_name regex: ^;*([^;]+)(;.*)?$ action: replace target_label: app - source_labels: - __meta_kubernetes_pod_label_monitoring action: replace target_label: monitoring - source_labels: - __meta_kubernetes_pod_label_app_kubernetes_io_instance - __meta_kubernetes_pod_label_release regex: ^;*([^;]+)(;.*)?$ action: replace target_label: instance - source_labels: - __meta_kubernetes_pod_label_app_kubernetes_io_component - __meta_kubernetes_pod_label_component regex: ^;*([^;]+)(;.*)?$ action: replace target_label: component {{- if .Values.config.snippets.addScrapeJobLabel }} - replacement: kubernetes-pods target_label: scrape_job {{- end }} {{- toYaml .Values.config.snippets.common | nindent 4 }} {{- with .Values.config.snippets.extraRelabelConfigs }} {{- toYaml . | nindent 4 }} {{- end }}

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts