CMK version:
Checkmk Raw Edition 2.1.0p9
OS version:
Debian 11 on both checkmk server and monitored system
Description of the problem:
I want to implement a custom URL rule via the checkmk API but no matter what I do I get the same error and I have no idea how to resolve it. I’ve made the same rule via the web interface and copied the Rule Value Representation in “value_raw”, but it still doesn’t work and I still have the same error.
Error message:
{
"title": "Bad Request",
"status": 400,
"detail": "These fields have problems: value_raw",
"fields": {
"value_raw": [
"Syntax Error: invalid syntax in 'https://google.com'"
]
}
}
API request:
#!/bin/bash
# NOTE: We recommend all shell users to use the "httpie" examples instead.
HOST_NAME="localhost"
SITE_NAME="monitoring"
API_URL="http://$HOST_NAME/$SITE_NAME/check_mk/api/1.0"
USERNAME="automation"
PASSWORD="redacted"
out=$(
curl \
--request POST \
--write-out "\nxxx-status_code=%{http_code}\n" \
--header "Authorization: Bearer $USERNAME $PASSWORD" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{
"conditions": {},
"folder": "/",
"properties": {
"disabled": false
},
"ruleset": "extra_host_conf:notes_url",
"value_raw": "'https://google.com'",
"conditions": {
"host_name": {
"match_on": [
"test-API"
],
"operator": "one_of"
},
"host_tags": [],
"host_labels": [],
"service_labels": []
}
}' \
"$API_URL/domain-types/rule/collections/all")
resp=$( echo "${out}" | grep -v "xxx-status_code" )
code=$( echo "${out}" | awk -F"=" '/^xxx-status_code/ {print $2}')
# For indentation, please install 'jq' (JSON query tool)
echo "$resp" | jq
# echo "$resp"
if [[ $code -lt 400 ]]; then
echo "OK"
exit 0
else
echo "Request error"
fi