VictoriaMetrics components like vmagent, vminsert or single-node can receive data from
Zabbix Connector streaming protocol
at /zabbixconnector/api/v1/history HTTP path.
Send data from Zabbix Connector #
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.
Zabbix Connector data mapping #
VictoriaMetrics maps Zabbix Connector streaming protocol to raw samples in the following way:
- Discards all item values that do not match the types “numeric (unsigned)” and “numeric (float)”.
- JSON path
$.host.hostconverts to label valuehost. - JSON path
$.host.nameconverts to label valuehostname. - JSON path
$.nameconverts to label value__name__. - JSON path
$.valueis used as the metric value. - JSON path
$.clockand$.nsis used as timestamp for the ingested raw sample .
timestamp is calculated using the formula:$.clock*1e3 +$.ns/1e6 (See Zabbix item structure for details) - If the command line flag
-zabbixconnector.addGroupsValue=<value>is specified, the elements of the$.gropsgroup array will be converted to the label name prefixed withgroup_with the value<value>. - The tag object array
$.item_tagswill be configured as follows:- The
tagelement will be used as the tag name, prefixed withtag_. The “value” element will be used as the value of the label. - If the command line flag
-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. - If the command line flag
-zabbixconnector.addDuplicateTagsSeparator=<value>is specified, then the values of duplicate tags will be merged into one using the<value>delimiter.
- The
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]}