Modifying host alias programmatically

Hi. I want to modify the host alias for a list of hosts. This can be done by editing hosts.mk but I am reluctant to edit that file. I would prefer to use a CLI command, or an API, or something similar but I understand that the alias is not part of the attribute list that can be set for a host.

Have I missed something or is the only way to set the host alias to do this manually via the GUI or by editing configuration files?

Why do you think that?

You can set any host attribute via Checkmk’s REST API.

Unless you mean the ā€œhost nameā€ (that can’t be changed) everything else can be controlled via the API - Looks like you have not tried the API?

1 Like

Hi Robert,

I had tried the API but made some mistake and could not get it to work, so I asked chat GPT who told me that it could not be done because ā€œaliasā€ is not a proper attribute and can only be set via the hosts.mk file. This is clearly wrong as you explained and I have been able to set alias as you suggested.

Your advice, as always, is to the point, useful, and much appliciated. It is clearly also orders of magnitude more reliable than an AI :slightly_smiling_face:

-Arvid

1 Like

Please use at least https://chat.checkmk.com which is trained on the Checkmk documentation.