Icinga2: API-filter for specific service

79 Views Asked by At

I try to get every services that are assigned to a specific host.

Here is what I have.

CMD

curl -k -s -u api:api 'https://localhost:5665/v1/objects/services?attrs=host_name&attrs=state'

OUTPUT

{
  "results": [
    {
      "attrs": {
        "host_name": "MyHostA",
        "state": 1
      },
      "joins": {},
      "meta": {},
      "name": "MyHostA!procs",
      "type": "Service"
    },
    {
      "attrs": {
        "host_name": "MyHostB",
        "state": 1
      },
      "joins": {},
      "meta": {},
      "name": "MyHostB!http",
      "type": "Service"
    }
  ]
}

I am not able to define a filter that only gives my the service of MyHostA.

My trials

curl -k -s -u api:api 'https://localhost:5665/v1/objects/services?attrs=host_name&filter=service.host_name==MyHostA'

curl -k -s -u api:api 'https://localhost:5665/v1/objects/services?attrs=host_name&filter=host_name==MyHostA'

curl -k -s -u api:api 'https://localhost:5665/v1/objects/services?attrs=host_name&filter=match(MyHostA,host_name)

curl -k -s -u api:api 'https://localhost:5665/v1/objects/services?attrs=host_name&filter=match(MyHostA,service.host_name)

All of them result in

{
  "error": 404,
  "status": "No objects found."
}

Also tried to set MyHostA betweem " but that results to HTTP-500 (unhandled exception).

Any ideas ho to get my filter work??

0

There are 0 best solutions below