1

I am having an issue with getting promtail to read and log file and extract the infomation i need to send to loki

The log line in the file looks like this

2022-11-16T16:55:35.738757+00:00 hostname-13 tracker[15857] {'arg': 'test.py', 'show': None, 'envname': None, 'ostype': 'Linux', 'hostname': 'hostname-13', 'username': 'foo', 'site': 'UK', 'app': 'test', 'ver': '2.9'}

And my promtail config scrape config looks like

scrape_configs:
  - job_name: tracker
    static_configs:
      - targets:
          - localhost


    labels:
      job: tracker
      __path__: /var/log/apptrack.log
pipeline_stages:
    - match:
        selector: '{job="tracker"}'
        stages:
        - regex:
            expression: "(?P<msg>{(.*?)})"
    - json:
        expressions:
          args: argv
          show: show
          envname: envname
          ostype: ostype
          hostname: hostname
          username: username
          site: site
          app: app
          ver: ver

but in Grafana/loki im still getting all the log line 
[enter image description here](https://i.stack.imgur.com/BTFwF.png)


Any suggestions 

Thanks


0 Answers0