-
New Feature Request
-
Resolution: Unresolved
-
Major
-
None
-
None
-
Calculated Items using aggregate functions
Aggregate functions using foreach functions are a mighty tool. However, there are some glaring omissions that are difficult to impossible to work around.
Consider for example a template determining the current patch state of Linux systems (this is an actual use case of mine). It uses some predefined thresholds to fill a patch state item for each Linux hosts; the item contains values 0 (unknown), 1 (bad), 2 (warning), 3 (good).
Now I want to get a simple graph to show me how many of my Linux servers have which patch state. Easy? No, it is not possible right now. I would need to count the number of hosts where this item has a specific value. However, item filters right now only support host groups and / or tags as criteria. Host groups obviously do not help me here, and I see no way to put a current item value in a tag. So what would be required is a filter enhancement that would allow me something like this:
count(last_foreach(/*/patch.stage,value=2)) (or something like this).
Consider another problem: I want to have a statistic with the different Linux Versions I run with the number of hosts for each of them.
This would require a LLD using a calculated item returning JSON, e.g.:
distinct(last_foreach(/*/linux.version)) returning something like
[""{#LINUX.VERSION}":"RHEL8.5","{#LINUX.VERSION}":"Centos 8 Stream"
So I could use an item prototype like this
count(last_foreach(/*/linux.version,strcmp({#LINUX.VERSION}))
to get the count for string values as well.
While this would fit in well syntactically, I guess this is not trivial to implement.