Ad Widget

Collapse

Unable to use two templates on hosts where both use systemd.unit.discovery

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • digdilem
    Junior Member
    • Feb 2025
    • 2

    #1

    Unable to use two templates on hosts where both use systemd.unit.discovery

    I have a master template for linux machines that I want to attach the Systemd by Zabbix Agent 2 template to.

    This works great for most machines, but we have two small groups that have existing templates which use systemd.unit.discovery. Zabbix blocks me from linking this template to the global one because of the machines that already use it, giving an error like:

    Cannot inherit LLD rule with key "systemd.unit.discovery[service]" of template "Linked_systemd" to host "example_hostname", because an LLD rule with the same key is already inherited from template "Haproxy_Monitoring".

    I've narrowed it down to the Discovery rules for each template, which use "systemd.unit.discovery[service]" provided by zabbix agent 2. The haproxy template above indeed uses this as well, as does another we're using.

    I've tried renaming every key I can find within the discovery rule, and even exported the yaml for the entire template and changed all the uuids within it to newly generated ones and reimporting in case those were what was duplicated, but the errors persist.

    Clearly I'm misunderstanding some core concept here as surely two templates must be able to ask the agent what systemd services are running - can someone please point out where I might be going wrong?
  • cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    #2
    Item keys have to be unique, so it does prevent you from having 2 items with same key.
    If one template defines "systemd.unit.discovery[service]", then in other one you can leave it as "systemd.unit.discovery[]​". That "service" is anyway a default value, which does not have to be defined there... If you have 3rd template also, you can use "systemd.unit.discovery["service"]​".

    Comment

    • Brambo
      Senior Member
      • Jul 2023
      • 245

      #3
      Either strip down the second template to really use it as an appendix template.
      Or included in your original and maybe use filter macro to by default exclude the creation of a certain item by discovery and by changing the macro on host level you can include it.
      Either way is possible but like said above my, an item key needs to be unique per host.
      (a template can be seen as a host without interface, within a template you also cant create duplicated item keys)

      Comment

      • digdilem
        Junior Member
        • Feb 2025
        • 2

        #4
        Thanks both for your help. I'll be trying this again soon and your replies have helped me to understand what's going on.

        Comment

        Working...