Ad Widget

Collapse

Issues with Docker Monitoring in Swarm Mode: Container Name Changes on Restart

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • still_at_work
    Junior Member
    • Jul 2023
    • 9

    #1

    Issues with Docker Monitoring in Swarm Mode: Container Name Changes on Restart

    Hello everyone,

    I’m using Zabbix to monitor my Docker containers, and overall, it works very well. I’ve set up discovery to track containers and monitor their metrics efficiently.

    However, since I started using Docker Swarm, I’ve encountered a challenge. Each time the Docker containers are restarted (due to scaling, updates, or node changes), their names change. For example, a container might be named app_mycontainer.1.xxyz1234 initially, but after a restart, it could be renamed to something like app_mycontainer.1.abcd5678.

    This behavior causes issues in Zabbix:
    • Old container names remain in Zabbix with no metrics (because the containers no longer exist).
    • New container names are treated as entirely new entities, triggering alerts for the "missing" containers.

    I’d like to know if anyone has experienced a similar issue and how you resolved it. Is there a way to handle this dynamically in Zabbix to avoid accumulating non-existent containers and to prevent unnecessary alerts when containers are replaced in Swarm mode?

    Here are the specifics of my setup:
    • Zabbix Version: 6.4.16
    • Docker Setup: Using Docker Swarm
    • Monitoring Template: Docker by Zabbix Agent 2
    • Problem: Container names change on restart due to Docker Swarm's naming convention.

    Thank you in advance for your help!
  • Jan_Prusinowski
    Junior Member
    • Dec 2024
    • 6

    #2
    Have you considered using labels instead of Docker container IDs? Labels are static, even if a container changes its name during a restart. Zabbix can be configured to discover and monitor containers based on these labels rather than container names. Would this solution work for you?

    Comment

    • duarte936
      Junior Member
      • Dec 2024
      • 1

      #3
      Hi everyone,

      I'm facing the same issue
      I already tried the following solution: https://medium.com/@archonkulis/zabb...y-b9ffc2b76652, but unfortunately, this template can't even connect to Docker, so I'm stuck at this point.

      I would really appreciate any help!

      Thank you in advance!

      Comment

      • JJJosph
        Junior Member
        • Dec 2024
        • 1

        #4
        Hello everyone,

        I would like to know if there is a solution to this problem?

        Thank you in advance for your help!

        Comment

        • Brambo
          Senior Member
          • Jul 2023
          • 245

          #5
          I don't use this plugin, but looking at the code of the discovery.go I see that #ID and #NAME are provided as macro's.
          You could try to test this #ID macro in the item key, however as I don't now which values are returned by the macro this also could have unexpected results.
          Last edited by Brambo; 23-12-2024, 11:56.

          Comment

          • toontoet
            Junior Member
            • Jul 2025
            • 1

            #6
            I've created a agent2 plugin to get some extra docker swarm stacks and services into zabbix: https://github.com/toontoet/zabbix-a...n-docker-swarm

            Comment


            • Tristis Oris
              Tristis Oris commented
              Editing a comment
              Sounds great, but do we need a new template for this?
          Working...