Ad Widget

Collapse

Macro usage in template items

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • blxy
    Junior Member
    • Jul 2020
    • 5

    #1

    Macro usage in template items

    I'm looking for a way to create similar HTTP items for each host in a group. Each of the hosts would need a bit different request body. In this case that would be as simple as using {HOST.HOST} for specific parameters.

    So I have a host group. I add it to the template and create an item for the template, but it seems I can't use default macros for item names, keys or in my case - http requests.

    Only stuff about templates and macros is this from the Template docs: "User macros, {INVENTORY.*} macros, {HOST.HOST}, {HOST.NAME}, {HOST.CONN}, {HOST.DNS}, {HOST.IP}, {HOST.PORT} and {HOST.ID} macros are supported in tags." So it seems I can safely assume that macros are not supported in templates.

    However what would be the best way to do what I have outlined in the beginning of this post? Creating item for each of the hosts is doable at the moment, but I want a central place where I can make edits as needed for these items. Feels like I'm missing something.

    I'm running Zabbix 5.0 btw.

    Edit: wording
  • Answer selected by blxy at 06-02-2024, 14:43.
    blxy
    Junior Member
    • Jul 2020
    • 5

    Thanks for the replies!

    I looked through the page cyber mentioned when I was testing what I described before. That's why I was confused why {HOST.HOST} wasn't working for me when added to the HTTP agents body and so I was looking in other pages for exceptions. However the issue was elsewhere, didn't debug it correctly before starting this thread. Thanks!

    {HOST.HOST} and other macros definitely work in HTTP agent fields.

    "→ HTTP agent type item, item prototype and discovery rule fields: URL, Query fields, Request body, Headers, Proxy, SSL certificate file, SSL key file, Allowed hosts." - where {HOST.HOST} is supported in HTTP agent, from https://www.zabbix.com/documentation...by_location​

    Comment

    • Jason-TELUS
      Junior Member
      • Jan 2024
      • 9

      #2
      if you want to see a sample template that uses the http requests for items have a look at the zookeeper by http template:



      in that template you can see how all the macros are set at the Template level and how the items are created.

      Comment

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

        #3
        Originally posted by blxy
        Only stuff about templates and macros is this from the Template docs: "User macros, {INVENTORY.*} macros, {HOST.HOST}, {HOST.NAME}, {HOST.CONN}, {HOST.DNS}, {HOST.IP}, {HOST.PORT} and {HOST.ID} macros are supported in tags." So it seems I can safely assume that macros are not supported in templates.
        So why do you think, that if a macro is usable in one place it is not usable in some other place.. That quote just says, you can use those macros in tags, it does not say anything about them not being usable in templates.

        Templates are just a collection of items/triggers etc. So look for usage of macros in items and triggers, not in templates..
        https://www.zabbix.com/documentation...ed_by_location Here's the list of macros and where they can be used.. Many (but not all) HOST:* macros can be used in item key parameters.

        Comment

        • blxy
          Junior Member
          • Jul 2020
          • 5

          #4
          Thanks for the replies!

          I looked through the page cyber mentioned when I was testing what I described before. That's why I was confused why {HOST.HOST} wasn't working for me when added to the HTTP agents body and so I was looking in other pages for exceptions. However the issue was elsewhere, didn't debug it correctly before starting this thread. Thanks!

          {HOST.HOST} and other macros definitely work in HTTP agent fields.

          "→ HTTP agent type item, item prototype and discovery rule fields: URL, Query fields, Request body, Headers, Proxy, SSL certificate file, SSL key file, Allowed hosts." - where {HOST.HOST} is supported in HTTP agent, from https://www.zabbix.com/documentation...by_location​

          Comment

          Working...