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
Try replace:
To:
It seems that you only specified:
which will only add a label to scraped log entries.
You forgot to specify:
which will tell Promtail where to find those logs to tail.
==========================================================
Here is my working Promtail 2.1 journal scraping config.