I have a some of docker containers with names:
project1-api
project1-crons
project2-api
project2-crons
etc…
And I need to have a label like “project1”, “project2” to filter in in Grafana Loki So I think to parse log in promtail with some regexp to add label “project1”, “project2” etc, but cann’t to have a correct config of Promtail Maybe there are other way to solve my problem, so you are welcome…
Try to config pipeline_stage for docker job but without success My config work for now is:
pipeline_stages:
- json:
expressions:
level: level
relabel_configs:
- source_labels: ['__meta_docker_container_name']
regex: '/(.*)'
target_label: 'container'
And I need to have a label like “project1”, “project2” to filter in in Grafana Loki
Note that the discovery will not pick up finished containers. That means Promtail will not scrape the remaining logs from finished containers after a restart.