sni / grafana-thruk-datasource

Use Thruks Rest API within Grafana
MIT License
13 stars 2 forks source link

Feature Request: transmit checkmk labels/values #42

Open dago158 opened 9 months ago

dago158 commented 9 months ago

Since releases 2.x, CheckMK has introduced Labels to complements Tags in hosts and services definition.

In the actual plugins, the tags are accessible trough _TAGS but labels are not.

I'll appreciate if labels could be made accessible the same way (unfortunately, my coding skills aren't good enough for me to delve in the code and propose a patch)

sni commented 9 months ago

Thanks for your idea. Since i am not using cmk anywhere, i flagged this issue, so maybe someone else wants to have a look at this.

dago158 commented 9 months ago

Thks. I've started to look and not sure wether it's in this grafana plugin or in the main thruk code that a change would be needed. Maybe without some pointers I could sort it out by myself

sni commented 9 months ago

can those lables be queried via livestatus?

dago158 commented 9 months ago

Yes, using the CLI, the livestatus query will give labels columns just the same as tags

for example : lq "GET hosts\nColumns: name address host_tags tags host_labels labels"

gds0043;10.1.2.11;agent|no-agent,ping|ping,ip-v4|ip-v4,snmp_ds|no-snmp,site|foo,address_family|ip-v4-only,overcrowded|0,networking|lan,criticality|production,piggyback|auto-piggyback;team|IT,cmk/site|foo,project|datastore

lq "GET services\nColumns: host_name display_name host_tags tags host_labels labels"

gds0043;PING;agent|no-agent,ping|ping,ip-v4|ip-v4,snmp_ds|no-snmp,site|foo,address_family|ip-v4-only,overcrowded|0,networking|lan,criticality|production,piggyback|auto-piggyback;agent|no-agent,ping|ping,ip-v4|ip-v4,snmp_ds|no-snmp,site|foo,address_family|ip-v4-only,overcrowded|0,networking|lan,criticality|production,piggyback|auto-piggyback;team|MIT,cmk/site|foo,project|datastore;team|MIT,cmk/site|foo;owner/Xxxxxy

All columns related to tags/labels :

OMD[foo]:~$ lq "GET columns\nFilter: table = hosts" | grep 'tag' A list of the names of the tags;tag_names;hosts;list A list of the values of the tags;tag_values;hosts;list A dictionary of the tags;tags;hosts;dict

OMD[foo]:~$ lq "GET columns\nFilter: table = hosts" | grep 'label' A list of the names of the labels;label_names;hosts;list A list of the names of the label sources;label_source_names;hosts;list A list of the values of the label sources;label_source_values;hosts;list A dictionary of the label sources;label_sources;hosts;dict A list of the values of the labels;label_values;hosts;list A dictionary of the labels;labels;hosts;dict

OMD[foo]:~$ lq "GET columns\nFilter: table = services" | grep 'tag' A list of the names of the tags;host_tag_names;services;list A list of the values of the tags;host_tag_values;services;list A dictionary of the tags;host_tags;services;dict A list of the names of the tags;tag_names;services;list A list of the values of the tags;tag_values;services;list A dictionary of the tags;tags;services;dict

OMD[foo]:~$ lq "GET columns\nFilter: table = services" | grep 'labels' A list of the names of the labels;host_label_names;services;list A list of the values of the labels;host_label_values;services;list A dictionary of the labels;host_labels;services;dict A list of the names of the labels;label_names;services;list A list of the values of the labels;label_values;services;list A dictionary of the labels;labels;services;dict

sni commented 9 months ago

So it's implemented as extra columns and not as custom variables. So you could extend the column lists in the Livestatus.pm of Thruk itself.

dago158 commented 8 months ago

looks like help_wanted is still true. By adding "labels" (or labels host_labels for services), I only have object.

I didn't really find where the "_TAGS" and other checkmk specific elements like "_ADDRESSES_4" or "_ADDRESS_4" are defined in thruk or its grafana plugin