[ZBX-21997] JSON Path malfuction after ZBXNEXT-8040, ZBXNEXT-8009 Created: 2022 Nov 29  Updated: 2024 Apr 10  Resolved: 2022 Dec 22

Status: Closed
Project: ZABBIX BUGS AND ISSUES
Component/s: Server (S)
Affects Version/s: 6.0.11
Fix Version/s: 6.0.12rc1, 6.2.6rc1, 6.4.0beta5, 6.4 (plan)

Type: Problem report Priority: Blocker
Reporter: LivreAcesso.Pro Assignee: Andris Zeila
Resolution: Fixed Votes: 0
Labels: jsonpath, lld, regression
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Debian GNU/Linux 10.5
Linux zabbix 5.10.0-19-amd64 #1 SMP Debian 5.10.149-2 (2022-10-21) x86_64 GNU/Linux

Package: zabbix-server-pgsql
Version: 1:6.0.11-1+debian11


Attachments: File LLD.json     PNG File image-2022-11-29-13-01-18-620.png     PNG File image-2022-12-02-08-51-27-658.png     PNG File image-2022-12-02-09-07-08-454.png     File out.json    
Issue Links:
Causes
caused by ZBXNEXT-8040 JSON Preprocessing improvements Closed
Duplicate
Team: Team A
Sprint: Sprint 94 (Nov 2022), Sprint 95 (Dec 2022)
Story Points: 1

 Description   

It works until 6.0.10

$.registros..data

LLD from preprocessing from Geogrid' API JSON object stop woking:

