Ad Widget

Collapse

Setting host tags automatically from data on host vm

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jonrober
    Junior Member
    • Aug 2025
    • 1

    #1

    Setting host tags automatically from data on host vm

    I've seen bits about this here and there but nothing that fully answered the situation, so sorry if this is a repeat.

    Our situation is that we're looking at moving into Zabbix. We already have a number of existing key-value we use to classify our hosts for different reporting systems and we'd like to get them into tags on each host for Zabbix. For example, the main ones are:
    • Stack (application-a, application-b, etc)
    • Stack Level (dev/qa/test/prod)
    • Owning team (operations/infrastructure/etc)
    The source of truth is our puppet build system, and then it can put the data onto each host in whatever format we need. So we can feed data to Zabbix by having Puppet write configuration for UserParameters, HostMetadata, etc. I'm not sure the best way to get this information fed into tags for the host, though.

    For the stack level, I can add the value to HostMetadata (say as HostMetadata=Linux,stack_level:dev) and then make an Autoregistration action to look for "stack_level:dev" and set the stack_level tag for the host to dev. But then I have to have a different action for each value that stack_level can be set to. This can also work for the owning team since there are only a few teams to write actions for, but doesn't scale for stack which can have a large number of possible values. So that method only works if I could pull out a regex to use to set the tag name in an autoregistration action.

    My solution at the moment is to have puppet write a list of tag-value pairs to /etc/zabbix/data/tags.yaml and then have a small python script also on each host that will take that file and call Zabbix via API to update the tags for the host it's running on. Puppet then runs the script every time it has an update for the data file. That works perfectly fine, but I wanted to see if people thought there was a better way before I cement that down as how we handle this case.
Working...