Value should be a JSON object error in Zabbix

I have the following script:-

#!/bin/bash

echo "{"
echo "\"data\":["

grep -hoR server_name.* /etc/nginx/sites-enabled/|sed 's/[^ ]* //'|sed 's/.$//'|awk -F"/" '{ print "{\"{#URL}\":\""$1"\"}," }'| head -c -2

echo "]"
echo "}"

This is set up as a UserParameter on the client

UserParameter=url.discovery[*],/etc/zabbix/scripts/urls.sh

and gives results such as

{
"data":[
{"{#URL}":"example.com"}]
}

I then have a discovery rule configured in zabbix like so:-

Key is url.discovery[*]

Item prototype is web.page.regexp[{#URL},,,test,,]

However,I get the following error

Value should be a JSON object error

I’ve checked the JSON result on https://jsonlint.com/ and it says its valid.

How can I resolve this?

Thanks
Stuart

Answer

Probably it’s a Zabbix issue – https://support.zabbix.com/browse/ZBX-12195

Attribution
Source : Link , Question Author : user2099762 , Answer Author : Jan Garaj

Leave a Comment