[ZBXNEXT-2045] add trigger function that would return historical value's timestamp Created: 2013 Nov 27  Updated: 2024 Mar 07

Status: Open
Project: ZABBIX FEATURE REQUESTS
Component/s: Frontend (F), Server (S)
Affects Version/s: 2.2.0
Fix Version/s: None

Type: New Feature Request Priority: Minor
Reporter: Aleksandrs Saveljevs Assignee: Unassigned
Resolution: Unresolved Votes: 26
Labels: Zabbix7.2, timestamp, triggerfunctions, unixtime
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by ZBXNEXT-7059 Trigger fucntion to get item history ... Closed
Sub-task

 Description   

Suppose we received value "1" for an item at time "1234567890" (a Unix timestamp for "Sat Feb 14 01:31:30 EET 2009"). Currently, we have a function last(), which returns "1". We also wish to have a function, say, unixtime(), which would return "1234567890".

Scenario where this would be useful is as follows. We wish to check how old something is, so we create an item, "last.change", which updates once per day and contains the timestamp of the last change. Then, we create a trigger, "{host:last.change.now()} - {host:last.change.last()} > {$MAX_AGE}". This alerts us when something has been updated too long ago and works well.

However, the problem with the above trigger is that it is recalculated every 30 seconds by the timer process. This puts unnecessary load on the server. So the suggestion is to replace now() with the proposed function unixtime(): "{host:last.change.unixtime()} - {host:last.change.last()} > {$MAX_AGE}". This way, trigger will only be recalculated once per day when it really needs to.



 Comments   
Comment by richlv [ 2013 Nov 27 ]

this would also allow to compare two items and see which one has more recent value. it would be highly useful when having two items that receive snmp traps - and one gets "ok", another gets "error" traps.

Comment by Aleksandrs Saveljevs [ 2013 Nov 27 ]

A somewhat related issue: ZBX-4500.

Comment by Thierry Sallé [ 2013 Dec 17 ]

I also need this kind of trigger function to test if i have recieved some data during a period.
For example, i want to check if i have data once a day from monday to friday, and send an alert on monday if there wasn't any data on friday.

Comment by richlv [ 2013 Dec 17 ]

that should be possible with nodata() function already

Comment by Thierry Sallé [ 2013 Dec 17 ]

richlv: with nodata function, i can only check if i have no data during last "period".
I want to check if i have no data between last friday 00:00 and last saturday 00:00.

Comment by Thierry Sallé [ 2013 Dec 17 ]

I have a related feature request _' :
Is it possible to add a {ITEM.LASTCLOCK} macro to inform users in notifications.
For example : "Last data collected at {ITEM.LASTCLOCK}"

Comment by richlv [ 2013 Dec 17 ]

well, the suggested feature would give you timestamp of the last value, thus it would not help you anyway.

as for the macro/variable, please, create a new feature request for that (searching for existing ones first )

Comment by Thierry Sallé [ 2013 Dec 18 ]

I found a related feature request ZBXNEXT-1118 so i voted for it

Comment by Thierry Sallé [ 2014 Jan 27 ]

Hello,
I'm calling you again about this feature request.
I need to know the last clock of an item value to check if last item clock was before another item clock.

Do you think it's possible to add this new trigger function ?

Comment by richlv [ 2014 Jan 27 ]

it is currently not on the roadmap. fastest way to make it implemented would probably be financed development (see http://www.zabbix.com/development_services.php for detail)

Comment by richlv [ 2014 Oct 31 ]

(1) the function should support optional string that would allow to match last value with a specific string (or regexp)
see ZBXNEXT-2555 for the usecase

Comment by richlv [ 2017 Feb 06 ]

similar trigger function "age()" requested in ZBXNEXT-3680

Comment by Aleksandrs Saveljevs [ 2018 Nov 28 ]

Another example where this could be useful is including a number of latest values with corresponding timestamps in a notification message.

For instance, to send the last five values:

{host:item.unixtime(#1)}: {host:item.last(#1)}
{host:item.unixtime(#2)}: {host:item.last(#2)}
{host:item.unixtime(#3)}: {host:item.last(#3)}
{host:item.unixtime(#4)}: {host:item.last(#4)}
{host:item.unixtime(#5)}: {host:item.last(#5)}

The intention is to produce something like this:

2018.11.28 14:25:00: 75 %
2018.11.28 14:20:00: 48 %
2018.11.28 14:15:00: 33 %
2018.11.28 14:10:00: 31 %
2018.11.28 14:05:00: 9 %

Note that the timestamp is meant to be human-readable.

Comment by James Cook [ 2022 Apr 29 ]

This is may also resolve feature request ZBXNEXT-7017.

I request {ITEM.TIME[0-9]} and {ITEM.LASTTIME[0-9]} so the trigger description for nodata() based expressions.

The idea would be that the time of the item collection can be used in the description for the 'Problem' ({ITEM.TIME[0-9]}) and the 'Recovery' ({ITEM.LASTTIME[0-9]}).

Generated at Fri Apr 19 20:53:50 EEST 2024 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.