Promtail example-static-config

When using tihs example to collect logs, this configuration doesn’t work (Configure Promtail | Grafana Loki documentation)

scrape_configs:
 - job_name: system
   pipeline_stages:
   static_configs:
   - targets:
      - localhost
     labels:
      job: varlogs  # A `job` label is fairly standard in prometheus and useful for linking metrics and logs.
      host: yourhost # A `host` label will help identify logs from this machine vs others
      __path__: /var/log/*.log  

I use extraScrapeConfigs to collect the log successfully

What is the difference between the two configurations?

I also needed to define extraVolumes to use extraScrapeConfigs.

Example:

extraVolumes:

  • name: node-logs
    hostPath:
    path: /var/log

extraVolumeMounts:

  • name: node-logs
    mountPath: /var/log
    readOnly: true

Set fsGroup to allow syslog file reading

podSecurityContext:
fsGroup: 4

Allow environment variables usage

extraArgs:

  • -config.expand-env=true

Scrape config to read syslog file from node

ls -1 /var/log/{,/}{[._]log,{mail,news}.{err,info,warn}}

var/log all files => path: /var/log/{,*/}

config:
snippets:
extraScrapeConfigs: |
# Add an additional scrape config for syslog
- job_name: node-all
static_configs:
- targets:
- localhost
labels:
job: node/node-all
path: /var/log/syslog
node_name: ‘onap-grafana-loki’