Ad Widget

Collapse

Monitor Docker with Zabbix

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jordanelis
    Junior Member
    • Oct 2023
    • 2

    #1

    Monitor Docker with Zabbix

    Hello everyone.

    I am new to Ubuntu, Zabbix and programming and want to prepare the ui for existing servers and a docker in one of the servers.
    I need help to connect my Docker to the Zabbix ui.

    I have done the following steps.

    In UbuntuServer1 (Us1), I installed Zabbix Server.
    In UbuntuServer2 (Us2), I installed Zabbix agent.
    I added a Host to Zabbix ui and I can monitor my Us2 server. It works fine.

    In Us2 I installed Docker, I added 2 containers, with nginx image, named nginx1 and nginx2.

    I went to Hosts, added a new host with the server ip of the Us2, Template: Docker by Zabbix agent 2.

    It didn't work​. In the latest data of this host in the info tab i get this message: Unsupported item key.

    After searching I saw that I have to install Zabbix Agent 2 to my Us2. I did it and both agents are running, but I had to change the port for Zabbix Agent 2 to 10051 because the default port 10050 was used by Zabbix Agent 1.
    I added the Host again but with 10051 port and in the latest data, in the info tab i get this message:

    "Cannot fetch data: Get "http://1.28/info": dial unix /var/run/docker.sock: connect: permission denied."

    I run both servers with the "root" user.


  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    You don't need to run 2 agents. Just remove classic agent and use agent2 instead. Plus using ports that a usually for proxy/server (10051) just creates confusion... better use something like 11050, which is clearly not a default port for something..
    Based on what I see here https://www.zabbix.com/integrations/docker You do not need to add separate hosts for each container and point them to your Us2 agent. You can push this template to Us2 and it should discover all those docker things. There is a note about Setup, you should follow on that server... Access to socket..​

    Comment

    • Jordanelis
      Junior Member
      • Oct 2023
      • 2

      #3
      Originally posted by cyber
      You don't need to run 2 agents. Just remove classic agent and use agent2 instead. Plus using ports that a usually for proxy/server (10051) just creates confusion... better use something like 11050, which is clearly not a default port for something..
      Based on what I see here https://www.zabbix.com/integrations/docker You do not need to add separate hosts for each container and point them to your Us2 agent. You can push this template to Us2 and it should discover all those docker things. There is a note about Setup, you should follow on that server... Access to socket..​
      Thank you for the reply!!! I will disable agent1 and keep agent 2 only.
      The problem I was having was fixed by fixing the permission of zabbix user.

      This is what I found:

      Zabbix Agent(/usr/sbin/zabbix_agentd) and Zabbix Server(/usr/sbin/zabbix_server) run with a user called “zabbix”.
      Docker monitoring commands can be run only by the user if root or a user which is part of linux group called “docker”.
      Thus for the Zabbix agent to keep an eye on Docker containers, you need to add the Zabbix user, which is installed by default, to the docker group.

      The command in ubuntu is:

      $ sudo usermod -aG docker zabbix

      Comment

      Working...