– cannot extract value from json by path "$.registros..dados": invalid object format, expected opening character '{' or '[' at: '
– {"registros":[{"dados":{"id":"846682","item":"terminal","marcador":"terminal","latitude":"-23.21831912","longitude":"-46.86608225","sigla":"vza 21-01","label":null,"responsavel":null,"ddd
```

JSON file attached.

JSON file and query is valid by https://jsonpath.com/



 Comments   
Comment by Andris Zeila [ 2022 Nov 29 ]

In the logs the json seems to have newline character at the beginning, while in the attached file there is none. Could you please confirm that the attached json is the same? If the problem is with leading whitespace, then as a temporary workaround you can insert trim preprocessing step before jsonpath.

Comment by LivreAcesso.Pro [ 2022 Nov 29 ]

Thanks.

I think this is the problem:

Comment by LivreAcesso.Pro [ 2022 Nov 29 ]

But, LLD preprocess don't allow TRIM functions.

Comment by LivreAcesso.Pro [ 2022 Nov 29 ]

Worked with JavaScript preprocessing before JSON Path:

const k = JSON.parse(value);
const s = JSON.stringify(k);
return s;
Comment by Todd Blake [ 2022 Nov 30 ]

I'm coming up with the same issue.  I manually used curl to retreive the same JSON, and jq parses it without issue.  I don't see any extra line breaks before the beginning of the JSON code.  For what it's worth there's no EOL either.

  1873:20221128:122447.966 discovery rule "splunk.lan:splunk.license.json" became not supported: Invalid discovery rule value: cannot parse as a valid JSON object: invalid JSON object value starting character at: '],"window_period":30,"max_retention_size":0,"allowedRoles":],"quota":10737418240,"creation_time":1665558000,"expiration_time":1681196399,"max_violations":5,"relative_e

I'd hoped maybe it was just some JSON that needed cleaning so i tried the aforementioned workaround using javascript to no avail.

EDIT:  I attached the json output.

[root@zabbix zabbix]# curl -u 'XXXXXXXX:XXXXXXXX' -sk 'https://splunk.lan:8089/services/licenser/licenses?output_mode=json'
{{
{"links":\{"create":"/services/licenser/licenses/_new"}
,"origin":"https://splunk.lan:8089/services/licenser/licenses","updated":"2022-11-30T10:54:10-05:00","generator":{"build":"82c987350fde","version":"9.0.1"},"entry":[{"name":"CE1E38B6EC08536DC8E732DE57C2A01E3342E2AE98E4839BAB1910585894FF1B","id":"https://splunk.lan:8089/services/licenser/licenses/CE1E38B6EC08536DC8E732DE57C2A01E3342E2AE98E4839BAB1910585894FF1B","updated":"1969-12-31T19:00:00-05:00","links":
{"alternate":"/services/licenser/licenses/CE1E38B6EC08536DC8E732DE57C2A01E3342E2AE98E4839BAB1910585894FF1B","list":"/services/licenser/licenses/CE1E38B6EC08536DC8E732DE57C2A01E3342E2AE98E4839BAB1910585894FF1B","edit":"/services/licenser/licenses/CE1E38B6EC08536DC8E732DE57C2A01E3342E2AE98E4839BAB1910585894FF1B"}
,"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":
{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]}
,"removable":false,"sharing":"system"},"content":{"add_ons":{"itsi":{"guid":"942ECDCE-2D13-4787-B584-BF581C5F2BA0","size":"10"}},"allowedRoles":[],"assignableRoles":[],"creation_time":1665558000,"disabled_features":[],"eai:acl":null,"expiration_time":1681196399,"features":["Acceleration","AdvancedSearchCommands","AdvancedXML","Alerting","ArchiveToHdfs","Auth","CanBeRemoteMaster","ConditionalLicensingEnforcement","CustomRoles","DeployClient","DeployServer","DistSearch","FwdData","GuestPass","KVStore","LDAPAuth","LocalSearch","MultifactorAuth","MultisiteClustering","NontableLookups","RcvData","RcvSearch","RollingWindowAlerts","SAMLAuth","ScheduledAlerts","ScheduledReports","ScheduledSearch","ScriptedAuth","SearchheadPooling","SigningProcessor","SplunkWeb","SyslogOutputProcessor","UnisiteClustering"],"group_id":"Enterprise","guid":"942ECDCE-2D13-4787-B584-BF581C5F2BA0","is_unlimited":false,"label":"Splunk Developer Personal License DO NOT DISTRIBUTE","license_hash":"CE1E38B6EC08536DC8E732DE57C2A01E3342E2AE98E4839BAB1910585894FF1B","max_retention_size":0,"max_stack_quota":18446744073709552000,"max_users":0,"max_violations":5,"notes":"","quota":10737418240,"relative_expiration_interval":0,"relative_expiration_start":0,"sourcetypes":[],"stack_id":"enterprise","status":"VALID","subgroup_id":"Production","type":"enterprise","window_period":30}},{"name":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD","id":"https://splunk.lan:8089/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD","updated":"1969-12-31T19:00:00-05:00","links":
{"alternate":"/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD","list":"/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD","edit":"/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD"}
,"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":
{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]}
,"removable":false,"sharing":"system"},"content":{"add_ons":null,"allowedRoles":[],"assignableRoles":[],"creation_time":1277017200,"disabled_features":["Acceleration","AdvancedSearchCommands","AdvancedXML","ArchiveToHdfs","ConditionalLicensingEnforcement","CustomRoles","GuestPass","KVStore","LDAPAuth","MultifactorAuth","MultisiteClustering","NontableLookups","RollingWindowAlerts","SAMLAuth","ScheduledAlerts","ScheduledReports","ScriptedAuth","SearchheadPooling","UnisiteClustering"],"eai:acl":null,"expiration_time":2147483647,"features":["Auth","DeployClient","FwdData","RcvData","SigningProcessor","SplunkWeb","SyslogOutputProcessor"],"group_id":"Forwarder","guid":"11111111-1111-1111-1111-111111111111","is_unlimited":false,"label":"Splunk Forwarder","license_hash":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD","max_retention_size":0,"max_stack_quota":18446744073709552000,"max_users":4294967295,"max_violations":5,"notes":"","quota":1048576,"relative_expiration_interval":0,"relative_expiration_start":0,"sourcetypes":[],"stack_id":"forwarder","status":"VALID","subgroup_id":"Production","type":"forwarder","window_period":30}},{"name":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","id":"https://splunk.lan:8089/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","updated":"1969-12-31T19:00:00-05:00","links":
{"alternate":"/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","list":"/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","edit":"/services/licenser/licenses/FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"}
,"author":"system","acl":{"app":"","can_list":true,"can_write":true,"modifiable":false,"owner":"system","perms":
{"read":["admin","splunk-system-role"],"write":["admin","splunk-system-role"]}
,"removable":false,"sharing":"system"},"content":{"add_ons":null,"allowedRoles":[],"assignableRoles":[],"creation_time":1277017200,"disabled_features":["Acceleration","AdvancedSearchCommands","AdvancedXML","ArchiveToHdfs","ConditionalLicensingEnforcement","CustomRoles","GuestPass","LDAPAuth","MultifactorAuth","MultisiteClustering","NontableLookups","RollingWindowAlerts","SAMLAuth","ScheduledAlerts","ScheduledReports","ScriptedAuth","SearchheadPooling","UnisiteClustering"],"eai:acl":null,"expiration_time":2147483647,"features":["FwdData","KVStore","LocalSearch","RcvData","ScheduledSearch","SigningProcessor","SplunkWeb"],"group_id":"Free","guid":"00000000-0000-0000-0000-000000000000","is_unlimited":false,"label":"Splunk Free","license_hash":"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF","max_retention_size":0,"max_stack_quota":18446744073709552000,"max_users":4294967295,"max_violations":3,"notes":"","quota":524288000,"relative_expiration_interval":0,"relative_expiration_start":0,"sourcetypes":[],"stack_id":"free","status":"VALID","subgroup_id":"Production","type":"free","window_period":30}}],"paging":{"total":3,"perPage":30,"offset":0},"messages":[]}[root@zabbix zabbix]#}}

 

Comment by Andris Zeila [ 2022 Nov 30 ]

Released ZBX-21997 in:

  • pre-6.0.12rc1 a0c35c13c49
  • pre-6.2.6rc1 409f7c0b312
  • pre-6.4.0rc1 5f5e3ce28e7

Updated documentation:

Comment by Edgars Melveris [ 2022 Nov 30 ]

toddblake - same issue happens if JSON contains empty element or array, like you have here:

"allowedRoles":[],
Comment by Dave Hampton [ 2022 Dec 02 ]

Installed 6.2.6rc1 last night, still having issues with JSONPath, more info below:

Before JSONPath:

{"errors":"","resources":{"value":[{"name":"*REDACTED*","id":"*REDACTED*","type":"Microsoft.Compute/virtualMachines","location":"uksouth","plan":{"name":"zabbix_proxy_6-0","publisher":"zabbix","product":"zabbix_proxy_6-0"},"properties":{"vmId":"*REDACTED*","hardwareProfile":{"vmSize":"Standard_B1ms"},"storageProfile":{"imageReference":{"publisher":"zabbix","offer":"zabbix_proxy_6-0","sku":"zabbix_proxy_6-0","version":"latest","exactVersion":"6.0.4"},"osDisk":{"osType":"Linux","name":"*REDACTED*","createOption":"FromImage","caching":"ReadWrite","managedDisk":{"storageAccountType":"StandardSSD_LRS","id":"*REDACTED*"},"deleteOption":"Delete","diskSizeGB":30},"dataDisks":[]},"osProfile":{"computerName":"*REDACTED*","adminUsername":"*REDACTED*","linuxConfiguration":{"disablePasswordAuthentication":false,"provisionVMAgent":true,"patchSettings":{"patchMode":"ImageDefault","assessmentMode":"ImageDefault"},"enableVMAgentPlatformUpdates":false},"secrets":[],"allowExtensionOperations":true,"requireGuestProvisionSignal":true},"networkProfile":{"networkInterfaces":[{"id":"*REDACTED*","properties":{"deleteOption":"Detach"}}]},"diagnosticsProfile":{"bootDiagnostics":{"enabled":true}},"provisioningState":"Succeeded","timeCreated":"2022-11-23T13:12:16.2952436+00:00"},"resourceGroup":"*REDACTED*"},{"sku":{"name":"Standard","tier":"Standard"},"id":"*REDACTED*","name":"*REDACTED*","type":"*REDACTED*","location":"UK South","tags":{},"properties":{"disableLocalAuth":false,"zoneRedundant":false,"provisioningState":"Succeeded","metricId":"*REDACTED*","createdAt":"2022-09-12T10:39:24.993Z","updatedAt":"2022-09-12T10:40:08.977Z","serviceBusEndpoint":"*REDACTED*","status":"Active"},"resourceGroup":"*REDACTED*"},{"sku":{"name":"Standard","tier":"Standard"},"id":"*REDACTED*","name":"*REDACTED*","type":"Microsoft.ServiceBus/Namespaces","location":"UK South","tags":{"Env":"Prod"},"properties":{"disableLocalAuth":false,"zoneRedundant":false,"provisioningState":"Succeeded","metricId":"*REDACTED*","createdAt":"2022-10-04T13:13:10.163Z","updatedAt":"2022-10-04T13:13:56.217Z","serviceBusEndpoint":"*REDACTED*","status":"Active"},"resourceGroup":"*REDACTED*"}]}}

After JSONPath:

[{"properties":{"networkProfile":{"networkInterfaces":[{"properties":{"deleteOption":"Detach"},"id":"*REDACTED*"}]},"provisioningState":"Succeeded","timeCreated":"2022-11-23T13:12:16.2952436+00:00","hardwareProfile":{"vmSize":"Standard_B1ms"},"diagnosticsProfile":{"bootDiagnostics":{"enabled":true}},"storageProfile":{"imageReference":{"exactVersion":"6.0.4","offer":"zabbix_proxy_6-0","sku":"zabbix_proxy_6-0","publisher":"zabbix","version":"latest"},"osDisk":{"diskSizeGB":30,"deleteOption":"Delete","createOption":"FromImage","osType":"Linux","managedDisk":{"storageAccountType":"StandardSSD_LRS","id":"*REDACTED*"},"name":"*REDACTED*","caching":"ReadWrite"},"dataDisks":]},"vmId":"*REDACTED*","osProfile":{"computerName":"*REDACTED*","linuxConfiguration":{"enableVMAgentPlatformUpdates":false,"disablePasswordAuthentication":false,"patchSettings":{"patchMode":"ImageDefault","assessmentMode":"ImageDefault"},"provisionVMAgent":true},"adminUsername":"*REDACTED*","allowExtensionOperations":true,"secrets":],"requireGuestProvisionSignal":true}},"resourceGroup":"*REDACTED*","id":"*REDACTED*","type":"Microsoft.Compute/virtualMachines","plan":{"product":"zabbix_proxy_6-0","publisher":"zabbix","name":"zabbix_proxy_6-0"},"name":"*REDACTED*","location":"uksouth"},{"tags":},"location":"UK South","type":"Microsoft.ServiceBus/Namespaces","properties":{"updatedAt":"2022-09-12T10:40:08.977Z","disableLocalAuth":false,"status":"Active","provisioningState":"Succeeded","createdAt":"2022-09-12T10:39:24.993Z","zoneRedundant":false,"metricId":"*REDACTED*","serviceBusEndpoint":"*REDACTED*"},"id":"*REDACTED*n","sku":{"name":"Standard","tier":"Standard"},"resourceGroup":"*REDACTED*","name":"*REDACTED*"},{"tags":{"Env":"Prod"},"location":"UK South","type":"Microsoft.ServiceBus/Namespaces","properties":{"updatedAt":"2022-10-04T13:13:56.217Z","disableLocalAuth":false,"status":"Active","provisioningState":"Succeeded","createdAt":"2022-10-04T13:13:10.163Z","zoneRedundant":false,"metricId":"*REDACTED*","serviceBusEndpoint":"*REDACTED*"},"id":"*REDACTED*","sku":{"name":"Standard","tier":"Standard"},"resourceGroup":"rg-stratus-uks-p-ssb-001","name":"*REDACTED*"}] 
Comment by Andris Zeila [ 2022 Dec 02 ]

Are you sure it's 6.2.6rc1 ? I built server from the 6.2.6rc1 sources (https://cdn.zabbix.com/zabbix/sources/release_candidates/6.2/) and using the above input json and $.resources.values[0] jsonpath I got:

{
  "properties": {
    "networkProfile": {
      "networkInterfaces": [
        {
          "properties": {
            "deleteOption": "Detach"
          },
          "id": "*REDACTED*"
        }
      ]
    },
    "provisioningState": "Succeeded",
    "timeCreated": "2022-11-23T13:12:16.2952436+00:00",
    "hardwareProfile": {
      "vmSize": "Standard_B1ms"
    },
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": true
      }
    },
    "storageProfile": {
      "imageReference": {
        "exactVersion": "6.0.4",
        "offer": "zabbix_proxy_6-0",
        "sku": "zabbix_proxy_6-0",
        "publisher": "zabbix",
        "version": "latest"
      },
      "osDisk": {
        "diskSizeGB": 30,
        "deleteOption": "Delete",
        "createOption": "FromImage",
        "osType": "Linux",
        "managedDisk": {
          "storageAccountType": "StandardSSD_LRS",
          "id": "*REDACTED*"
        },
        "name": "*REDACTED*",
        "caching": "ReadWrite"
      },
      "dataDisks": []
    },
    "vmId": "*REDACTED*",
    "osProfile": {
      "computerName": "*REDACTED*",
      "linuxConfiguration": {
        "enableVMAgentPlatformUpdates": false,
        "disablePasswordAuthentication": false,
        "patchSettings": {
          "patchMode": "ImageDefault",
          "assessmentMode": "ImageDefault"
        },
        "provisionVMAgent": true
      },
      "adminUsername": "*REDACTED*",
      "allowExtensionOperations": true,
      "secrets": [],
      "requireGuestProvisionSignal": true
    }
  },
  "resourceGroup": "*REDACTED*",
  "id": "*REDACTED*",
  "type": "Microsoft.Compute/virtualMachines",
  "plan": {
    "product": "zabbix_proxy_6-0",
    "publisher": "zabbix",
    "name": "zabbix_proxy_6-0"
  },
  "name": "*REDACTED*",
  "location": "uksouth"
}

What jsonpath were you using ?

Comment by Dave Hampton [ 2022 Dec 02 ]

Yeah, Double checked it this morning incase I'd been daft! 

 

Using  $.resources.value

Comment by Andris Zeila [ 2022 Dec 02 ]

Still getting valid results. Any change that the host is monitored by proxy and only server was upgraded?

Comment by Dave Hampton [ 2022 Dec 02 ]

Afraid not:

 

Might be worth mentioning that its not a new install, upgraded from 6.2.5

Comment by Andris Zeila [ 2022 Dec 02 ]

That should not affect it. Any new values that are preprocessed by the new binaries should have handled empty arrays correctly. And that does seem to be the case with server built from 6.2.6rc1 sources.

Could you please check the log file, is the new binary really stared ? It should have something like this:

349838:20221202:112553.199 Starting Zabbix Server. Zabbix 6.2.6rc1 (revision 55aeb78c451).
Comment by Dave Hampton [ 2022 Dec 02 ]

ah, Bingo, wrong Binary starting, my bad! I'll sort that now  

 

Update, now that I'm using the correct binary, working fine. Thanks for your help! 

Comment by LivreAcesso.Pro [ 2022 Dec 07 ]

6.0.12 solved it for me.

Comment by Mikko Tikkala [ 2022 Dec 08 ]

Faced the same issue with 6.4.0beta4.

Json data was validated at jsonpath.com.

This workaround helped. 

const k = JSON.parse(value);
const s = JSON.stringify(k);
return s; 
Comment by Andris Zeila [ 2022 Dec 09 ]

Could you please give more details about this issue? Error message, jsonpath and the input data?

Comment by Mikko Tikkala [ 2022 Dec 09 ]

Sure.

I'll reproduce error later and post all available information. 

 

Error message was same looking as posted here before. 

– cannot extract value from json by path "$.xxxxxxxx": invalid object format, expected opening character '{' or '[' at: ' 

Before upgrading to 6.4.0beta I was using 6.2.6 and there jsonpath preprocessing worked OK. 

Comment by Andris Zeila [ 2022 Dec 09 ]

Ah right, this fix didn't make to beta4, it will be included in next release (beta/rc - depending on how it goes).

Generated at Sun Jul 06 06:14:29 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.