Promtail: combine several files in one label

230 views Asked by At

On my instance (nginx reverse-proxy) I have several log files, two for each site. For example:

$ ls /var/logs/nginx
site-1.access.log
site-1.error.log
site-2.access.log
site-2.error.log
site-3.access.log           
site-3.error.log

For now, I'm able to scrape all logs with the following Promtail config:

- job_name: reverseproxy-log
  static_configs:
    - labels:
        __path__: /var/log/nginx/*.log
      targets:
        - localhost

This works very well, but the "problem" is that in Grafana/Loki, I can filter only with the filename, for example with the query

{filename="/var/log/nginx/site-1.access.log"}

I would like to be able to filter first by site, for example, the query {site="site-1"} gives me all logs access and error from site-1, and then have the possibility to filter more specifically access or error logs.

Could you help me to find the correct Promtail config for this? Thanks

0

There are 0 answers