12 Discovery using Prometheus data

Overview

Data provided in Prometheus line format can be used for low-level discovery.

See Prometheus checks for details how Prometheus data querying is implemented in Zabbix.

Configuration

The low-level discovery rule should be created as a dependent item to the HTTP master item that collects Prometheus data.

Prometheus to JSON

In the discovery rule, go to the Preprocessing tab and select the Prometheus to JSON preprocessing option. Data in JSON format are needed for discovery and the Prometheus to JSON preprocessing option will return exactly that, with the following attributes:

  • metric name

  • metric value

  • help (if present)

  • type (if present)

  • labels (if present)

  • raw line

For example, querying wmi_logical_disk_free_bytes:

12 Discovery using Prometheus data - 图1

from these Prometheus lines:

  1. # HELP wmi_logical_disk_free_bytes Free space in bytes (LogicalDisk.PercentFreeSpace)
  2. # TYPE wmi_logical_disk_free_bytes gauge
  3. wmi_logical_disk_free_bytes{volume="C:"} 3.5180249088e+11
  4. wmi_logical_disk_free_bytes{volume="D:"} 2.627731456e+09
  5. wmi_logical_disk_free_bytes{volume="HarddiskVolume4"} 4.59276288e+08

will return:

  1. [
  2. {
  3. "name": "wmi_logical_disk_free_bytes",
  4. "help": "Free space in bytes (LogicalDisk.PercentFreeSpace)",
  5. "type": "gauge",
  6. "labels": {
  7. "volume": "C:"
  8. },
  9. "value": "3.5180249088e+11",
  10. "line_raw": "wmi_logical_disk_free_bytes{volume=\"C:\"} 3.5180249088e+11"
  11. },
  12. {
  13. "name": "wmi_logical_disk_free_bytes",
  14. "help": "Free space in bytes (LogicalDisk.PercentFreeSpace)",
  15. "type": "gauge",
  16. "labels": {
  17. "volume": "D:"
  18. },
  19. "value": "2.627731456e+09",
  20. "line_raw": "wmi_logical_disk_free_bytes{volume=\"D:\"} 2.627731456e+09"
  21. },
  22. {
  23. "name": "wmi_logical_disk_free_bytes",
  24. "help": "Free space in bytes (LogicalDisk.PercentFreeSpace)",
  25. "type": "gauge",
  26. "labels": {
  27. "volume": "HarddiskVolume4"
  28. },
  29. "value": "4.59276288e+08",
  30. "line_raw": "wmi_logical_disk_free_bytes{volume=\"HarddiskVolume4\"} 4.59276288e+08"
  31. }
  32. ]
Mapping LLD macros

Next you have to go to the LLD macros tab and make the following mappings:

  1. {#VOLUME}=$.labels['volume']
  2. {#METRIC}=$['name']
  3. {#HELP}=$['help']
Item prototype

You may want to create an item prototype like this:

12 Discovery using Prometheus data - 图2

with preprocessing options:

12 Discovery using Prometheus data - 图3