How remove kv from json log when move kv to labels by promtail?

Hello! Thanks for Grafana Loki and Promtail.
I try move kv from json log to labels by promtail
I have json log from mingrammer/flog

{
   "host":"122.26.132.161",
   "user-identifier":"daugherty5530",
   "datetime":"29/Nov/2022:08:13:38 +0000",
   "method":"PATCH",
   "request":"/reintermediate/e-services",
   "protocol":"HTTP/1.0",
   "status":500,
   "bytes":25902,
   "referer":"http://www.centralmonetize.com/mission-critical"
}
{
   "host":"173.49.110.104",
   "user-identifier":"fisher5806",
   "datetime":"29/Nov/2022:08:13:38 +0000",
   "method":"PATCH",
   "request":"/open-source/niches",
   "protocol":"HTTP/1.0",
   "status":500,
   "bytes":15315,
   "referer":"http://www.productsyndicate.org/orchestrate"
}

I have promtail config in k8s

config:
  clients:
    - url: http://loki-loki-distributed-gateway.loki/loki/api/v1/push
  snippets:
    pipelineStages:
      - cri: {}
      - labeldrop:
          - filename
          - pod
      - json:
          expressions:
            method: method
            protocol: protocol
      - labels:
          method:
          protocol:
      - output:
          source: output

I have kv in json log and labels:

Log labels:
.......
method  PATCH
.......
protocol  HTTP/1.0
......

Detected field:
......
method  "PATCH"
protocol  "HTTP/1.0"
......

How remove kv from json log when move kv to labels by promtail?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.