New set of trigger functions for long term analytics (ZBXNEXT-6140)

[ZBXNEXT-6184] Time and number formatting macro functions fmttime, fmtnum Created: 2020 Sep 03  Updated: 2024 Apr 10  Resolved: 2020 Oct 19

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Server (S)
Affects Version/s: None
Fix Version/s: 5.2.0beta2, 5.2 (plan)

Type: Specification change (Sub-task) Priority: Trivial
Reporter: Rostislav Palivoda (Inactive) Assignee: Viktors Tjarve
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Team: Team A
Sprint: Sprint 67 (Aug 2020), Sprint 68 (Sep 2020), Sprint 69 (Oct 2020), Sprint 80 (Sep 2021)
Story Points: 1

 Description   
Time formatting macro function

Time formatting macro function fmttime  will be added to allow custom time formats. It will be usable with {TIME} macro.

Usage: fmttime(<format>, <time_shift>) 

  • <format>  - mandatory format string, compatible with strftime function formatting.
  • <time_shift>  - the time shift applied to the time before formatting: -<N><time unit> , where
    • <N>  - the number of time units to subtract
    • <time unit>  - the time unit: h (hour), d (day), w (week), M (month) and y (year).

For example: fmttime(%B,-1M) 

Number formatting macro function

Number formatting macro function fmtnum  will be added to control the number of digits printed after the decimal point.

Usage: fmtnum(<digits>) 

  • <digits>  - the number of digits after decimal point. No trailing zeros will be produced.

For example: fmtnum(2) 



 Comments   
Comment by Viktors Tjarve [ 2020 Sep 24 ]

Released in:

Comment by MArk [ 2024 Jan 16 ]

The TIME macro has very little documentation for its time formatting.

I see the time units suggested above in this request, but cannot find them in the documentation

According to the doc, it is compatible with the strftime formatting method. I suppose we can use these kind of formatting codes. A reference link might help a bit.

Also, adding some common format code representation might improve the doc as well as including more complex examples.

Example:

{{TIME}.fmttime(%Y-%m-%d %H:%M:%S)} = 2024-01-16 10:17:00

 


It would be a great improvement if the TIME macro were supported in items and triggers for more complex data retrieval or processing.


Comment by MArk [ 2024 Jan 16 ]

Is it possible to reopen this request or should a new one be created?

Generated at Fri Jun 06 20:52:21 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.