Ad Widget

Collapse

Read logs from Docker container

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • passcode
    Junior Member
    • Oct 2021
    • 4

    #1

    Read logs from Docker container

    Hello everyone!

    I have installed Zabbix agent 2 in a Docker container. I would like to read and analyze the logs of other containers.
    I created a host on the Zabbix server, added the "Docker by Zabbix agent 2" template. Next, I created an item:

    Type: Zabbix agent (active)
    Key: log[/var/lib/docker/containers/<container-id>/<container-id>-json.log]
    Type: Log

    I can read this file locally: cat /var/lib/docker/containers/<container-id>/<container-id>-json.log
    But on Zabbiks server displays the status "Not supported" and Info "Cannot obtain information for file "/var/lib/docker/containers/<container-id>/<container-id>-json.log": [2] No such file or directory".
    If this worked, then I would have to change the <container-id> in the item when re-creating the container.

    How can I set up log collection from containers, even if they are recreated?
  • passcode
    Junior Member
    • Oct 2021
    • 4

    #2
    I added the "/var/lib/docker" directory to the Zabbiks agent container. Now I can read the logs using the item key: [/var/lib/docker/containers/<container-id>/<container-id>-json.log]. Is this good practice?
    Can I use the name of the container instead of its ID in the item key?

    Comment

    Working...