Skip to content

Instantly share code, notes, and snippets.

@wheel5up
Created April 8, 2025 16:12
Show Gist options
  • Select an option

  • Save wheel5up/478329979961b1532b6eaa84b83f38eb to your computer and use it in GitHub Desktop.

Select an option

Save wheel5up/478329979961b1532b6eaa84b83f38eb to your computer and use it in GitHub Desktop.
Zabbix docker container discovery for agent v1
{
"zabbix_export": {
"version": "7.0",
"template_groups": [
{
"uuid": "a571c0d144b14fd4a87a9d9b2aa9fcd6",
"name": "Templates/Applications"
}
],
"host_groups": [
{
"uuid": "e11ed509db20463981961a17553f64df",
"name": "Containers"
}
],
"templates": [
{
"uuid": "aeabf248a59a4687a13d0a5fc9b01cd7",
"template": "Docker",
"name": "Docker",
"groups": [
{
"name": "Templates/Applications"
}
],
"items": [
{
"uuid": "b8a7dfb6206e4299a4cecae930347b46",
"name": "Docker containers",
"key": "docker.containers",
"history": "90d",
"value_type": "TEXT",
"tags": [
{
"tag": "component",
"value": "docker"
},
{
"tag": "type",
"value": "containers"
}
]
}
],
"discovery_rules": [
{
"uuid": "8f1e5fba1ba64f86aa13420eb41a7645",
"name": "Docker discovery",
"type": "DEPENDENT",
"key": "docker.discovery",
"lifetime": "30d",
"enabled_lifetime_type": "DISABLE_NEVER",
"item_prototypes": [
{
"uuid": "e453358b9791433cb705b769e7ad0236",
"name": "{{#CONTAINERNAME}.regsub(\"^/(.*)\",\"\\1\")} status",
"type": "DEPENDENT",
"key": "docker.container.status[{#CONTAINERNAME}]",
"value_type": "TEXT",
"preprocessing": [
{
"type": "JSONPATH",
"parameters": [
"$.[?(@.Id == '{#CONTAINERID}')].State"
]
}
],
"master_item": {
"key": "docker.containers"
},
"tags": [
{
"tag": "component",
"value": "container"
}
],
"trigger_prototypes": [
{
"uuid": "965526e588374b39a9c8a6267eee7c2b",
"expression": "change(/Docker/docker.container.status[{#CONTAINERNAME}]) = 1",
"name": "Container Changed State"
}
]
}
],
"host_prototypes": [
{
"uuid": "e4b0e7c66c8542f396968aebe4a86e92",
"host": "{{#CONTAINERNAME}.regsub(\"^/(.*)\",\"\\1\")}",
"name": "{{#CONTAINERNAME}.regsub(\"^/(.*)\",\"\\1\")}",
"inventory_mode": "AUTOMATIC",
"group_links": [
{
"group": {
"name": "Containers"
}
}
],
"templates": [
{
"name": "Container Instance"
}
],
"macros": [
{
"macro": "{$CONTAINERID}",
"value": "{#CONTAINERID}",
"description": "Sets container ID for other templates to use"
},
{
"macro": "{$CONTAINERIP}",
"value": "{#IPADDRESS}"
}
],
"tags": [
{
"tag": "component",
"value": "Docker"
},
{
"tag": "containerID",
"value": "{#CONTAINERID}"
},
{
"tag": "containerName",
"value": "{#CONTAINERNAME}"
},
{
"tag": "image",
"value": "{#IMAGE}"
},
{
"tag": "imageID",
"value": "{#IMAGEID}"
},
{
"tag": "ipaddress",
"value": "{#IPADDRESS}"
},
{
"tag": "macaddress",
"value": "{#MACADDRESS}"
},
{
"tag": "state",
"value": "{#STATE}"
}
],
"custom_interfaces": "YES"
}
],
"master_item": {
"key": "docker.containers"
},
"lld_macro_paths": [
{
"lld_macro": "{#CONTAINERID}",
"path": "$.Id"
},
{
"lld_macro": "{#CONTAINERNAME}",
"path": "$.Names.first()"
},
{
"lld_macro": "{#IMAGEID}",
"path": "$.ImageID"
},
{
"lld_macro": "{#IMAGE}",
"path": "$.Image"
},
{
"lld_macro": "{#IPADDRESS}",
"path": "$.NetworkSettings.Networks.*.IPAddress.first()"
},
{
"lld_macro": "{#MACADDRESS}",
"path": "$.NetworkSettings.Networks.*.MacAddress.first()"
},
{
"lld_macro": "{#STATE}",
"path": "$.State"
}
],
"overrides": [
{
"name": "Disabled Container",
"step": "1",
"filter": {
"conditions": [
{
"macro": "{#STATE}",
"value": "exited"
}
]
},
"operations": [
{
"operationobject": "HOST_PROTOTYPE",
"operator": "REGEXP",
"value": ".*",
"discover": "NO_DISCOVER",
"status": "DISABLED"
}
]
}
]
}
],
"tags": [
{
"tag": "component",
"value": "docker"
}
]
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment