Files
FruitServer/promtail-config.yml

35 lines
1015 B
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Author: fruit.com.cn
# Promtail:通过 Docker 服务发现自动采集所有容器的 stdout/stderr 日志,推送到 Loki。
server:
http_listen_port: 9080
grpc_listen_port: 0
positions:
filename: /tmp/positions.yaml
clients:
- url: http://loki:3100/loki/api/v1/push
batchwait: 1s
batchsize: 1048576
scrape_configs:
- job_name: docker-containers
docker_sd_configs:
- host: unix:///var/run/docker.sock
refresh_interval: 5s
relabel_configs:
# 容器名(去掉开头的 /)
- source_labels: ['__meta_docker_container_name']
regex: '/(.*)'
target_label: container
# 日志流:stdout / stderr
- source_labels: ['__meta_docker_container_log_stream']
target_label: stream
# 容器 ID 前 12 位
- source_labels: ['__meta_docker_container_id']
target_label: container_id
regex: '(.{12}).*'
# 镜像名
- source_labels: ['__meta_docker_container_image']
target_label: image