Promtail scrape JSON log file

I am trying to get promtail to ingest the following line and send it to my Loki instance for ingest. I get errors starting the job referencing the job name. However I’m not entirely sure I have the syntax right in the configuration file.I haven’t been able to locate much through search for the specifics I’m trying to accomplish. Would appreciate any assistance.

Sample data

{“T”:“2022-07-03T17:56:04.272393285+01:00”,“QH”:“fonts.googleapis.com”,“QT”:“A”,“QC”:“IN”,“CP”:“”,“Answer”:“XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX”,“Result”:{},“Upstream”:“tls://dns.quad9.net:853”,“IP”:“XXX.XXX.XXX.XXX”,“Elapsed”:178015,“Cached”:true}

promtail yaml file (IP Masked)

> server:
http_listen_port: 9080
grpc_listen_port: 0
log_level: "info"
positions:
filename: /data/positions.yaml
client:
url: http://X.X.X.X/loki/api/v1/push
backoff_config:
minbackoff: 500ms
maxbackoff: 1m
maxretries: 99999999
scrape_configs:
        - job_name: adguard
        pipline_stages:
                -json:
                        expressions:
                                timestamp: T
                                domain: QH
                                method: QT
                                answer: Answer
                                upstream: Upstream
                                src: IP
                        elapsed: Elapsed
                        cached: Cached
                -labels:
                        domain:
                        method:
                        answer:
                        upstream:
                        src:
                -timestamp
                        source: timestamp
                -output:
                        source:output
static_configs:
        -targets:
                - localhost
                labels:
                        job: adguard
                        __path__: /opt/AdGuardHome/data/querylog.json

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