<?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 Re: Querying log events based on field values nested inside a escaped raw JSON property in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640714#M221988</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253625"&gt;@btsr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you provide the raw JSON as a code sample as this makes it easier to provide a working example that shows you what you need to do using SPL.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yeahnah_0-1681948314914.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24989iAE811F40EEE064B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yeahnah_0-1681948314914.png" alt="yeahnah_0-1681948314914.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On a side note, you should look at cleaning this data up before it is ingested - basically object is showing the HTML code for a double quote - " = &amp;amp;#34.&lt;/P&gt;</description>
    <pubDate>Wed, 19 Apr 2023 23:54:11 GMT</pubDate>
    <dc:creator>yeahnah</dc:creator>
    <dc:date>2023-04-19T23:54:11Z</dc:date>
    <item>
      <title>Querying log events based on field values nested inside a escaped raw JSON property</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640711#M221987</link>
      <description>&lt;P&gt;Hi, I need some help with querying log events based on field values nested inside a escaped raw JSON object property. Below screenshot represents the complete JSON log event in "Show syntax highlighted" mode. I need to filter events based on properties in the parent JSON object and also combine field values from msg.object which is also a proper JSON object.&lt;/P&gt;&lt;P&gt;I tried rex, spath but couldn't filter the events the way I need.&amp;nbsp;Any help is appreciated. Thanks.&lt;/P&gt;&lt;P&gt;I am looking for a query to filter events matching the highlighted fields in the Splunk event log screenshot.&amp;nbsp;This is for a dashboard with dropdowns for app, clientName, requestType, and state fields. I should be able to filter the log events based on dropdown selection.&lt;/P&gt;&lt;P&gt;index=x05_dev app=mock-app msg.detail{}.value=value1 | search msg.object.headers.requestType="basic" | search msg.object.body.client.clientName="XyzClient" | search msg.object.body.order.details[*].address.state="MN"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sample Splunk Log Event" style="width: 518px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24988i929204C372D5D7A5/image-size/large?v=v2&amp;amp;px=999" role="button" title="SplunkEventLog.png" alt="Sample Splunk Log Event" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Sample Splunk Log Event&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 00:48:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640711#M221987</guid>
      <dc:creator>btsr</dc:creator>
      <dc:date>2023-04-20T00:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Querying log events based on field values nested inside a escaped raw JSON property</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640714#M221988</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253625"&gt;@btsr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can you provide the raw JSON as a code sample as this makes it easier to provide a working example that shows you what you need to do using SPL.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yeahnah_0-1681948314914.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24989iAE811F40EEE064B5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yeahnah_0-1681948314914.png" alt="yeahnah_0-1681948314914.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On a side note, you should look at cleaning this data up before it is ingested - basically object is showing the HTML code for a double quote - " = &amp;amp;#34.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Apr 2023 23:54:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640714#M221988</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-04-19T23:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Querying log events based on field values nested inside a escaped raw JSON property</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640715#M221989</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/158935"&gt;@yeahnah&lt;/a&gt;, the msg.object field is ingested with HTML code like shown in the screenshot by the Splunk team to allow different teams to use it for different free form JSON format. If I click on "Show as Raw Text" in Splunk, it is replacing all ampersand symbol with&amp;nbsp;&lt;SPAN&gt;\&lt;/SPAN&gt;&lt;SPAN class=""&gt;u0026&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 00:10:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640715#M221989</guid>
      <dc:creator>btsr</dc:creator>
      <dc:date>2023-04-20T00:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: Querying log events based on field values nested inside a escaped raw JSON property</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640716#M221990</link>
      <description>&lt;P&gt;I think we need to get the msg.object and replace all HTML codes&lt;SPAN&gt;&amp;nbsp;to double quotes on the fly to make a valid JSON before querying further.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{
  "app": "mock-app",
  "sessionId": "71cde99f-faa9-47df-99d4-97b81b39275b",
  "msg": {
    "event": "response",
    "status": "success",
    "details": [
      {
        "key": "key1",
        "value": "value1"
      }
    ],
    "method": "post",
    "object":{
      \u0026#34;headers\u0026#34;: {
        \u0026#34;content-length\u0026#34;: \u0026#34;225\u0026#34;,
        \u0026#34;requestType\u0026#34;: \u0026#34;basic\u0026#34;
      },
      \u0026#34;body\u0026#34;: {
        \\\u0026#34;client\\\u0026#34;: {
            \\\u0026#34;clientName\\\u0026#34;: \\\u0026#34;XyzClient\\\u0026#34;
        },
        \\\u0026#34;order\\\u0026#34;: {
            \\\u0026#34;number\\\u0026#34;: \\\u0026#34;551270009\\\u0026#34;,
            \\\u0026#34;details\\\u0026#34;: [
            {
                \\\u0026#34;item\\\u0026#34;: \\\u0026#34;product\\\u0026#34;,
                \\\u0026#34;address\\\u0026#34;: {
                  \\\u0026#34;street\\\u0026#34;: \\\u0026#34;Main St\\\u0026#34;,
                  \\\u0026#34;zip\\\u0026#34;: \\\u0026#34;12345\\\u0026#34;,
                  \\\u0026#34;state\\\u0026#34;: \\\u0026#34;MN\u0026#34;,
                \\\u0026#34;city\\\u0026#34;: \\\u0026#34;XyzCity\\\u0026#34;
            }
          }
        ]
      }
    }  
    }
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 00:48:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640716#M221990</guid>
      <dc:creator>btsr</dc:creator>
      <dc:date>2023-04-20T00:48:30Z</dc:date>
    </item>
    <item>
      <title>Re: Querying log events based on field values nested inside a escaped raw JSON property</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640718#M221991</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253625"&gt;@btsr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Try adding this sed character replacement using the rex command, which should normalise the escaped code in the msg.object back to double quotes expected for JSON formats, then spath will pull the kv fields out of the JSON event again&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... your search ...
| rex mode=sed "s/(\\\)*u0026#34;/\"/g"
| spath msg.object
| ... more SPL, as needed ...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Hope it helps&lt;/P&gt;</description>
      <pubDate>Thu, 20 Apr 2023 01:02:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Querying-log-events-based-on-field-values-nested-inside-a/m-p/640718#M221991</guid>
      <dc:creator>yeahnah</dc:creator>
      <dc:date>2023-04-20T01:02:40Z</dc:date>
    </item>
  </channel>
</rss>

