Using Regex for host selection with the REST API

CMK version: 2.3.0p19
OS version: Rocky Linux 8.10

Error message: {“title”: “Bad Request”, “status”: 400, “detail”: “These fields have problems: host_name”, “fields”: {“host_name”: [“‘~^elastic.*$’ does not match pattern ‘[1]+\\Z’.”]}}

I am trying to setup an api request that will put groups of machines into downtime and the documentation seems to say that this can be done with regex but I have not been able to get it to work.

curl -g -u "user:secret" -X 'POST'   'host/site/check_mk/api/1.0/domain-types/downtime/collections/host'   
-H 'accept: */*'    
-H 'Content-Type: application/json'    
-d '{ 
"start_time": "2024-11-11T21:00:00Z", 
"end_time": "2024-11-11T21:38:00Z",  
"comment": "Security updates", 
"downtime_type": "host",  
"host_name":  "~^elastic.*$" }'

{"title": "Bad Request", "status": 400, "detail": "These fields have problems: host_name", "fields": {"host_name": ["'~^elastic.*$' does not match pattern '^[-0-9a-zA-Z_.]+\\\\Z'."]}}

checkmk.shop.wsd/shop/check_mk/api/1.0/ui/#/Downtimes/cmk.gui.openapi.endpoints.downtime.create_host_related_downtime
The downtime section of this says “These endpoints support all [Livestatus filter operators]”
and the filter operators seem to say that you can use Regex if you start with a “~” but if I put any special characters into the host_name filed I get this error.


  1. -0-9a-zA-Z_. ↩︎