CMK version: 2.2.0p12 (cre)
OS version: Debian GNU/Linux 11 (bullseye)
Error message: (no error)
I am trying to retrieve the downtimes via the rest API, however there appears to be no filtering of the output by the query I specified. In the example below, I am trying to restrict the response by hostname and the comment on the downtime - but I get back data for all hosts / all downtimes.
Oddly, despite “site_id” being a required paramter (according to the docs), output is not filtered by this either in my code.
How can I restrict the returned data?
HDR="Content-Type: application/json"
AUTHHDR="Authorization: Bearer ${CMKUSER} ${CMKSECRET}"
FILTER='{"op": "and", "expr": [{"op": "~", "left": "comment", "right": "banana"}, {"op": "=", "left": "host_name", "right": "cmk-satellite.southwold.net"}]}'
CMKSITE='southwold'
RES=$( curl -i -w "\n%{http_code}" -X "GET" \
--data-urlencode 'downtime_type=both' \
--data-urlencode "site_id=${CMKSITE}" \
--data-urlencode "query=${FILTER}" \
"${CMKURL}/domain-types/downtime/collections/all" \
-H "Accept: application/json" -H "$HDR" -H "$AUTHHDR"
(truncated output below)
"domainType": "downtime",
"id": "4",
"title": "Downtimeforservice:OMDsatelliteperformance",
"members": {},
"extensions": {
"site_id": "southwold",
"host_name": "cmk-satellite.southwold.net",
"author": "cmkadmin",
"is_service": "yes",
"start_time": "2023-11-28T10:43:00+00:00",
"end_time": "2023-11-28T11:03:00+00:00",
"recurring": "no",
"comment": "testinggetmaintenance"
}
},
{
"domainType": "downtime",
"id": "5",
"title": "Downtimeforservice:SystemdSocketSummary",
"members": {},
"extensions": {
"site_id": "southwold",
"host_name": "cmk-satellite.southwold.net",
"author": "cmkadmin",
"is_service": "yes",
"start_time": "2023-11-28T10:43:00+00:00",
"end_time": "2023-11-28T11:03:00+00:00",
"recurring": "no",
"comment": "testinggetmaintenance"
}
},
{
"domainType": "downtime",
"id": "6",
"title": "Downtimeforservice:SystemdServiceSummary",
"members": {},
"extensions": {
"site_id": "satellite",
"host_name": "glue.southwold.net",
"author": "cmkadmin",
"is_service": "yes",
"start_time": "2023-11-28T10:48:46+00:00",
"end_time": "2023-11-28T11:08:46+00:00",
"recurring": "no",
"comment": "testinggetmaintenance"
}
}