This commit is contained in:
61
deployments/observability/config/promtail.yaml
Normal file
61
deployments/observability/config/promtail.yaml
Normal file
@@ -0,0 +1,61 @@
|
||||
server:
|
||||
http_listen_port: 9080
|
||||
grpc_listen_port: 0
|
||||
|
||||
positions:
|
||||
filename: /tmp/positions.yaml
|
||||
|
||||
clients:
|
||||
- url: ${LOKI_URL}
|
||||
bearer_token: ${OBS_AUTH_TOKEN}
|
||||
|
||||
scrape_configs:
|
||||
# ============================================
|
||||
# chat-deploy 业务层日志采集
|
||||
# ============================================
|
||||
- job_name: chat-deploy-logs
|
||||
static_configs:
|
||||
- targets:
|
||||
- localhost
|
||||
labels:
|
||||
job: chat-deploy-logs
|
||||
project: ${OBS_PROJECT}
|
||||
service: ${OBS_SERVICE}
|
||||
log_layer: business
|
||||
__path__: /var/lib/docker/containers/*/*-json.log
|
||||
|
||||
pipeline_stages:
|
||||
# 解析 Docker JSON 日志格式
|
||||
- docker: {}
|
||||
|
||||
# 从文件路径提取容器 ID
|
||||
- regex:
|
||||
source: filename
|
||||
expression: '/var/lib/docker/containers/(?P<container_id>[0-9a-f]{12})[0-9a-f]*/'
|
||||
- labels:
|
||||
container_id:
|
||||
|
||||
# ============================================
|
||||
# 过滤规则:只丢弃基础设施层日志
|
||||
# 保留 chat-deploy 业务层日志(包括Go服务的caller日志)
|
||||
# ============================================
|
||||
|
||||
# 1. 丢弃 promtail/prometheus/grafana 等基础设施组件的内部日志
|
||||
- drop:
|
||||
expression: 'caller=.*(promtail|prometheus|grafana|loki|exporter).*\.go:[0-9]+'
|
||||
drop_counter_reason: infra_go_internal_log
|
||||
|
||||
# 2. 丢弃基础设施组件日志(prometheus/grafana/exporter等)
|
||||
- drop:
|
||||
expression: '(component=|target=|scrape_pool=|instance=.*exporter)'
|
||||
drop_counter_reason: infrastructure_component
|
||||
|
||||
# 3. 丢弃 Docker 服务发现和 API 错误日志
|
||||
- drop:
|
||||
expression: '(docker_discovery|Unable to refresh target groups|client version.*is too old|Minimum supported API version)'
|
||||
drop_counter_reason: docker_api_error
|
||||
|
||||
# 4. 丢弃文件监控事件日志(promtail 内部)
|
||||
- drop:
|
||||
expression: '(file watcher event|filetargetmanager|fsnotify)'
|
||||
drop_counter_reason: file_watcher
|
||||
Reference in New Issue
Block a user