Icinga / icingaweb2-module-cube

Drill-down view for Icinga web 2 based on custom variables
GNU General Public License v2.0
45 stars 12 forks source link

Allow matching of array entries in arbitrary positions #88

Closed mocdaniel closed 2 years ago

mocdaniel commented 2 years ago

Is your feature request related to a problem? Please describe.

When combining the cube module with IcingaDB as a backend it is now possible to operate on array/dictionary entries. But, counterintuitively, these operations happen "in place". Consider the following array variable on two hosts:

host1.fruit = ["apple", "banana", "orange", "papaya"]
host2.fruit = ["banana", "apple", "orange"]

Based on the four different entries for this variable across all hosts, Cube/IcingaDB will offer entries fruit[0-4] in Cube's dimension dropdown. Two problems arise:

For above example, only one cube (fruit[2]) would contain both hosts, as item and position match. I'd expect three cubes to contain both hosts, as they got three array items in common.

Describe the solution you'd like

Preferred solution:

In the dropdown menu, offer fruit as a dimension. The operation for arrays would be to slice twice then:

  1. first between hosts/services that possess fruit vs those which don't
  2. then between all occuring array items across all hosts, no matter their respective positions within their arrays. The same implementation would make a nice feature for dictionaries, too.

Fallback solution:

If the method above is not feasible/doable, seeing the actual items in the dropdown and matching them in arbitrary positions of arrays would help, too. I.e. being offered fruit.apple, fruit.banana, fruit.orange etc. instead of fruit[0-4].

Describe alternatives you've considered

We had a close look at using dictionaries instead of arrays, but continue with arrays and Cube behaviour as described above is the preferred and more intuitive/ergonomic solution.

nilmerg commented 2 years ago

Usually a cube shows single-value dimensions, this was the case with the initial version and the IDO and is still the case with non-array variables and Icinga DB.

With Icinga DB are also dictionaries available now. But with their keys and sub-keys offered individually. I don't see why we should change anything here, as each key still refers to a single value. (unless it's an array of course)

Arrays on the other hand are slightly different. They define multiple values for a single dimension on the same object. (host, service) The indices of these values are most of the time not of interest. Icinga DB Web also allows to search for host.vars.fruits[*]=apple to find results where apple is inside the array, no matter where.

In my opinion this is the best solution on how the Cube should handle arrays as well: A dimension can now have multiple values on a single object.

This means, an object can appear multiple times in different cubes on the same pane:

Here are only two hosts involved: (the example in the OP) Screenshot from 2022-08-15 16-32-03

This is what I'd implement. Please comment if that suits your requirements.

bobapple commented 2 years ago

👍

mocdaniel commented 2 years ago

This is what I'd implement. Please comment if that suits your requirements

This is exactly what I imagined. I also share your perspective regarding dictionary entries.