docs/victoriametrics/integrations/zabbixconnector.md
VictoriaMetrics components like vmagent, vminsert or single-node can receive data from
Zabbix Connector streaming protocol
at /zabbixconnector/api/v1/history HTTP path.
You must specify http://<victoriametrics-addr>:8428/zabbixconnector/api/v1/history in the "URL" parameter when creating a new connector in the Zabbix WEB interface. Starting from version 7.0, the "Type of information" parameter must be set to "numeric (unsigned)" and "numeric (float)".
Extra labels may be added to all the written time series by passing extra_label=name=value query args.
For example, /zabbixconnector/api/v1/history?extra_label=foo=bar would add {foo="bar"} label to all the ingested metrics.
VictoriaMetrics maps Zabbix Connector streaming protocol to raw samples in the following way:
$.host.host converts to label value host.$.host.name converts to label value hostname.$.name converts to label value __name__.$.value is used as the metric value.$.clock and $.ns is used as timestamp for the ingested raw sample.$.clock*1e3 + $.ns/1e6 (See Zabbix item structure for details)-zabbixconnector.addGroupsValue=<value> is specified, the elements of the $.grops group array will be converted to the label name prefixed with group_ with the value <value>.$.item_tags will be configured as follows:
tag element will be used as the tag name, prefixed with tag_. The "value" element will be used as the value of the label.-zabbixconnector.addEmptyTagsValue=<value> is specified, then tags with empty values will not be ignored. <value> will be used as the tag value. By default, tags with empty values are ignored.-zabbixconnector.addDuplicateTagsSeparator=<value> is specified, then the values of duplicate tags will be merged into one using the <value> delimiter.For example, let's import the following Zabbix Connector request to VictoriaMetrics:
{"host":{"host":"ZabbixServer","name":"ZabbixServer"},"groups":["servers"],"item_tags":[{"tag":"foo","value":""}],"itemid":44457,"name":"item_1","clock":1673454303,"ns":800155804,"value":0,"type":3}
{"host":{"host":"ZabbixServer","name":"ZabbixServer"},"groups":["servers"],"item_tags":[{"tag":"foo","value":"test"}, {"tag":"foo","value":""}],"itemid":44458,"name":"item_2","clock":1673454303,"ns":832290669,"value":1,"type":3}
{"host":{"host":"ZabbixServer","name":"ZabbixServer"},"groups":["servers"],"item_tags":[{"tag":"bar","value":"test"}],"itemid":44458,"name":"item_3","clock":1673454303,"ns":867770366,"value":123,"type":3}
Save this NDJSON into data.ndjson file and then use the following command in order to import it into VictoriaMetrics:
curl -X POST -H 'Content-Type: application/x-ndjson' --data-binary @data.ndjson http://localhost:8428/zabbixconnector/api/v1/history
Let's assume vmagent is running with command line flags:
-zabbixconnector.addGroupsValue=exists-zabbixconnector.addEmptyTagsValue=exists-zabbixconnector.addDuplicateTagsSeparator=,Let's fetch the ingested data via data export API:
curl http://localhost:8428/api/v1/export -d 'match={host="Zabbix server"}'
{"metric":{"__name__":"item_1","host":"ZabbixServer","hostname":"ZabbixServer","group_servers":"exists","tag_foo":"exists"},"values":[0],"timestamps":[1673454303800]}
{"metric":{"__name__":"item_2","host":"ZabbixServer","hostname":"ZabbixServer","group_servers":"exists","tag_foo":"test,exists"},"values":[1],"timestamps":[1673454303832]}
{"metric":{"__name__":"item_3","host":"ZabbixServer","hostname":"ZabbixServer","group_servers":"exists","tag_bar":"test"},"values":[123],"timestamps":[1673454303867]}