Ad Widget

Collapse

Zabbix template trigger expression referencing a item from another template

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • erasedhammer
    Member
    • Aug 2020
    • 58

    #1

    Zabbix template trigger expression referencing a item from another template

    I'm having trouble thinking and implementing a way to do the following:

    I have a systemd monitoring template which has 2 main triggers for any given discovered service. "The service has restarted" or "The service is not running". When a given host restarts, every single service trigger kicks off with an alert saying "service has restarted". This makes sense, the host restarts, so do the services.

    My goal is to prevent the service trigger alerts from being generated if the host uptime is less than 10 minutes (the default timer for the "host restarted" trigger). In other words, "Service has restarted" trigger should only be generated when the host uptime (and subsequently the service uptime itself) is more than 10 minutes.

    So my initial thoughts were to use trigger dependencies, but those only create a dependency off another trigger. So I wouldn't want my "service has restarted" trigger to activate if the "host has restarted" trigger was also activated (thats the opposite of what I want). And as far as I am aware, the trigger dependencies do not have a "negate" or "not" function/operator built into them. So I couldn't say something like: "This trigger can only activate if this other trigger is currently inactive."

    So my next thought was to edit the template discovery trigger prototype expression and change it from the following:
    Code:
    last(/Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m
    to something like
    Code:
    last(system.uptime)>10m AND last(/Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m
    This isn't exact syntax, just the rough idea of what I was thinking of.

    The problem is when I try to do the expression editor and include the item from another template, is errors out with:

    Code:
    Trigger prototype "{#UNIT.NAME}: has been restarted" belongs to templates with different linkages.
    I assume that it wont let me link a prototype trigger with another templates item?

    I am using the default "Linux Generic by Zabbix Agent" Template, and the following template for systemd: https://git.zabbix.com/projects/ZBX/...at=release/6.0

    Overall, I definitely don't want to be going around to every host and creating custom triggers for every single service that compares the host uptime with the systemd service uptime. Maybe I could move the system.uptime template item from the "Generic Linux Template" to the Systemd template, but thats rather brute force.

    Anyone got an ideas for what to do here? Any better/more elegant ways to solve my problem?
  • seren
    Junior Member
    • Jun 2023
    • 10

    #2
    Did you ever find a solution to this problem? I have a similar issue with an item that I'd like to reference from triggers in different templates. Thanks!

    Comment

    Working...