<?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: How to exclude or select events based on value from key/value array? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-or-select-events-based-on-value-from-key-value/m-p/630406#M219013</link>
    <description>&lt;P&gt;I am rather confused. &amp;nbsp;Your sample code shows exactly what you are asking. &amp;nbsp;In other words, you already have the answer. &amp;nbsp;What is missing? &amp;nbsp;If your code is not returning what you expect, you will need to illustrate the results and explain any difference between what you expect and what you receive.&lt;/P&gt;&lt;P&gt;Side note: Based on your search term, Splunk already extracted from JSON. &amp;nbsp;You don't need another spath. &amp;nbsp;Also, if all operators between logical terms is AND, there is no need to bracket them. Additionally, in search command, default operator is AND, so you can also omit that keyword.&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 07:43:45 GMT</pubDate>
    <dc:creator>yuanliu</dc:creator>
    <dc:date>2023-02-10T07:43:45Z</dc:date>
    <item>
      <title>How to exclude or select events based on value from key/value array?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-or-select-events-based-on-value-from-key-value/m-p/630343#M218989</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;Our&amp;nbsp;&lt;SPAN&gt;JSON payload looks like as shown below. The msg.details array can have any number key/value pairs in any order.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
  "appName": "TestApp",
  "eventType": "Response",
  "msg": {
    "transId": "Trans1234",
    "status": "Success",
    "client": "clientXyz",
    "responseTime": 1650,
    "details": [
      {
        "keyName": "returnUrl",
        "keyValue": "https://abc.com/onlineshop?prod=112&amp;amp;cat=1349"
      },
      {
        "keyName": "customer",
        "keyValue": "xyz"
      }
    ],
    "url": "/v1/test"
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to filter events using partial wildcard keyValue for a keyName in the array in the msg.details array. Your help is appreciated. Thanks.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;index=* appName="TestApp" msg.url="/v1/test" |&amp;nbsp; spath | search msg.details{}.keyName=returnUrl AND&amp;nbsp;msg.details{}.keyValue!="*abc.com*"&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;The search may include multiple keyValue filters in the array like this. Thanks.&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;index=* appName="TestApp" msg.url="/v1/test" |&amp;nbsp; spath | search&amp;nbsp;(msg.details{}.keyName=customer AND&amp;nbsp;msg.details{}.keyValue!="xyz") AND (msg.details{}.keyName=returnUrl AND&amp;nbsp;msg.details{}.keyValue!="*abc.com*")&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Feb 2023 18:59:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-or-select-events-based-on-value-from-key-value/m-p/630343#M218989</guid>
      <dc:creator>btsr</dc:creator>
      <dc:date>2023-02-09T18:59:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to exclude or select events based on value from key/value array?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-or-select-events-based-on-value-from-key-value/m-p/630406#M219013</link>
      <description>&lt;P&gt;I am rather confused. &amp;nbsp;Your sample code shows exactly what you are asking. &amp;nbsp;In other words, you already have the answer. &amp;nbsp;What is missing? &amp;nbsp;If your code is not returning what you expect, you will need to illustrate the results and explain any difference between what you expect and what you receive.&lt;/P&gt;&lt;P&gt;Side note: Based on your search term, Splunk already extracted from JSON. &amp;nbsp;You don't need another spath. &amp;nbsp;Also, if all operators between logical terms is AND, there is no need to bracket them. Additionally, in search command, default operator is AND, so you can also omit that keyword.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 07:43:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-exclude-or-select-events-based-on-value-from-key-value/m-p/630406#M219013</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-02-10T07:43:45Z</dc:date>
    </item>
  </channel>
</rss>

