[ZBXNEXT-6601] Zabbix Trigger Function for Monotonic Items Created: 2021 Apr 03  Updated: 2024 Apr 10  Resolved: 2021 Aug 25

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F), Server (S)
Affects Version/s: None
Fix Version/s: 6.0.0alpha1, 6.0 (plan)

Type: New Feature Request Priority: Minor
Reporter: Ryan Eberly Assignee: Artjoms Rimdjonoks
Resolution: Fixed Votes: 3
Labels: expressions, functions, trigger
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: JPEG File XXX2.jpg     JPEG File XXX_1.jpg    
Issue Links:
Causes
Team: Team C
Sprint: Sprint 78 (Jul 2021), Sprint 79 (Aug 2021)
Story Points: 1

 Description   

I have several trigger expressions that look for monotonically increasing items. For example, I monitor applications that perform messaging and when something goes wrong the message queue increases. I also monitor applications that are supposed to read files from disk and if the application fails we can tell by counting the files in the directory and checking if they are increasing monotonically. I have several expressions like,

"{Host1:system.app.messaging.last()} > *

{Host1:system.app.messaging.prev()}

and* *

{Host1:system.app.messaging.prev()}

> 

{Host1:system.app.messaging.last(#3)}

and* *

{Host1:system.app.messaging.last(#3)}

> 

{Host1:system.app.messaging.last(#4)}

"*********

...and so on up to last(#24) or even higher in some cases. This makes the trigger expression quite large and difficult to read. Is it possible to add a new trigger function that does something like the below (written in javascript as an example):

// assume var array is an time-ordered (ascending) list of values retrieved from zabbix

var array = [1, 3, 5, 6, 7];
var is_monotonic_increasing = true;
var is_monotonic_decreasing = true;
for (let i = 1; i < array.length; i++) {
    if (array[i] < array[i - 1]) {
        is_monotonic_increasing = false;
    }
    if (array[i] > array[i - 1]) {
        is_monotonic_decreasing = false;
    }
}
console.log(is_monotonic_increasing);
console.log(is_monotonic_decreasing);

 

The function name could be something like:

monotonic(sec|#num,<operator>,time_shift)

where <operator> would either be "increasing" or "decreasing".

Real example allowing us to check if all values received in the last 6 hours are monotonically increasing:

*

{Host1:system.app.messaging.monotonic(6h,"increasing")}

= 1*

Real example checking if all values in the last 10 values are monotonically decreasing:

*

{Host1:system.app.messaging.monotonic(#10,"decreasing")}

= 1*

 

Thank you so much for your time and I hope this possible!



 Comments   
Comment by Alexei Vladishev [ 2021 May 21 ]

It sounds like a great feature request, should be implemented at some point.

Comment by Alexei Vladishev [ 2021 May 26 ]

I think we should introduce two functions monoinc(/host/key, <mode>) and monodec(/host/key, <mode>). If <mode> is set to 'strict' then we check for strict increasing/decreasing monotonic values. By default, the functions will check for weak monotonicity.

Comment by Ryan Eberly [ 2021 May 27 ]

The mode option is a good idea. When setting it to strict I presume that would check that every value is greater/less than the previous value? Just for my own knowledge, how would the 'weak' algorithm work?

Thank you very much. I'm happy to see this be implemented!

Comment by Ryan Eberly [ 2021 May 27 ]

Sorry, I had that backwards. I meant to ask about the 'strict' mode. I presume that weak monotonicity would mean that each value would be greater/less than the previous value retrieved from zabbix. I'm curious if 'strict' would mean that each value is greater/less than or equal to the previous value. But how many consecutive values can be equivalent with strict monotonicity?

Comment by Alexei Vladishev [ 2021 May 27 ]

Weak increasing means that each next value is greater or equal to previous one. Strong means that each next value must be greater.

Comment by Ryan Eberly [ 2021 May 27 ]

Thank you for the clarification.

Comment by Alexei Vladishev [ 2021 May 27 ]

I forgot to mention that this functionality will be implemented in Zabbix 6.0 LTS.

Comment by Artjoms Rimdjonoks [ 2021 Aug 05 ]

Available in versions:

Updated documentation:

Comment by Ryan Eberly [ 2021 Oct 23 ]

I'm excited for this and thank you very much! We've recently run into several issues with MySql deadlocks when trying to update/create triggers with many expressions in them, specifically with INSERT statements into the functions table. When we decrease the expressions in the trigger the deadlock does not happen. Being able to replace some of our expressions with a single monoinc() or monodec() should definitely improve the speed of those INSERT transactions and lessen the load on the database. I look forward to more features and optimizations like this.

Generated at Tue Apr 08 08:12:35 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.