Grafana-zabbix: Support nested host groups

Created on 13 Jun 2018  路  7Comments  路  Source: alexanderzobnin/grafana-zabbix

I'm submitting a ...

  • [ ] Bug report
  • [ x] Feature requestdd
  • [ ] Question / Support request

Hi it would be nice to be able to select variuos host groups on the triggers table or select a nested hostgroup weach doesnt show right now for example of nested hostgroup Latvia/Riga

Thanks Great work so far ....

Problems panel datasource feature request

Most helpful comment

I was creating some scripts at work, and looking at the debug from Zabbix frontend, I found that it makes a query using search in the name with the forward-slash (which I'm using in my script):

(
    [output] => Array
        (
            [0] => groupid
        )
    [search] => Array
        (
            [name] => Array
                (
                    [0] => MyRootGroup/
                )
        )
    [searchByAny] => 1
    [startSearch] => 1
)

Makin a little search at plugin code I found that you always get all groups:

https://github.com/alexanderzobnin/grafana-zabbix/blob/94c5059fb1d21f481678b9dc275a3533c39e7c71/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js#L106-L114

And then filters them using the defined regex:

https://github.com/alexanderzobnin/grafana-zabbix/blob/94c5059fb1d21f481678b9dc275a3533c39e7c71/src/datasource-zabbix/zabbix/zabbix.js#L166-L184

Maybe an if using a clause where the value is not a regex and contains a forward-slash can solve the issue?

I'm really sorry for not making up the code and sending a PR, but I'm not a JS/TS developer (more like a Python/PHP one), so at the moment I only can share my logic.

All 7 comments

You can select multiple groups by using regex.

Thanks got it working i leave an example here if some one needs it.
Lets say you have two groups Latvia and Riga and want to filter only the hosts of them
you would write on the box /Latvia|Riga/ and it will give you the thes hosts of those groups only.

Problem with nested groups in variables, when i create a using "{*}" to get all groups isn't bring a first nest.

+1

to add my 2 cents here

i have nested host groups, in zabbix if i show all hosts in host group Parent/Child/1

i see all hosts in that and its sub groups .e.g. Parent/Child/1/Access

but in Grafana i see nothing because all of the hosts are in the lowest level hostgroup only, they are not directly in Parent/Child/1

i would at least loosely to expect behaviour similar to zabbix

i tried the workaround of /Latvia|Riga/ however this appears not to work because of the presense of / in the hostgroup name for nested, i also tried escaping and appears not to work - debugging if this is specifically because of that or my query is now large because its a LOT of devices (some 650)

I was creating some scripts at work, and looking at the debug from Zabbix frontend, I found that it makes a query using search in the name with the forward-slash (which I'm using in my script):

(
    [output] => Array
        (
            [0] => groupid
        )
    [search] => Array
        (
            [name] => Array
                (
                    [0] => MyRootGroup/
                )
        )
    [searchByAny] => 1
    [startSearch] => 1
)

Makin a little search at plugin code I found that you always get all groups:

https://github.com/alexanderzobnin/grafana-zabbix/blob/94c5059fb1d21f481678b9dc275a3533c39e7c71/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.js#L106-L114

And then filters them using the defined regex:

https://github.com/alexanderzobnin/grafana-zabbix/blob/94c5059fb1d21f481678b9dc275a3533c39e7c71/src/datasource-zabbix/zabbix/zabbix.js#L166-L184

Maybe an if using a clause where the value is not a regex and contains a forward-slash can solve the issue?

I'm really sorry for not making up the code and sending a PR, but I'm not a JS/TS developer (more like a Python/PHP one), so at the moment I only can share my logic.

Any way I can buy someone some beer/coffee/whatever to implement this change?

@mike-sol just try to put the full group if it's just one. If it's more, I'd just put it in a Regex like this: 'customer_a\/servers\/.*' For me, using this way works just fine.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Akabell95 picture Akabell95  路  8Comments

xiaoxue999 picture xiaoxue999  路  3Comments

felipemvieira picture felipemvieira  路  6Comments

heyrod picture heyrod  路  7Comments

samyscoub picture samyscoub  路  6Comments