<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to extract the json based key value pair for defined match? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638873#M221365</link>
    <description>&lt;P&gt;below is my json file. I want to notify whenever&amp;nbsp; there is a change in last property , "displayName": Included Updated Properties when newvalue:false and oldvalue:true. please let me know the search query&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;json file&lt;/P&gt;
&lt;P&gt;resultReason:&lt;BR /&gt;targetResources: [ [-]&lt;BR /&gt;{ [-]&lt;BR /&gt;administrativeUnits: [ [+]&lt;BR /&gt;]&lt;BR /&gt;displayName: Authorization Policy&lt;BR /&gt;id: abc&lt;BR /&gt;modifiedProperties: [ [-]&lt;BR /&gt;{ [-]&lt;BR /&gt;displayName: PermissionGrantPolicyIdsAssignedToDefaultUserRole&lt;BR /&gt;newValue: ["microsoft-user"]&lt;BR /&gt;oldValue: ["Manage"]&lt;BR /&gt;}&lt;BR /&gt;{ [-]&lt;BR /&gt;displayName: Included Updated Properties&lt;BR /&gt;newValue: "true"&lt;BR /&gt;oldValue: "false"&lt;BR /&gt;}&lt;BR /&gt;{ [+]&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2023 18:13:08 GMT</pubDate>
    <dc:creator>nb662x</dc:creator>
    <dc:date>2023-04-05T18:13:08Z</dc:date>
    <item>
      <title>How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638873#M221365</link>
      <description>&lt;P&gt;below is my json file. I want to notify whenever&amp;nbsp; there is a change in last property , "displayName": Included Updated Properties when newvalue:false and oldvalue:true. please let me know the search query&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;json file&lt;/P&gt;
&lt;P&gt;resultReason:&lt;BR /&gt;targetResources: [ [-]&lt;BR /&gt;{ [-]&lt;BR /&gt;administrativeUnits: [ [+]&lt;BR /&gt;]&lt;BR /&gt;displayName: Authorization Policy&lt;BR /&gt;id: abc&lt;BR /&gt;modifiedProperties: [ [-]&lt;BR /&gt;{ [-]&lt;BR /&gt;displayName: PermissionGrantPolicyIdsAssignedToDefaultUserRole&lt;BR /&gt;newValue: ["microsoft-user"]&lt;BR /&gt;oldValue: ["Manage"]&lt;BR /&gt;}&lt;BR /&gt;{ [-]&lt;BR /&gt;displayName: Included Updated Properties&lt;BR /&gt;newValue: "true"&lt;BR /&gt;oldValue: "false"&lt;BR /&gt;}&lt;BR /&gt;{ [+]&lt;BR /&gt;}&lt;BR /&gt;]&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 18:13:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638873#M221365</guid>
      <dc:creator>nb662x</dc:creator>
      <dc:date>2023-04-05T18:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638917#M221388</link>
      <description>&lt;P&gt;That is not valid json, not is it really what your events are.&amp;nbsp; How do you expect us to deal with it?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 22:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638917#M221388</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-05T22:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638947#M221400</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/255569"&gt;@nb662x&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Share your full sample event.&amp;nbsp; we need _raw from your search.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=YOUR_INDEX | head 1| table _raw&lt;/LI-CODE&gt;&lt;P&gt;Copy and paste in a code block ( &amp;lt;/&amp;gt;).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;This is code block&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;KV&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 05:34:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638947#M221400</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2023-04-06T05:34:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638959#M221402</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/127939"&gt;@kamlesh_vaghela&lt;/a&gt;&amp;nbsp; Please find the json-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"time": "2023-04-04T07:58:02.7508973Z",&lt;BR /&gt;"resourceId": "/tenants/r456ach/providers/Microsoft.aadiam",&lt;BR /&gt;"operationName": "Update authorization policy",&lt;BR /&gt;"operationVersion": "1.0",&lt;BR /&gt;"category": "AuditLogs",&lt;BR /&gt;"tenantId": "r456ach",&lt;BR /&gt;"resultSignature": "None",&lt;BR /&gt;"durationMs": 0,&lt;BR /&gt;"callerIpAddress": "20.190.145.169",&lt;BR /&gt;"correlationId": "16800",&lt;BR /&gt;"Level": 4,&lt;BR /&gt;"properties": {&lt;BR /&gt;"id": "Directory_498",&lt;BR /&gt;"category": "AuthorizationPolicy",&lt;BR /&gt;"correlationId": "4985e174-",&lt;BR /&gt;"result": "success",&lt;BR /&gt;"resultReason": "",&lt;BR /&gt;"activityDisplayName": "Update authorization policy",&lt;BR /&gt;"activityDateTime": "2023-04-04T07:58:02.7508973+00:00",&lt;BR /&gt;"loggedByService": "Core Directory",&lt;BR /&gt;"operationType": "Update",&lt;BR /&gt;"userAgent": null,&lt;BR /&gt;"initiatedBy": {&lt;BR /&gt;"user": {&lt;BR /&gt;"id": "deb6abb8",&lt;BR /&gt;"displayName": null,&lt;BR /&gt;"userPrincipalName": "user@test.onmicrosoft.com",&lt;BR /&gt;"ipAddress": "20.10.10.10",&lt;BR /&gt;"roles": []&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;"targetResources": [&lt;BR /&gt;{&lt;BR /&gt;"id": "c8458b3c",&lt;BR /&gt;"displayName": "Authorization Policy",&lt;BR /&gt;"type": "Other",&lt;BR /&gt;"modifiedProperties": [&lt;BR /&gt;{&lt;BR /&gt;"displayName": "PermissionGrantPolicyIdsAssignedToDefaultUserRole",&lt;BR /&gt;"oldValue": "[\"ManagePermissionGrantsForSelf.microsoft-user-default-legacy\"]",&lt;BR /&gt;"newValue": "[\"microsoft-user-default-legacy\"]"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"displayName": "Included Updated Properties",&lt;BR /&gt;"oldValue": null,&lt;BR /&gt;"newValue": "\"DefaultUserRolePermissions.AllowedToCreateApp, PermissionGrantPolicyIdsAssignedToDefaultUserRole\""&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"displayName": "DefaultUserRolePermissions.AllowedToCreateApp",&lt;BR /&gt;"oldValue": "true",&lt;BR /&gt;"newValue": "false"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"administrativeUnits": []&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"additionalDetails": [&lt;BR /&gt;{&lt;BR /&gt;"key": "User-Agent",&lt;BR /&gt;"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to create below query but not sure if it's the right way because then i need to hard code array position {2} in the query. Could you please suggest right way&lt;/P&gt;&lt;P&gt;sourcetype=azure:logs "properties.targetResources{}.modifiedProperties{}.displayName"="DefaultUserRolePermissions.AllowedToCreateApp" "properties.activityDisplayName"="Update authorization policy"&lt;/P&gt;&lt;P&gt;| spath path=properties.targetResources{} output=mp | spath path=properties.activityDisplayName output=activityName | spath output=UPN path=properties.initiatedBy.user.userPrincipalName&lt;/P&gt;&lt;P&gt;| spath output=NewTenantCreationRestriction path=properties.targetResources{0}.modifiedProperties{2}.newValue&lt;/P&gt;&lt;P&gt;| search NewTenantCreationRestriction=*false*&lt;/P&gt;&lt;P&gt;| spath output=OldTenantCreationRestriction path=properties.targetResources{0}.modifiedProperties{2}.oldValue&lt;/P&gt;&lt;P&gt;| search OldTenantCreationRestriction=*true*&lt;/P&gt;&lt;P&gt;| spath output=Date path=properties.activityDateTime | spath output=tenantId path=properties.tenantId&lt;/P&gt;&lt;P&gt;| table tenantId, Date, activityName, UPN , NewTenantCreationRestriction, OldTenantCreationRestriction&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 06:30:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638959#M221402</guid>
      <dc:creator>nb662x</dc:creator>
      <dc:date>2023-04-06T06:30:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638960#M221403</link>
      <description>&lt;P&gt;Please find the json-&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt;"time": "2023-04-04T07:58:02.7508973Z",&lt;BR /&gt;"resourceId": "/tenants/r456ach/providers/Microsoft.aadiam",&lt;BR /&gt;"operationName": "Update authorization policy",&lt;BR /&gt;"operationVersion": "1.0",&lt;BR /&gt;"category": "AuditLogs",&lt;BR /&gt;"tenantId": "r456ach",&lt;BR /&gt;"resultSignature": "None",&lt;BR /&gt;"durationMs": 0,&lt;BR /&gt;"callerIpAddress": "20.190.145.169",&lt;BR /&gt;"correlationId": "16800",&lt;BR /&gt;"Level": 4,&lt;BR /&gt;"properties": {&lt;BR /&gt;"id": "Directory_498",&lt;BR /&gt;"category": "AuthorizationPolicy",&lt;BR /&gt;"correlationId": "4985e174-",&lt;BR /&gt;"result": "success",&lt;BR /&gt;"resultReason": "",&lt;BR /&gt;"activityDisplayName": "Update authorization policy",&lt;BR /&gt;"activityDateTime": "2023-04-04T07:58:02.7508973+00:00",&lt;BR /&gt;"loggedByService": "Core Directory",&lt;BR /&gt;"operationType": "Update",&lt;BR /&gt;"userAgent": null,&lt;BR /&gt;"initiatedBy": {&lt;BR /&gt;"user": {&lt;BR /&gt;"id": "deb6abb8",&lt;BR /&gt;"displayName": null,&lt;BR /&gt;"userPrincipalName": "user@test.onmicrosoft.com",&lt;BR /&gt;"ipAddress": "20.10.10.10",&lt;BR /&gt;"roles": []&lt;BR /&gt;}&lt;BR /&gt;},&lt;BR /&gt;"targetResources": [&lt;BR /&gt;{&lt;BR /&gt;"id": "c8458b3c",&lt;BR /&gt;"displayName": "Authorization Policy",&lt;BR /&gt;"type": "Other",&lt;BR /&gt;"modifiedProperties": [&lt;BR /&gt;{&lt;BR /&gt;"displayName": "PermissionGrantPolicyIdsAssignedToDefaultUserRole",&lt;BR /&gt;"oldValue": "[\"ManagePermissionGrantsForSelf.microsoft-user-default-legacy\"]",&lt;BR /&gt;"newValue": "[\"microsoft-user-default-legacy\"]"&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"displayName": "Included Updated Properties",&lt;BR /&gt;"oldValue": null,&lt;BR /&gt;"newValue": "\"DefaultUserRolePermissions.AllowedToCreateApp, PermissionGrantPolicyIdsAssignedToDefaultUserRole\""&lt;BR /&gt;},&lt;BR /&gt;{&lt;BR /&gt;"displayName": "DefaultUserRolePermissions.AllowedToCreateApp",&lt;BR /&gt;"oldValue": "true",&lt;BR /&gt;"newValue": "false"&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"administrativeUnits": []&lt;BR /&gt;}&lt;BR /&gt;],&lt;BR /&gt;"additionalDetails": [&lt;BR /&gt;{&lt;BR /&gt;"key": "User-Agent",&lt;BR /&gt;"value": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried to create below query but not sure if it's the right way because then i need to hard code array position {2} in the query. Could you please suggest right way&lt;/P&gt;&lt;P&gt;sourcetype=azure:logs "properties.targetResources{}.modifiedProperties{}.displayName"="DefaultUserRolePermissions.AllowedToCreateApp" "properties.activityDisplayName"="Update authorization policy"&lt;/P&gt;&lt;P&gt;| spath path=properties.targetResources{} output=mp | spath path=properties.activityDisplayName output=activityName | spath output=UPN path=properties.initiatedBy.user.userPrincipalName&lt;/P&gt;&lt;P&gt;| spath output=NewTenantCreationRestriction path=properties.targetResources{0}.modifiedProperties{2}.newValue&lt;/P&gt;&lt;P&gt;| search NewTenantCreationRestriction=*false*&lt;/P&gt;&lt;P&gt;| spath output=OldTenantCreationRestriction path=properties.targetResources{0}.modifiedProperties{2}.oldValue&lt;/P&gt;&lt;P&gt;| search OldTenantCreationRestriction=*true*&lt;/P&gt;&lt;P&gt;| spath output=Date path=properties.activityDateTime | spath output=tenantId path=properties.tenantId&lt;/P&gt;&lt;P&gt;| table tenantId, Date, activityName, UPN , NewTenantCreationRestriction, OldTenantCreationRestriction&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 06:31:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/638960#M221403</guid>
      <dc:creator>nb662x</dc:creator>
      <dc:date>2023-04-06T06:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/639052#M221429</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{
\"time\": \"2023-04-04T07:58:02.7508973Z\",
\"resourceId\": \"/tenants/r456ach/providers/Microsoft.aadiam\",
\"operationName\": \"Update authorization policy\",
\"operationVersion\": \"1.0\",
\"category\": \"AuditLogs\",
\"tenantId\": \"r456ach\",
\"resultSignature\": \"None\",
\"durationMs\": 0,
\"callerIpAddress\": \"20.190.145.169\",
\"correlationId\": \"16800\",
\"Level\": 4,
\"properties\": {
\"id\": \"Directory_498\",
\"category\": \"AuthorizationPolicy\",
\"correlationId\": \"4985e174-\",
\"result\": \"success\",
\"resultReason\": \"\",
\"activityDisplayName\": \"Update authorization policy\",
\"activityDateTime\": \"2023-04-04T07:58:02.7508973+00:00\",
\"loggedByService\": \"Core Directory\",
\"operationType\": \"Update\",
\"userAgent\": null,
\"initiatedBy\": {
\"user\": {
\"id\": \"deb6abb8\",
\"displayName\": null,
\"userPrincipalName\": \"user@test.onmicrosoft.com\",
\"ipAddress\": \"20.10.10.10\",
\"roles\": []
}
},
\"targetResources\": [
{
\"id\": \"c8458b3c\",
\"displayName\": \"Authorization Policy\",
\"type\": \"Other\",
\"modifiedProperties\": [
{
\"displayName\": \"PermissionGrantPolicyIdsAssignedToDefaultUserRole\",
\"oldValue\": \"[\\\"ManagePermissionGrantsForSelf.microsoft-user-default-legacy\\\"]\",
\"newValue\": \"[\\\"microsoft-user-default-legacy\\\"]\"
    },
{
\"displayName\": \"Included Updated Properties\",
\"oldValue\": null,
\"newValue\": \"\\\"DefaultUserRolePermissions.AllowedToCreateApp, PermissionGrantPolicyIdsAssignedToDefaultUserRole\\\"\"
    },
{
\"displayName\": \"DefaultUserRolePermissions.AllowedToCreateApp\",
\"oldValue\": \"true\",
\"newValue\": \"false\"
    }
],
\"administrativeUnits\": []
}
],
\"additionalDetails\": [
{
\"key\": \"User-Agent\",
\"value\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36\"
    }
]
}
}" 
| kv
| spath path=properties.activityDisplayName output=activityName 
| spath output=UPN path=properties.initiatedBy.user.userPrincipalName 
| spath output=Date path=properties.activityDateTime 
| table tenantId, Date, activityName, UPN , NewTenantCreationRestriction, OldTenantCreationRestriction _raw
| rex max_match=0 "(?ms){[\r\n\s]*\"displayName\":.*?\"oldValue\":\s*\"?(?&amp;lt;oldValue&amp;gt;.*?)[\",]*[\r\n\s]+\"newValue\":\s*\"(?&amp;lt;newValue&amp;gt;.*?)[\",]*[\r\n]"
| where mvindex(oldValue, -1)=="true" AND mvindex(newValue, -1)=="false"&lt;/LI-CODE&gt;&lt;P&gt;OR like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="{
\"time\": \"2023-04-04T07:58:02.7508973Z\",
\"resourceId\": \"/tenants/r456ach/providers/Microsoft.aadiam\",
\"operationName\": \"Update authorization policy\",
\"operationVersion\": \"1.0\",
\"category\": \"AuditLogs\",
\"tenantId\": \"r456ach\",
\"resultSignature\": \"None\",
\"durationMs\": 0,
\"callerIpAddress\": \"20.190.145.169\",
\"correlationId\": \"16800\",
\"Level\": 4,
\"properties\": {
\"id\": \"Directory_498\",
\"category\": \"AuthorizationPolicy\",
\"correlationId\": \"4985e174-\",
\"result\": \"success\",
\"resultReason\": \"\",
\"activityDisplayName\": \"Update authorization policy\",
\"activityDateTime\": \"2023-04-04T07:58:02.7508973+00:00\",
\"loggedByService\": \"Core Directory\",
\"operationType\": \"Update\",
\"userAgent\": null,
\"initiatedBy\": {
\"user\": {
\"id\": \"deb6abb8\",
\"displayName\": null,
\"userPrincipalName\": \"user@test.onmicrosoft.com\",
\"ipAddress\": \"20.10.10.10\",
\"roles\": []
}
},
\"targetResources\": [
{
\"id\": \"c8458b3c\",
\"displayName\": \"Authorization Policy\",
\"type\": \"Other\",
\"modifiedProperties\": [
{
\"displayName\": \"PermissionGrantPolicyIdsAssignedToDefaultUserRole\",
\"oldValue\": \"[\\\"ManagePermissionGrantsForSelf.microsoft-user-default-legacy\\\"]\",
\"newValue\": \"[\\\"microsoft-user-default-legacy\\\"]\"
    },
{
\"displayName\": \"Included Updated Properties\",
\"oldValue\": null,
\"newValue\": \"\\\"DefaultUserRolePermissions.AllowedToCreateApp, PermissionGrantPolicyIdsAssignedToDefaultUserRole\\\"\"
    },
{
\"displayName\": \"DefaultUserRolePermissions.AllowedToCreateApp\",
\"oldValue\": \"true\",
\"newValue\": \"false\"
    }
],
\"administrativeUnits\": []
}
],
\"additionalDetails\": [
{
\"key\": \"User-Agent\",
\"value\": \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36\"
    }
]
}
}" 
| kv
| spath path=properties.activityDisplayName output=activityName 
| spath output=UPN path=properties.initiatedBy.user.userPrincipalName 
| spath output=Date path=properties.activityDateTime 
| table tenantId, Date, activityName, UPN , NewTenantCreationRestriction, OldTenantCreationRestriction _raw
| rex "(?ms){[\r\n\s]*\"displayName\":[\r\n\s]+\"DefaultUserRolePermissions.AllowedToCreateApp\",[\r\n\s]+\"oldValue\":\s*\"?(?&amp;lt;oldValue&amp;gt;.*?)[\",]*[\r\n\s]+\"newValue\":\s*\"(?&amp;lt;newValue&amp;gt;.*?)[\",]*[\r\n]"
| where oldValue=="true" AND newValue=="false"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 06 Apr 2023 17:14:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/639052#M221429</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-06T17:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract the json based key value pair for defined match?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/695379#M236460</link>
      <description>&lt;P&gt;I know this is an old one, but I went searching in the hopes someone had already written, so sharing here.&lt;BR /&gt;&lt;BR /&gt;This is specifically for EntraID (/Azure AD) Audit logs - Which are "valid" json, however there's some wierd stuff going on within the JSON itself - And a real mixture of data structures (probably depends on which developer wrote each piece i'm guessing).&lt;BR /&gt;&lt;BR /&gt;Anyway, hope it helps someone - it deals with the 2x value data as well as the name/old/new type data.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;index=entra_audit activityDisplayName="Consent to application" category="ApplicationManagement"&lt;BR /&gt;``` Entra ID Audit Logs - Extract Application Consent JSON into usable fields ```&lt;BR /&gt;| spath operationType&lt;BR /&gt;| rename targetResources{}.* AS targetResources.*&lt;BR /&gt;| table _time index sourcetype source correlationId additionalDetails* activityDisplayName category operationType result initiatedBy.user.ipAddress initiatedBy.user.userPrincipalName targetResources.*&lt;BR /&gt;&lt;BR /&gt;``` additionalDetails is a 2 entry key/value pair in JSON ```&lt;BR /&gt;| rename additionalDetails{}.* AS additionalDetails_*&lt;BR /&gt;| eval additionalDetails=mvzip(additionalDetails_key,additionalDetails_value, "=") &lt;BR /&gt;| mvexpand additionalDetails &lt;BR /&gt;| eval Key=mvindex(split(additionalDetails,"="),0), Value=mvindex(split(additionalDetails,"="),1) &lt;BR /&gt;| eval additionalDetails.{Key}=Value&lt;BR /&gt;&lt;BR /&gt;``` targetResources.modifiedProperties{} is a 3 entry name/newvalue/oldvalue in JSON ```&lt;BR /&gt;| rename targetResources.modifiedProperties{}.* AS targetm_*&lt;BR /&gt;| eval targetm=mvzip(targetm_displayName,targetm_newValue, ";") &lt;BR /&gt;| eval targetm=mvzip(targetm,targetm_oldValue, ";")&lt;BR /&gt;| mvexpand targetm &lt;BR /&gt;| eval Key=mvindex(split(targetm,";"),0).".newValue", Value=trim(mvindex(split(targetm,";"),1),"\"")&lt;BR /&gt;| eval modifiedProperties.{Key}=Value &lt;BR /&gt;| eval Key=mvindex(split(targetm,";"),0).".oldValue", Value=trim(mvindex(split(targetm,";"),2),"\"") &lt;BR /&gt;| eval modifiedProperties.{Key}=Value&lt;BR /&gt;&lt;BR /&gt;``` Now extract the permissions, which are in yet a different format - multiple fields with `double_bracket`old =&amp;gt; `double_bracket`new, but json format is the same old/new format as other above fields - yet the old and new is stored in the "newValue" field only, and "oldValue" is blank```&lt;BR /&gt;``` Within the double brackets are multiple ID's which relate to individual scopes, however we're only interested in the scope and context type ```&lt;BR /&gt;``` Remove spaces ```&lt;BR /&gt;| rex mode=sed field=modifiedProperties.ConsentAction.Permissions.newValue "s/ //g"&lt;BR /&gt;``` Extract new/old values ```&lt;BR /&gt;| rex field=modifiedProperties.ConsentAction.Permissions.newValue "\[(?P&amp;lt;perms_new&amp;gt;\[.*\])\]=&amp;gt;\[(?P&amp;lt;perms_old&amp;gt;\[.*\])\]"&lt;BR /&gt;| makemv perms_new delim="],"&lt;BR /&gt;| mvexpand perms_new&lt;BR /&gt;| eval perms_new = trim(perms_new,"[]")&lt;BR /&gt;| rex field=perms_new "ConsentType:(?P&amp;lt;perms_type_new&amp;gt;.*?),.*Scope:(?P&amp;lt;perms_scope_new&amp;gt;.*?),"&lt;BR /&gt;| makemv perms_old delim="],"&lt;BR /&gt;| mvexpand perms_old&lt;BR /&gt;| eval perms_old = trim(perms_old,"[]")&lt;BR /&gt;| rex field=perms_old "ConsentType:(?P&amp;lt;perms_type_old&amp;gt;.*?),.*Scope:(?P&amp;lt;perms_scope_old&amp;gt;.*?),"&lt;BR /&gt;| rename perms_type_new AS permissions.consentType.newValue perms_scope_new AS permissions.scope.newValue&lt;BR /&gt;| rename perms_type_old AS permissions.consentType.oldValue perms_scope_old AS permissions.scope.oldValue&lt;BR /&gt;&lt;BR /&gt;``` Clean up unecessary fields - Slighly faster to do this before the transaction```&lt;BR /&gt;| fields - Key Value *_key *_value targetm* additionalDetails modifiedProperties.ConsentAction.Permissions* perms*&lt;BR /&gt;&lt;BR /&gt;``` Condense those events down to a single event ```&lt;BR /&gt;| transaction correlationId maxspan=1s&lt;BR /&gt;``` Format into a nicer table and field names ```&lt;BR /&gt;| rename initiatedBy.user.ipAddress AS src initiatedBy.user.userPrincipalName AS user&lt;BR /&gt;| rename modifiedProperties.ConsentContext.* AS context.*&lt;BR /&gt;| rename modifiedProperties.TargetId.* AS target.*&lt;BR /&gt;| table _time index sourcetype source category operationType result src user activityDisplayName correlationId additionalDetails.* targetResources.* target.* context.* permissions.*&lt;BR /&gt;&lt;BR /&gt;```| collect index=my_summary ```&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;For performance I suggest you collect that into a summary index, csv or kvstore&lt;BR /&gt;&lt;BR /&gt;Here's a sanitised copy of an event:&lt;/P&gt;&lt;PRE&gt;&lt;BR /&gt;{"id": "Directory_zzzzz-zzzz-zzzz", "category": "ApplicationManagement", "correlationId": "zzzz-zzzz-zzzz-zzzz-zzzz", "result": "success", "resultReason": "", "activityDisplayName": "Consent to application", "activityDateTime": "2024-08-05T06:10:19.1808273Z", "loggedByService": "Core Directory", "operationType": "Assign", "initiatedBy": {"app": null, "user": {"id": "zzzz-zzzz-zzzz-zzzz-zzzz", "displayName": null, "userPrincipalName": "zzzz", "ipAddress": "0.0.0.0", "userType": null, "homeTenantId": null, "homeTenantName": null}}, "targetResources": [{"id": "zzzz-zzzz-zzzz-zzzz-zzzz", "displayName": "Microsoft Graph PowerShell", "type": "ServicePrincipal", "userPrincipalName": null, "groupType": null, "modifiedProperties": [{"displayName": "ConsentContext.IsAdminConsent", "oldValue": null, "newValue": "\"True\""}, {"displayName": "ConsentContext.IsAppOnly", "oldValue": null, "newValue": "\"False\""}, {"displayName": "ConsentContext.OnBehalfOfAll", "oldValue": null, "newValue": "\"False\""}, {"displayName": "ConsentContext.Tags", "oldValue": null, "newValue": "\"WindowsAzureActiveDirectoryIntegratedApp\""}, {"displayName": "ConsentAction.Permissions", "oldValue": null, "newValue": "\"[] =&amp;gt; [[Id: zzzz-zzzz-zzzz-zzzz-zzzz_-OGPWDcaCSZ3yquwoJpK3, ClientId: zzzz-zzzz-zzzz-zzzz-zzzz, PrincipalId: zzzz-zzzz-zzzz-zzzz-zzzz, ResourceId: zzzz-zzzz-zzzz-zzzz-zzzz, ConsentType: Principal, Scope: Application.ReadWrite.All Organization.Read.All AuditLog.Read.All openid profile offline_access, CreatedDateTime: , LastModifiedDateTime ]]; \""}, {"displayName": "TargetId.ServicePrincipalNames", "oldValue": null, "newValue": "\"zzzz-zzzz-zzzz-zzzz-zzzz\""}]}], "additionalDetails": [{"key": "User-Agent", "value": "EvoSTS"}, {"key": "AppId", "value": "zzzz-zzzz-zzzz-zzzz-zzzz"}]}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Aug 2024 07:12:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-the-json-based-key-value-pair-for-defined-match/m-p/695379#M236460</guid>
      <dc:creator>lindonmorris</dc:creator>
      <dc:date>2024-08-06T07:12:56Z</dc:date>
    </item>
  </channel>
</rss>

