Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
274 views
in Technique[技术] by (71.8m points)

linux - Configure promtail 2.0 to read the files .log

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,

question from:https://stackoverflow.com/questions/65849600/configure-promtail-2-0-to-read-the-files-log

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try replace:

path: /opt/error.log

To:

__path__: /opt/error.log

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...