Hi,
I want to log my caddy instance with promtail.
I was able to log all containers with this approach:
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: instance
pipeline_stages:
- docker: {}
But I was not able to scrape only one specific docker container with the instance name “caddy_caddy_1” in my case.
Where and how should I do this?
Do you see any log from the container when you do docker logs
?
Yes, I can see the logs of all container with my approach.
So what I want to do is, only to focus on one container with the name caddy_caddy_1 instead of logging all instances
I see. You can use drop
(drop | Grafana Loki documentation), and drop all logs that don’t match the container name.
This is not really working for me because we change our setup from time to time.
Why is the opposite way not possible? I would like to filter just for the containers which I am interested in?
Is my approach maybe completely wrong?
I guess this is a common task to obsorve logs from docker container nowadays.