Ad Widget

Collapse

Zabbix template tags inheritance not working??

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • vsergione
    Junior Member
    • Oct 2023
    • 28

    #1

    Zabbix template tags inheritance not working??

    Hello zabbixers!

    As far as I understood tags configure on the template level should be inherited by the host, but most important by the triggered events. So let's assume the following situation:
    I have create a template DataCenter/Rome. On this template I have configured a tag LOCATION:ROME. There are no items or triggers defined in this template.
    I have created a host named test-server with some test items and test triggers and I have assigned the above template to this host.
    If there are any alarms triggered by this host, I would expect to see those alarms tagged with LOCATION:ROME.



    So, the first question is: is this the expected behaviour, have I understood it right? If yes, then why I don't see that tag on the raised alarm??
    Last edited by vsergione; 06-03-2025, 12:44.
  • Answer selected by vsergione at 06-03-2025, 22:17.
    Brambo
    Senior Member
    • Jul 2023
    • 245

    Template item/ triggers tags are passed through. Only Template tags (the ones not on any item/ trigger) are purely for interface (filtering) / api usage handy.
    When a problem is created is has: Host > item > trigger tags. So to put that all in an image: Click image for larger version

Name:	image.png
Views:	409
Size:	96.8 KB
ID:	500092

    Comment

    • vsergione
      Junior Member
      • Oct 2023
      • 28

      #2
      No more need to answer... ChatGPT knows everithing... It's f...g scarry this thing. So here is the full answer.

      No, the tags defined at the template level in Zabbix are not inherited by the alarms (problems) raised for a host that has the template assigned. How Tags Work in Zabbix:
      1. Template Level Tags:
        • These tags exist at the template level but do not automatically propagate to hosts or triggers.
        • They are useful for organizing templates but do not impact alarms.
      2. Host Level Tags:
        • If a host has tags defined, these tags can be used in triggers and actions.
      3. Trigger Level Tags (Most Important for Alarms):
        • These are the tags that get attached to alarms (problems).
        • If a trigger within the template has specific tags defined, those tags will be assigned to any problem generated by that trigger, regardless of whether the host has any tags.
      Conclusion:
      • Alarms (problems) only inherit tags from triggers, not from the template itself.
      • If you want specific tags to be associated with alarms, define them on the triggers inside the template, not on the template itself.

      Comment

      • Brambo
        Senior Member
        • Jul 2023
        • 245

        #3
        Template item/ triggers tags are passed through. Only Template tags (the ones not on any item/ trigger) are purely for interface (filtering) / api usage handy.
        When a problem is created is has: Host > item > trigger tags. So to put that all in an image: Click image for larger version

Name:	image.png
Views:	409
Size:	96.8 KB
ID:	500092

        Comment

        • cyber
          Senior Member
          Zabbix Certified SpecialistZabbix Certified Professional
          • Dec 2006
          • 4806

          #4
          Good pic!
          Your host does not inherit tags from template, if it has no items or triggers.
          • with tagged templates - any host problem (created by triggers from the template) will inherit the template tags;
          • with tagged hosts - any host problem will inherit the host tags;
          • with tagged items/web scenarios - any item/web scenario problem will inherit the item/web scenario tags;
          • with tagged triggers - any problem created by the trigger will inherit the trigger tags.

          Comment

          • vsergione
            Junior Member
            • Oct 2023
            • 28

            #5
            To be honest I find this a little bit frustrating.

            We have this situation where we manage ~5000 hosts which are grouped in different locations. For each location we have a name, a site ID and a team ID. These values need to be configured as tags because later on in the alarm handling process somebody is gonna take care of it based on these IDs. Currently I need to configure each host individually with these tags. Of course, this is not done manually, but sometimes we make errors, like swapping the IDs, mistyping the name... So it would be much easier and less error-prone (or at least easier to correct) to be able to set these tags on the template level and inherit them on the host level in a similar manner like the macros are inherited by hosts from the templates.

            I've made a feature request to Zabbix to have this implemented. Hopefully there will be more people to find this useful so it gets pushed in the planned features.

            Comment

            • Brambo
              Senior Member
              • Jul 2023
              • 245

              #6
              vsergione so setting up 1 generic template tag would have solve this? Then all host would have the same tag?
              Maybe have a look in the mass update feature on the host page? You can select all host which has a certain linked template

              Or otherwise the API is a powerful tool as well.

              Comment

              • vsergione
                Junior Member
                • Oct 2023
                • 28

                #7
                Originally posted by Brambo
                vsergione so setting up 1 generic template tag would have solve this? Then all host would have the same tag?
                Maybe have a look in the mass update feature on the host page? You can select all host which has a certain linked template

                Or otherwise the API is a powerful tool as well.
                Maybe I was not clear enough. We did this job already using the API. We've even developed a tool to make our job easier (https://github.com/vsergione/zbxwizz) But there was a lot of data which had to be processed manually: identify the owners of the equipment, find out device type (was not always clear). Given the shear amount of data to be processed we made mistakes: mix up the IDs, typos in the site name, miss some of the devices.

                See my full description of our use case in this post: https://www.zabbix.com/forum/zabbix-...145#post500145

                Comment

                • cyber
                  Senior Member
                  Zabbix Certified SpecialistZabbix Certified Professional
                  • Dec 2006
                  • 4806

                  #8
                  I think what was meant is, that they would have a template (per site) with just tags in it... every host in that site would get it and from there those tags would populate through host... But tags do not inherit like that...
                  I would populate host inventory and use inventory macros in template. Actually we are doing it. Daily sync from CMDB to update info etc...

                  Comment

                  • vsergione
                    Junior Member
                    • Oct 2023
                    • 28

                    #9
                    Originally posted by cyber
                    I think what was meant is, that they would have a template (per site) with just tags in it... every host in that site would get it and from there those tags would populate through host... But tags do not inherit like that...
                    I would populate host inventory and use inventory macros in template. Actually we are doing it. Daily sync from CMDB to update info etc...
                    That's a nice idea but I would still end up to modifying all the hosts to use the macros in the inventory. I would also have to update the Service Now integration script to collect those values from the inventory instead from tags and so on, and eventually any other integration that it might use those values. No, I'm not afraid of more work, but what I am afraid is of loosing track of all the places which need changes.

                    Meanwhile we came up with a different solution: a cron job which synchronizes once per day the tags for all the hosts part of those site groups.

                    Comment

                    • cyber
                      Senior Member
                      Zabbix Certified SpecialistZabbix Certified Professional
                      • Dec 2006
                      • 4806

                      #10
                      nonono... You don't need to modify all the host macros... you don't even need host macros. You can set macros in template for example: site -> {INVENTORY.LOCATION}. then populating inventory is either by syncing with CMDB or letting some item find it from host and populate... But you can use one template for all sites as it has no hardcoded values. All tag values are taken from that particular hosts inventory

                      Comment

                      • jhboricua
                        Senior Member
                        • Dec 2021
                        • 113

                        #11
                        We achieve this with Chef by creating a 'hostmetadata.conf file in the zabbix_agent2.d directory with specific keywords. Then we use autoregistration actions that assign tags to the hosts based on specific host metadata keywords, such as environment, location, appt_tier, application_name, etc.

                        This is on Zabbix 7 which now allows tagging using autoregistration actions.

                        Comment

                        Working...