skip to Main Content

Since I’ve updated to promtail 2.0, I’m unable to read the content of a log file in loki.

config-promtail.yml

server:
  http_listen_port: 9080
  grpc_listen_port: 0

positions:
  filename: /tmp/positions.yaml

clients:
  - url: http://192.168.1.103:3100/loki/api/v1/push

scrape_configs:
  - job_name: manuallog
    static_configs:
      - targets:
          - 192.168.1.103
        labels:
          job: tomcat
          host: 192.168.1.103
          path: /opt/error.log

I’ve also tried to use a different configuration in the scrape config, but with no luck:

  - job_name: varlog
journal:
  max_age: 12h
  labels:
    filename: /opt/error.log
    path: /opt/error.log

The error.log is not empty:

    # cat /opt/error.log
Disconnected from localhost

The Promtail version – 2.0

    ./promtail-linux-amd64 --version
promtail, version 2.0.0 (branch: HEAD, revision: 6978ee5d)
  build user:       root@2645337e4e98
  build date:       2020-10-26T15:54:56Z
  go version:       go1.14.2
  platform:         linux/amd64

Any clue? Am I doing anything wrong?

Many thanks,

2

Answers


  1. Try replace:

    path: /opt/error.log
    

    To:

    __path__: /opt/error.log
    
    Login or Signup to reply.
  2. It seems that you only specified:

    journal.lables.path: /opt/error.log
    

    which will only add a label to scraped log entries.

    You forgot to specify:

    journal.path: /opt/error.log
    

    which will tell Promtail where to find those logs to tail.

    ==========================================================

    Here is my working Promtail 2.1 journal scraping config.

        scrape_configs:
          - job_name: journal
            pipeline_stages:
              - drop:
                  expression: ".*something-redudant.*"
            journal:
              path: /var/log/journal
              max_age: 12h
              labels:
                job: systemd-journal
            relabel_configs:
              - source_labels: ['__journal__systemd_unit']
                target_label: 'unit'
              - source_labels: ['__journal__hostname']
                target_label: 'hostname'
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search