Promtail does not push log to loki after log rotate (Docker)

Dear Community,

I have several services’ logs that i would like to send to loki using Promtail. The logs will have rotate every day at 12am to rename for exp: a.log will be rename to a-<>.log and then a new a.log will be created and push today log. I realised the promtail stopped pushing logs after the rotation and i been researching online talk about using * in the path instead. But after i applied the configuration, the problem still presists. After i manually restart the container, the logs pushed again.

Hope i can get the solution here. The following is the example of the configuration:

server:
http_listen_port: 9080
grpc_listen_port: 0

positions:
filename: /tmp/positions.yaml

clients:

scrape_configs:

  • job_name: jobname

    static_configs:

    • targets:
      • localhost
        labels:
        job: jobname
        server_name: servername
        agent: promtail
        path: /path/to/logs/*.log

I’ve never had this problem before. Promtail does look for filesystem changes. Try changing your logrotation configuration so that filename does NOT end with .log after rotation.

Hi tony,

Thanks for the reply. i managed to solve the issues by mount the whole folder inside for example the log i want to tail is /home/service1/logs/a.log. I mount the whole folder into the container /home/service1/logs/: /home/service1/logs/ and then the path in the config.yaml of promtail will be /home/service1/logs/a.log. I had been monitored for 4 consecutive days, it does not stopped pushing the logs after log rotate.