JSON-Problem with objects/services

Iam trying to get a table of all vars.notification Dicitionaries:

This one is fine but contains not the host/service pair:

curl -s -k -u $APILOGIN:$APIPASSWORD -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services' | jq '.results[].attrs.vars.notification'

Thanks in advance

Maybe joins can help here.

Its jq related. I found a solution, but I dont claim greater depth understanding:

curl -s -k -u $APILOGIN:$APIPASSWORD -H 'X-HTTP-Method-Override: GET' -X POST 'https://localhost:5665/v1/objects/services?' | jq '.results[].attrs | { __name: .__name, notification: .vars.notification }'

I get such objects:

{
  "__name": "myhost.company.tld!ping4",
  "notification": {
    "mail": {
      "groups": [
        "icingaadmins"
      ]
    }
  }
}

This is a good starting point for a table.

1 Like