[ZBX-17619] User macros not working for HTTP agent request body Created: 2020 Apr 23  Updated: 2025 Mar 20  Resolved: 2020 Apr 29

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 4.0.19
Fix Version/s: None

Type: Problem report Priority: Trivial
Reporter: Shane Assignee: Eduards Matuls (Inactive)
Resolution: Commercial support required Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Ubuntu 18, Postgres Database


Attachments: PNG File Screen Shot 2020-04-23 at 11.58.45 am.png     PNG File Screen Shot 2020-04-23 at 11.58.55 am.png     PNG File Screen Shot 2020-04-23 at 12.00.54 pm.png     PNG File Screen Shot 2020-04-23 at 12.08.27 pm.png     PNG File Screen Shot 2020-04-29 at 5.54.40 pm.png     PNG File Screen Shot 2020-04-29 at 5.56.11 pm.png    

 Description   

Steps to reproduce:

  1. Create an item with type HTTP agent
  2. Paste JSON request body into 'Request body' section
  3. Change a value in the body to a user macro
  4. Monitor response

Result:

The result I get from the endpoint when I use a macro is blank or '{}', suggesting that the JSON data posted is valid, but the "url" value is incorrect and does not match any records in Google Safe Browsing API.

If I change my '{$URL}' macro within the JSON body to the exact text I put in my user macro, it works and the responseI get is a match from Google Safe Browsing API.

I'll include a screenshot of both the JSON body including the macro, as well as a screenshot of the straight text.

I'll also include a screenshot of latest data, which shows where I change it to use the straight text URL and it begins to work.

Expected:
I expect the macro to send the url in place of the macro unformatted and result in a match.

 

I've tried:

Finding logs within the Google Safe Browsing URL that show what the request body contains, but I don't think this is possible.

I've also tried finding logs of what Zabbix is actually sending, but couldn't find any way to do this either after a lot of searching.

 

I've tried sending as 'Raw data' as well as 'JSON data' within the item config.

 

If there is a way to debug this within Zabbix itself, I'd love to get some more info on what it's actually sending in place of the macro placeholder.



 Comments   
Comment by Eduards Matuls (Inactive) [ 2020 Apr 29 ]

Hello!

Thank you for reporting the issue. Can you please send screenshots of your item configuration and macro defined?

Regards,
Eduards

Comment by Shane [ 2020 Apr 29 ]

Thanks for replying Eduards,

Here's some screenshots:

Comment by Eduards Matuls (Inactive) [ 2020 Apr 29 ]

Hello!

I've tried to reproduce the issue and I could not. I've installed Zabbix 4.0.19 on Ubuntu 18 with postgres DB suport. Used HTTP agent to get information from local API. My JSON is:

{
    "jsonrpc": "2.0",
    "method": "host.get",
    "params": {
        "filter": {
            "host": "{$TEST_SERVER_NAME}"
        }
    },
    "auth": "d881de82305ed43ee165bcf1ef2d28fa",
    "id": 1
}

Here I passed filter value as a macro. And it worked correctly for me.

Please be advised that this section of the tracker is for bug reports only. The case you have submitted can not be qualified as one, so please reach out to [email protected] for commercial support or consultancy services. Alternatively, you can also use our IRC channel or community forum (https://www.zabbix.com/forum) for assistance. With that said, we are closing this ticket. Thank you for understanding. 

Regards,
Eduards

 

Comment by Nicolas Urioste [ 2025 Mar 20 ]

Better late than never.

I'm using Zabbix 7.2 and phased the same issue.

What worked for me is to include the macro without the double quotation mark and on the value of the macro include said double quotation mark.

In my case I was working with an API (I can't share it do to security concerns) that required a range of time, also on grapql, and the following solved the issue:

Macro Value
{$TO} "2025-03-12T16:03:29.043Z"
{$FROM} "2025-03-05T16:03:29.043Z"

So in the body it would look something like this:

    "variables": {
        "from": {$TO},
        "to": {$FROM}
    } 
Generated at Mon Jun 30 09:39:45 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.