Werk #9652 · Nov 28, 26
Add an experimental REST API for automating appliance administration
The web configuration now provides a REST API so that a fleet of appliances can be administered from scripts and automation instead of the web interface. It covers routine maintenance tasks for the devices: Installing and removing Checkmk versions, creating, configuring, updating, controlling and removing monitoring sites, staging and installing firmware updates, changing the device settings (e.g. time zone, DNS, NTP, syslog forwarding and outgoing mails) and rebooting or shutting down the device.
The REST API is disabled by default. To use it, enable it on the "REST API (experimental)" page of the web configuration.
We support the use cases of the REST API from the start and try our best to provide a well usable API right away. As we collect first experiences and feedback, we will learn more about what is needed. So for the time being, the API is experimental: It may still change incompatibly, and parts of it may be removed. Build your automations, try out what the API offers and let us know what you need. Depending on the feedback, we will declare the whole API or parts of it as stable.
Clustered appliances can be updated one node after the other: The API reports the cluster state as the cluster page shows it, puts nodes into standby and back online, fails over to the other node and cleans up failed resources. For firmware updates that change the operating system, it can disconnect and reconnect the cluster.
The API also reports the state of the backup jobs configured in the web configuration and starts a backup job when requested, for example by a script that takes a backup before it updates the device. The API does not start backups on its own.
The API focuses on routine maintenance and the other core tasks of administering appliances. We do not plan to make the full functionality of the web interface available through the REST API in the foreseeable future.
To start using it, create an API token on the "REST API (experimental)" page. The token secret is shown only once, directly after creation - store it safely, as it grants full administrative access to the device, just like the device password.
Authenticate every request with the token as a bearer token, for example:
curl -H "Authorization: Bearer <token>" \
https://<device>/webconf/api/v1/info
For scripts and automation, a Python client is available on PyPI. It
contains the library cmk.appliance.client and the command line client
cmk-appliance, which offers one command per operation of the API:
pip install cmk-appliance-client
CMK_APPLIANCE_TOKEN=<token> cmk-appliance --url https://<device> info
The client is released independently of the firmware and supports every appliance with this REST API. When a device's firmware lacks a feature the client knows, it names the API revision the feature needs and asks to update the firmware, instead of failing with an unspecific error. Its changes are listed as werks of their own: https://werks.checkmk.com/?product=cma_client
The API is versioned under /webconf/api/v1/. Its full specification is
served as an OpenAPI document at /webconf/api/v1/openapi (readable
without a token) and is linked from the "REST API (experimental)" page.
Every response names the revision of the API in the API-Revision
header: It increases when a firmware release extends the API, so
automation can tell which features a device offers. The API-Status
header names whether the API is experimental, stable or deprecated.
Details
- Class:
- New Features
- Level:
- Major
- Component:
- Firmware
- Versions:
- 1.7.28Not yet released