我想使用 Promtail > Loki > Grafana。我的日志文件如下所示:
{"asctime": "2006-01-02T15:04:05.999999999-07:00", "levelname": "INFO", "module": "blocking_connection", "funcName": "__init__", "lineno": 1246, "message": "Created channel=1"}
{"asctime": "2006-01-02T15:04:06.999999999-07:00", "levelname": "INFO", "module": "publisher", "funcName": "info", "lineno": 18, "message": "Connect to channel"}
{"asctime": "2006-01-02T15:04:07.999999999-07:00", "levelname": "INFO", "module": "publisher", "funcName": "info", "lineno": 18, "message": "Send to"}
我的 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:
- job_name: system
pipeline_stages:
- json:
expressions:
messange: message
timestamp: asctime
funcName: funcName
- timestamp:
source: timestamp
format: RFC3339Nano
static_configs:
- targets:
- localhost
labels:
job: varlogs
__path__: /home/my_name/*log
我试图阅读系统日志,一切正常,但没有 json。