Thruk icon indicating copy to clipboard operation
Thruk copied to clipboard

Ability to set different status types for AND conditions in filters panel

Open Ashark opened this issue 3 years ago • 2 comments

Currently (I checked in Thruk 2.40-2) it is impossible to filter with different status types for several services in AND conditions in web interface.

Explanation in more details. I have a service "CPU freq". Also I have a service "Firmware". "Firmware" service is normally used to check firmware outdatance. But also in its output is shows the motherboard model of the server. So in this example I want to use "Firmware" service as a filter. I want to show only servers with "CPU freq" in status ok and logical conjunction that with non-hp servers.

If I wanted disjunction, this is easily achievable with the "> or" button where you can set service status separately, as in this screenshot: filters_for_or_and_and

But it is impossible to achieve the same feature for conjunction. As you can see, the "v and" button just adds another filter, while the service status types are common for all filters in and.

If I make an and condition with "ok" status, I will miss also-wanted non-hp servers that has outdated firmware. But if I make an and condition with "any" status, I will also gen unwanted servers with non-ok "cpu freq" service.

Describe the solution you'd like Near the "or" button, the second "and" button could be added. This way you could write a separate status and properties for the filters with and condition.

Describe alternatives you've considered Not really an alternative, but I guess this can be achieved via api.

Additional This also could be used for simplifying searh. For example, by plugin output: search service "Firmware" with plugin output ~ "hp" AND service "ipmi login" with plugin output ~ "unable to login".

Ashark avatar Jun 10 '21 16:06 Ashark

i am not sure if i understand the issue correctly. The very last example would match nothing, because there is no service with name "Firmware" and name "ipmi login". What you want is an "or" here. If you want something like sub queries, meaning all hosts which have a service firmware in none-ok state and you want to list the service ipmi login of those, then this is not possible. Should still be possible to generate such a list with 2-5lines of shell.

sni avatar Jun 21 '21 15:06 sni

Yes, you may think of it like a sub query. Actually, it is A ∩ B as in this picture: 330px-Venn_A_intersect_B svg

Yes, looks like it is impossible to create such filters, and this is exactly the issue I opened.

I have created my custom script so that I can extract host names to a list in text file from a url of a thruk page. So yes, I can make two separate lists. Ok, then I can create a script that will only create a list of hosts from both A and B, i.e. A ∩ B hosts. But I have no idea how to conveniently import that list again to thruk and see what I wanted. And I will need to redo all these extract actions every time.

Don't you like my suggestion in "Describe the solution you'd like"?

Ashark avatar Jun 21 '21 16:06 Ashark

Thinking about it, there is a undocumented feature for lexical querys which is used from the thruk grafana datasource. You can supply filter with the generic q parameter. This is not very intuitive for most users, so i never added an input field for this.

But it is possible to do something like this:

/thruk/cgi-bin/status.cgi?q=description %3D 'CPU' and host_services >%3D firmware&style=detail

This will show all services name CPU on hosts which have a firmware service. But, searching lists like the host_services does not support regular expressions unless you use LMD. And of course it's a bit cumbersome to write your querys url encoded :) But it might work to store this as a bookmark if you need that frequently.

Maybe i'll add a raw query input at some point for the experienced poweruser :-)

sni avatar Nov 25 '22 17:11 sni