I ran into a big problem while testing out checkmk on my servers.
I want to monitor a lot of Docker-Containers as single Hosts and because I have a lot of different Hosts running the same Docker-Containers I had problems with the rule “Hostname translation for piggybacked Hosts”.
With this rule you can change the name of the piggyback/subdirectory that is created for every single container into something different, and then you can rename the Host as well, so that you have a better structure in your Webinterface.
But like I said if you have a container with the same name as the one you already have, but on a different server, you will get the problem that checkmk can not distinguish these two from another.
And I really don’t want to use a workaround here, for example renaming every directory that contains compose files specific to the used server.
So my question is: Is there a way or a rule I can use to create specific name prefixes for every child host (docker container) my parent Host has? So that I can then distinguish them all from another and monitor each one ?
Here is an example of my current situation:
I have 3 parent hosts: vm-01, vm-02, vm-03.
Every parent host has 2 docker-containers running, they are all called “tools_portainer” and “my_nginx” on all 3 hosts.
I tried creating the hostname translation rule, so that “tools_portainer” is changed to “vm-01_portainer” and “my_nginx” to “vm-01_nginx”.
The problem is that I can now only monitor the two containers from my vm-01, because checkmk can not find my “tools_portainer” and “my_nginx” from vm-02 or vm-02 anymore.
Like I said I am looking for a certain rule or anything similar, that automatically renames the child hosts “tools_portainer” and “my_nginx” to something regarding their parent host.
I would like to have “vm-01_portainer”, “vm-02_portainer” etc.
And I can not change the containers name directly on the server, because that would be an ugly workaround and I use the same .yml file on all servers and it would only make things even more complicated.
This should really be a feature of the dynamic configuration daemon or even the mk_docker.py agent plugin, but currently is not.
You can create multiple rules in “Hostname translation for piggybacked Hosts” for each Docker node (assign every single rule to a differen Docker node host). With this and the regex replacement you can create individual prefixes for the container hosts.
Hey sorry for the late reply, thank you for your suggestion, but I found a nice workaround.
I added “hostname_name” as a third option in the mk_docker.py file where it would otherwise only be “name” or “long”. To get the hostname I simply used os.gethostname().
This can be achieved with a rule in “Hostname translation for piggybacked hosts” for every docker node. There you can add a custom prefix to the container name.
An explicit hostname mapping will not work here. If you want to add a prefix to each piggybacked host you need to use the regular expression option like this:
This rule cannot work as the renaming happens before the label is applied.
I have done this prefix renaming for some kubernetes instances and it is working there as expected.
In my system i restrict the renaming rules to the source host of the data and that’s all.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.