We used to loki log plugin but we decided turn on to promtail because plugin demands from loki to have ports bind to a host.
How with promtail get labels: host, stack & service like loki log plugin do?
Here is my promtail’s config
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
client:
url: http://loki:3100/loki/api/v1/push
scrape_configs:
- job_name: containers
static_configs:
- targets:
- localhost
labels:
job: containerlogs
path: /var/lib/docker/containers/*/*log
pipeline_stages:
- json:
expressions:
stream: stream
attrs: attrs
tag: attrs.tag
- regex:
expression: ^(?P<image_name>([^|]+))\|(?P<container_name>([^|]+))$
source: 'tag'
- labels:
image_name:
container_name:
- match:
selector: '{container_name="",image_name=""}'
action: drop
- match:
selector: '{container_name=~"^stack_proxy.*"}'
stages:
- json:
expressions:
log: log
- labeldrop:
- filename
- output:
source: log