Excluding certain Docker containers from Promtail log scraping

Hi there,

I have set up Loki with Promtail to ingest logs from Docker containers deployed across various hosts. Some containers have their logging driver set to “none”, which causes Promtail to periodically emit an error message:

level=error ts=2023-08-27T17:31:56.766242135Z caller=target.go:106 target=docker/35aa28881d155f86526e029fed06a0a607831d2687eb443050460d37ec1955fb msg="could not fetch logs for container" container=35aa28881d155f86526e029fed06a0a607831d2687eb443050460d37ec1955fb err="Error response from daemon: configured logging driver does not support reading"

Is there a way to exclude these containers from scraping?

Thanks,
Thilo

Edit:

My Scrape config looks like this:

  scrape_configs:
    - job_name: docker
      docker_sd_configs:
        - host: unix:///var/run/docker.sock
          refresh_interval: 5s
      relabel_configs:
        - source_labels: ['__meta_docker_container_name']
          regex: '/(.*)'
          target_label: 'container'
        - source_labels: ['__meta_docker_container_log_stream']
          target_label: 'logstream'
        - source_labels: ['__meta_docker_container_label_logging_jobname']
          target_label: 'job'
1 Like

Did you find solution?

Somebody find solution?