zabbix-kubernetes is "plugin" used for Kubernetes monitoring. Easy to deploy and configure. Addition of all metrics for pods, deployments, services, etc are done automatically. Script designed to make addition of new metrics easy w/o interaction with scripting or console.
- Install required Perl modules with cpan
- LWP::UserAgent
- JSON
- Copy scripts to zabbix external scripts path
- Import Zabbix template
- Configure zabbix macros in template with correct path to kubernetes config file (which can be used by kubectl)
- Check other macros related to triger thresholds
- Create Zabbix API user and assign appropriate permissions. User must have "Admin Role" and has access to host groups with monitored hosts
- Check "CONFIG" section in both scripts and set appropriate values for variables
Plugin has its own syntax for key. You dont need to change anything in scripts or creating cronjobs, etc. All you need to do is to create item with appropriate key. Items has the following syntax: trap.k8s.<kind>[<namespace>,<name>,<jsonpath>]
- trap.k8s. - prefix used to filter items via Zabbix API, for 99.9% needs just write it as is.
- <kind> - can be pods,deployments,services,nodes
- <namespace> - namespace or none for deployments
- <name> - name from metadata (any kind)
- <jsonpath> - path inside of kubectl JSON output. For arrays additional expression must be set. E.g. for getting status of nodes in "conditoins":
trap.k8s.nodes[default,minikube,status.conditions(type=DiskPressure).status]
- {$NAMESPACE} - per namespace separation (one zabbix host = one namespace). Multiple namespaces supported (separate with comma)
- {$K8SCONFIG} - path to kubernetes config (should be readable by zabbix server). Multiple configs supported.
- {$CONTAINER_RESTART_THRESH} - threshold for container restart count
- {$DISCOVERY_NODATA_PERIOD} - no data from discovery period for trigger