My intent is to retrieve these labels by using the REST API, but I haven’t been able to find any solutions yet.
I don’t see any dedicated endpoint in the documentation, nor I can find it in others.
The only way I’ve found is to recall the ruleset /domain-type/rule/collections/all?ruleset_name=service_label_rules and host_label_rules, but that’s limiting and way more complicated to integrate as I would need to recreate some other association logics compared to just obtaining the label.
In previous versions of CheckMK I would have been able to export a CSV and obtain the labels from the WebAPI, but since its deprecation I don’t know where to look.
I need to get the labels from both hosts and services, as there’s both host labels and service labels rules ^^
The endpoint you gave me should return the host labels, but it’s not, and I have no idea how I could recall the service labels.
Hi MarcS,
just a couple things that I want to note:
The first method will only return explicit rules of a host, that’s a nono for me
The second method is the original “solution” I came up with, but querying the ruleset directly is also a bigger nono for me. I’d have to parse the entire ruleset, adapt the regex to the explicit services, and do additional API calls to retrieve for example the host tag a service belongs to. I’d basically have to rewrite the entire association logic that’s already in CheckMK.
After banging my head to the wall for so long, I’ve found a last resort solution that doesn’t involve using the REST API.
I’m going to send a POST request by recalling the login.py and passing inside the direct link that will export a service/host stats in CSV, that’s where I can easily grab the host/service label and call it a day. The last thing that I have to do is to make a function that will convert the hosts and services names to an encoded URL and pass it inside another function:
I wish it were possible to do it with the REST API, but I think this will do for now.
I’m leaving this issue open for the time being, as I’d like to know what the devs think about this situation, and perhaps plan some of those mentioned features in a future release of CheckMK.
I think you can request all labels by using livestatus requests (Statusdaten abrufen via Livestatus). You can ask for the column “labels” there. Haven’t tried it mysself, but should work.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.