This is a proof-of-concept that converts the output of a Prometheus exporter into a Zabbix template with generated items.
A conversion can be performed in the following way:
- Gather the prometheus output (alternatively use the
--urlparameter in step 4)curl http://kube-prometheus-stack-prometheus.umon:9090/metrics > example/prometheus_exporter_dump.txt - Create an example template in zabbix
- Download it in JSON and add replacement markers to it,
see zabbix_template_prometheus_exporter.json
- PROM2ZABBIX_TEMPLATE_NAME: The name of the template
- PROM2ZABBIX_ITEM_NAME: The displayed name of the template
- PROM2ZABBIX_ITEM_KEY: The item key, adapted label to comply to zabbix item name restrictions
- PROM2ZABBIX_ITEM_LABEL: The prometheus label
- Execute the conversion, this selects only items which match to the specified filter regex
./prom2zabbix \ --template example/zabbix_template_prometheus_exporter.json \ --dump example/prometheus_exporter_dump.txt \ --target_template example/zabbix_template_prometheus_exporter_generated.json \ --filter "promhttp_metric_handler_requests_total" \ --name "Prometheus" - Upload the generated template to zabbix and check the result
- Repeat the process for other items and select the option "Delete missing" of the existing items