# ============================================================================= # Promtail 配置文件 # ============================================================================= server: http_listen_port: 9080 grpc_listen_port: 0 positions: filename: /tmp/positions.yaml clients: - url: http://loki:3100/loki/api/v1/push scrape_configs: # --------------------------------------------------------------------------- # Sub2API 应用日志 # --------------------------------------------------------------------------- - job_name: sub2api static_configs: - targets: - localhost labels: job: sub2api service: sub2api __path__: /var/log/sub2api/*.log pipeline_stages: - json: expressions: level: level component: component trace_id: trace_id request_id: request_id - labels: level: component: # --------------------------------------------------------------------------- # Docker 容器日志 # --------------------------------------------------------------------------- - job_name: docker static_configs: - targets: - localhost labels: job: docker __path__: /var/lib/docker/containers/*/*.log pipeline_stages: - json: expressions: output: log stream: stream attrs: - json: source: attrs expressions: tag: - regex: source: tag expression: (?P(?:[^|])*[^|]) - timestamp: source: time format: RFC3339Nano - labels: stream: container_name: - output: source: output # --------------------------------------------------------------------------- # 系统日志 # --------------------------------------------------------------------------- - job_name: syslog static_configs: - targets: - localhost labels: job: syslog __path__: /var/log/syslog # --------------------------------------------------------------------------- # Nginx 访问日志 (如果有) # --------------------------------------------------------------------------- - job_name: nginx static_configs: - targets: - localhost labels: job: nginx __path__: /var/log/nginx/access.log pipeline_stages: - regex: expression: '^(?P\S+) - (?P\S+) \[(?P[^\]]+)\] "(?P[^"]+)" (?P\d+) (?P\d+) "(?P[^"]+)" "(?P[^"]+)"' - labels: status: - timestamp: source: time_local format: 02/Jan/2006:15:04:05 -0700