How to Use Zabbix Agent2 to Monitor Docker Containers – Step-by-Step Guide
This guide walks through the inner workings of Zabbix Agent2’s Docker monitoring plugin, detailing how it communicates via the Docker API, the key configuration files, the query mechanism, and how to apply the provided templates to automatically discover and display container and image metrics.
Zabbix Agent2 Monitoring Docker Containers
First, the article explains the implementation principle of the Zabbix Agent2 Docker monitoring plugin, which works by calling Docker's API. The plugin source resides in zabbix-agent2/src/go/plugins/docker, starting with the client.go file that defines communication with the Docker daemon via a UNIX socket.
The config.go file defines the plugin's default configuration, including the default socket path /var/run/docker.sock and the global timeout. It loads plugin parameters from the configuration file into an Options struct using conf.Unmarshal().
This step checks whether the Endpoint defined in the configuration file is valid.
Next, docker.go defines the monitoring keys and their corresponding API request paths and parameter lengths.
A Query method constructs a GET request based on the provided API path to retrieve data. The request uses a constant 1.28 for the Docker API version and the default socket path /var/run/docker.sock.
The plugin implements an Export interface that passes a key to the Query method and returns JSON‑formatted data. The template creates dependencies and uses a preprocessing step to split the JSON.
Zabbix also provides two methods for automatic discovery of containers and images, returning JSON data that includes information about each container and image.
These metrics are initialized with parameters such as the plugin pointer, plugin name, key, and description.
After understanding the plugin's implementation, you can extend it by adding new API calls or creating custom scripts for Zabbix Agent2 based on the same logic.
Using the Agent2 Template to Monitor Docker
The article provides a link to the Docker template, which, once applied, displays the status of Docker containers directly in Zabbix.
After loading the template, the Docker status becomes visible in the Zabbix dashboard.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Ops Development Stories
Maintained by a like‑minded team, covering both operations and development. Topics span Linux ops, DevOps toolchain, Kubernetes containerization, monitoring, log collection, network security, and Python or Go development. Team members: Qiao Ke, wanger, Dong Ge, Su Xin, Hua Zai, Zheng Ge, Teacher Xia.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
