Reputation: 105
Hi Can someone help me simulate this scenario, Example this is the response I got, I want to extract all alertId with the name parameter contains test. You response is highly appreciated. Thank you so much.
Response:
[ { "duplicateCount": 0, "fqdn": "qa-ubuntu14-4", "appName": "TEST_APD_UB14", "stateString": "OPEN", "category": "FILESCAN", "alkey": { "agentId": "8470ea64-a710-3e46-ba6b-ccd37ebc4074", "role": "AD SERVER", "alertId": "0258a7ca-bc72-3a53-aa98-3098c87411ba", "id": "6695a7fa-ab9f-43fa-871b-620cd1eeb75054af7770-604b-11e9-b486-8d59ab9344597cea0ea2-d897-3696-852d-5f3cb36f270e8470ea64-a710-3e46-ba6b-ccd37ebc4074/var/log/test321.txttest321.txtA", "applicationContextId": "7cea0ea2-d897-3696-852d-5f3cb36f270e" }, "properties": { "name": "test321.txt", "acl": "" } }, { "duplicateCount": 0, "fqdn": "qa-ubuntu14-4", "appName": "TEST_APD_UB18", "stateString": "OPEN", "category": "FILESCAN", "alkey": { "agentId": "8470ea64-a710-3e46-ba6b-ccd37ebc4074", "role": "AD SERVER", "alertId": "0258a7ca-bc72-3a53-aa98-3098c8741CDA", "id": "6695a7fa-ab9f-43fa-871b-620cd1eeb75054af7770-604b-11e9-b486-8d59ab9344597cea0ea2-d897-3696-852d-5f3cb36f270e8470ea64-a710-3e46-ba6b-ccd37ebc4074/var/log/test321.txttest321.txtA", "applicationContextId": "7cea0ea2-d897-3696-852d-5f3cb36f270e" }, "properties": { "name": "test555.txt", "acl": "" } } ]
Expected Result: I want to extract all alertId with the name parameter contains test
Upvotes: 0
Views: 43
Reputation: 1841
You could use the following JSON query to extract the values:
[*].[?(@.properties.name contains 'test')]alkey.agentId
I found this reference with JSON Path Syntax is really useful.
Upvotes: 1