我有以下嵌套 JSON 中的日志
{"level":30,"time":1627625600625,"pid":15676,"hostname":"admin-hp-elitebook-840-g2","reqId":"req-2","req":{"method":"POST","url":"/v1/login","hostname":"127.0.0.1:3000","remoteAddress":"127.0.0.1","remotePort":55884},"msg":"incoming request"}
从那开始,我想为方法、URL、主机创建标签,我在 promtail 中尝试过如下 JSON 表达式。我尝试解析 JSON,我能够提取 req,但我不知道如何解析在promtail中嵌套一个
scrape_configs:
- job_name: plainlog
pipeline_stages:
- json:
expressions:
req: req
- labels:
req:
- output:
source: req
static_configs:
- targets:
- localhost
labels:
job: plainlog
__path__: /home/nidhin/Desktop/plainlog/*log