enigma619
(Enigma)
September 1, 2021, 11:25am
1
Hi
I’ve a quick question about API / curl call
with this curl:
curl -k -s -u admin:BLABLABLA -H 'X-HTTP-Method-Override: GET' -X POST 'https://127.0.0.1:5665/v1/objects/hosts' -d '{ "filter": "host.vars.rack == \"A01\"", "pretty": true }'
I can retrieve all my hosts which are located on rack A01 (rack is a field I’ve setted on my icinga confguration).
I want to do the same curl but with host.vars.rack like A0* (to retrieve all hosts with rack like A0*) but it doesnt work. Itried with host.vars.rack >= \A01\ but then, No objects found.
If I use icingaweb it works with:
https://icingaURL/monitoring/list/hosts?_host_rack>=A0*
Do you have any idea how I can do with my curl call to do the same please?
Thanks
1 Like
I would check out advanced filters in the docs.
enigma619
(Enigma)
September 1, 2021, 1:19pm
3
I’ve already checked this page with no success.
Thanks
Can’t fix that then; using the above link I’m able to obtain exactly what you want to do (using a different custom var of course)
enigma619
(Enigma)
September 1, 2021, 2:22pm
5
So if you use a similar curl like:
curl -k -s -u admin:BLABLABLA -H 'X-HTTP-Method-Override: GET' -X POST 'https://127.0.0.1:5665/v1/objects/hosts' -d '{ "filter": "host.vars.rack >= \"A0*\"", "pretty": true }'
it works?
“>=” instead of “==”
A0* instead of A01
enigma619
(Enigma)
September 2, 2021, 8:48am
6
If you have an example when it works on your side perhaps please?
enigma619
(Enigma)
September 2, 2021, 10:55am
7
succedeed with:
curl -k -s -u admin:WWWWW -H 'X-HTTP-Method-Override: GET' -X POST 'https://127.0.0.1:5665/v1/objects/hosts' -d '{ "filter": "match(\"A*\", host.vars.rack)", "pretty": true }'
1 Like