Skip to content
Tutorials Center
My learning

Topics

Lesson 21 of 37 ยท Templates and Discovery

Discovery Rules, Prototypes and Network Discovery

Build Zabbix discovery rules step by step: item, trigger, graph and host prototypes, overrides, dependent items, and the separate network discovery with actions.

The previous lesson explained what LLD is. Now you will build one, from the data source to host prototypes, and meet the other discovery mechanism: network discovery, which finds whole hosts instead of parts of a host. Zabbix is not runnable on this site, so steps are described in words and the runnable parts are stand-ins.

Anatomy of a discovery rule

In a template, open Discovery rules > Create discovery rule. The fields you fill in:

  • Name and Type (Zabbix agent, SNMP agent, Script, HTTP agent, Dependent item, and others).
  • Key: for example net.if.discovery, or a user parameter such as app.queues.discovery.
  • Update interval: 1h by default is sensible.
  • Filters and Overrides (see below).
  • Keep lost resources period and optional "disable lost resources".

After saving, the rule gets four prototype types: item, trigger, graph and host prototypes.

Prototypes in practice

For a discovery of network interfaces ({#IFNAME}):

Prototype Example
Item net.if.in[{#IFNAME}], name Incoming traffic on {#IFNAME}, units bps, preprocessing Change per second, Custom multiplier 8
Item net.if.out[{#IFNAME}] with the same preprocessing
Trigger avg(/Template Net/net.if.in[{#IFNAME}],5m)>{$IF.UTIL.MAX:"{#IFNAME}"}
Graph One graph per interface with both items

Note the user macro with context :"{#IFNAME}". A default value is set on the template, and a host that has a noisy eth1 can override just that context.

Preprocessing steps and tags in prototypes work as on normal items, and tags may contain LLD macros (interface:{#IFNAME}), which makes later problem filtering easy.

Dependent items and one-call discovery

Calling an agent once per metric is wasteful. A better design collects a JSON blob with a master item and derives everything else from it:

  1. Master item app.status.raw, type text, runs every minute and returns JSON.
  2. Discovery rule of type Dependent item with preprocessing JSONPath: $.queues to build the list.
  3. Item prototypes of type dependent, each with preprocessing JSONPath: $.queues[?(@.name=="{#NAME}")].depth.first().

One agent request now yields all metrics. The HTTP agent type fits well when an application exposes a status page.

Overrides

An override changes prototypes for entries that match a filter. Typical examples:

  • Filesystem /boot: do not create the free-space trigger prototype ("no trigger").
  • Interface names starting with veth: skip item creation entirely.
  • Disk nvme0n1: set a different severity or add a tag.

Overrides are evaluated in order, so keep the list short and name each one clearly. They are better than building complicated regular expressions in the filter.

Host prototypes

Some discoveries return things that deserve their own host: virtual machines on a hypervisor, containers, or devices behind a gateway. A host prototype creates a host per entry. You give it a name pattern (vm-{#VMNAME}), template links, groups, macros and optionally a custom interface. The discovered hosts are managed by the rule: they appear and disappear with it, and you cannot edit inherited fields. Link templates to the prototype, not to the created hosts.

Network discovery (finding hosts)

Network discovery is a different feature, configured under Data collection > Discovery (older versions: Configuration > Discovery). A rule contains:

  • An IP range: 192.168.10.1-254, 10.0.0.0/24, or a comma list.
  • Checks: ICMP ping, TCP connect on a port, Zabbix agent key lookups, SNMP OID reads, HTTP, SSH and others.
  • An update interval and a device uniqueness criterion (IP address or a check value).

Discovery by itself only records events. To act on them you create a discovery action (Alerts > Actions > Discovery actions) with conditions such as "Service type = HTTP and Received value contains nginx" and operations such as Add host, Add to host group, Link template, or Enable host. This is the classic pairing: discover web servers, add them, and link Template App Nginx automatically.

Another route is autoregistration for active agents: the agent announces itself with its HostMetadata, and an autoregistration action links templates by matching metadata text such as Linux web. For big, cloud-like fleets, autoregistration is much cheaper than scanning IP ranges.

Stand-in: an override engine

This Python code models the way overrides select and adjust prototypes. It is not Zabbix code.

Python Override rules on discovered entries (Python stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Stand-in: planning a scan

Before enabling a network discovery rule, estimate its size and duration. This calculator shows why wide ranges and slow checks need care.

Python Network discovery workload (Python stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The /16 with three one-second checks takes hours. Split large networks into several rules with different intervals, or use autoregistration instead.

Troubleshooting checklist

  • Rule is "not supported": run the key on the agent with zabbix_get -s HOST -k KEY and inspect the output.
  • Items do not appear: check filters, then check that every macro used in prototypes is returned.
  • Too many items: add a filter or an override before the rule ever runs against production.
  • Discovered hosts keep duplicating: change the uniqueness criterion from IP address to a stable value such as a hostname or UUID.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a host prototype create?

    Host prototypes produce hosts that live and die with the discovery rule.
  2. 2. Which feature finds new servers in an IP range?

    Network discovery scans ranges; actions add hosts and link templates.
  3. 3. Why use a dependent-item discovery with a master item?

    One request fills many dependent items through JSONPath preprocessing.
  4. 4. You do not want a trigger for /boot only. What is the clean solution?

    Overrides adjust prototypes for matching entries.

Summary

  • Rules produce item, trigger, graph and host prototypes; macros fill their keys and names.
  • Dependent-item discovery lets one request drive many items.
  • Overrides adjust prototypes for matching entries; filters decide which entries exist.
  • Network discovery finds hosts, discovery actions add them; autoregistration suits large fleets.

Next: Nagios Object Inheritance