<?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 Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted values in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649764#M224653</link>
    <description>&lt;P&gt;Hello Community,&lt;BR /&gt;&lt;SPAN&gt;I am fairly new to Splunk, and I am struggling with this. Here is my raw event: these are discrepancy events that show a reported discrepancy in the two JSONs (for the context of this problem, those JSONs are not necessary to be known).&lt;BR /&gt;Assuming there are n events similar to what we have in the sample JSON.&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;{
  "severity": "INFO",
  "time": "2023-07-09 18:53:53.930",
  "Stats": {
    "discrepancy" : 10
  },
  "discrepancyDetails": {
    "record/0": "#DEL",
    "record/1": "#DEL",
    "recordD": "#DEL",
    "recordX": "expected =&amp;gt; actual",
    "recordY": "someExpectedVal =&amp;gt; null", &amp;lt;-- actual value is null in this case
    "recordN": "someExpectedValN =&amp;gt; null"
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stats.discrepancy provides the total count, while discrepancyDetails provides the actual discrepancy.&lt;/P&gt;&lt;P&gt;I want to fetch some statistics from this, which involve the following details:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;All the unique discrepancyDetails with their respective counts.&lt;/LI&gt;&lt;LI&gt;Before finding the count, I want to remove all numerical characters from the key. For example, in the same JSON, we have two keys in the discrepancyDetails: "record/1" and "record/2". I want to treat these keys as "record/" and replace the numeric strings with an empty value.&lt;/LI&gt;&lt;LI&gt;figure out all the keys with null &lt;STRONG&gt;actual &lt;/STRONG&gt;(from sample json "expected =&amp;gt; actual") values and "#DEL" (deleted) values&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I was able to obtain the unique count of all the keys using the following query.&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;index="demo1" sourcetype="demo2" 
| search discrepancyDetails AND Stats 
| spath "Stats.discrepancy" 
| search "Stats.discrepancy" &amp;gt; 0 
| stats count(discrepancyDetails.*) as discrepancyDetails.*
| transpose&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unable to figure out points 2 and 3 from the above requirements.&lt;BR /&gt;&lt;BR /&gt;Desired output for requirement 2&amp;nbsp; considering above sample json:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;Unique_key&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;record/&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;recordD&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;recordX&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;recordY&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;recordN&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Desired output for requirement 3&amp;nbsp; considering above sample json:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Unique_key&lt;/TD&gt;&lt;TD width="25%"&gt;null or #DEL&lt;/TD&gt;&lt;TD width="25%"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;record/&lt;BR /&gt;recordD&lt;/TD&gt;&lt;TD width="25%"&gt;#DEL&lt;/TD&gt;&lt;TD width="25%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;recordY&lt;BR /&gt;recordN&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;null&lt;/TD&gt;&lt;TD width="25%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
    <pubDate>Mon, 10 Jul 2023 08:38:36 GMT</pubDate>
    <dc:creator>adikrhd</dc:creator>
    <dc:date>2023-07-10T08:38:36Z</dc:date>
    <item>
      <title>Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted values</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649764#M224653</link>
      <description>&lt;P&gt;Hello Community,&lt;BR /&gt;&lt;SPAN&gt;I am fairly new to Splunk, and I am struggling with this. Here is my raw event: these are discrepancy events that show a reported discrepancy in the two JSONs (for the context of this problem, those JSONs are not necessary to be known).&lt;BR /&gt;Assuming there are n events similar to what we have in the sample JSON.&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;{
  "severity": "INFO",
  "time": "2023-07-09 18:53:53.930",
  "Stats": {
    "discrepancy" : 10
  },
  "discrepancyDetails": {
    "record/0": "#DEL",
    "record/1": "#DEL",
    "recordD": "#DEL",
    "recordX": "expected =&amp;gt; actual",
    "recordY": "someExpectedVal =&amp;gt; null", &amp;lt;-- actual value is null in this case
    "recordN": "someExpectedValN =&amp;gt; null"
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Stats.discrepancy provides the total count, while discrepancyDetails provides the actual discrepancy.&lt;/P&gt;&lt;P&gt;I want to fetch some statistics from this, which involve the following details:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;All the unique discrepancyDetails with their respective counts.&lt;/LI&gt;&lt;LI&gt;Before finding the count, I want to remove all numerical characters from the key. For example, in the same JSON, we have two keys in the discrepancyDetails: "record/1" and "record/2". I want to treat these keys as "record/" and replace the numeric strings with an empty value.&lt;/LI&gt;&lt;LI&gt;figure out all the keys with null &lt;STRONG&gt;actual &lt;/STRONG&gt;(from sample json "expected =&amp;gt; actual") values and "#DEL" (deleted) values&lt;BR /&gt;&lt;BR /&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I was able to obtain the unique count of all the keys using the following query.&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;index="demo1" sourcetype="demo2" 
| search discrepancyDetails AND Stats 
| spath "Stats.discrepancy" 
| search "Stats.discrepancy" &amp;gt; 0 
| stats count(discrepancyDetails.*) as discrepancyDetails.*
| transpose&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am unable to figure out points 2 and 3 from the above requirements.&lt;BR /&gt;&lt;BR /&gt;Desired output for requirement 2&amp;nbsp; considering above sample json:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;Unique_key&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;record/&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;recordD&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;recordX&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%" height="25px"&gt;recordY&lt;/TD&gt;&lt;TD width="50%" height="25px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;recordN&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;Desired output for requirement 3&amp;nbsp; considering above sample json:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%"&gt;Unique_key&lt;/TD&gt;&lt;TD width="25%"&gt;null or #DEL&lt;/TD&gt;&lt;TD width="25%"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;record/&lt;BR /&gt;recordD&lt;/TD&gt;&lt;TD width="25%"&gt;#DEL&lt;/TD&gt;&lt;TD width="25%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="50%"&gt;recordY&lt;BR /&gt;recordN&lt;/TD&gt;&lt;TD width="25%"&gt;&amp;nbsp;null&lt;/TD&gt;&lt;TD width="25%"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:38:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649764#M224653</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-10T08:38:36Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649782#M224659</link>
      <description>&lt;P&gt;Requirements 2 and 3 are not clear - perhaps if you shared what your expected output would be, it might become clearer&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 07:21:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649782#M224659</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-07-10T07:21:10Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649788#M224661</link>
      <description>&lt;P&gt;This question needs some serious clarification. &amp;nbsp;First, the sample data and sample code you illustrated are incompatible: Node&amp;nbsp;discrepancyDetails in the data is a hash of key-value pairs, not an array. &amp;nbsp;Yet the path option in the illustrated SPL uses the {} notation, implying that&amp;nbsp;discrepancyDetails should be array; the use of mvexpand also only has effect on array content. &amp;nbsp;In fact, both spath and mvexpand should have no effect if data is as illustrated. (If the data format is as illustrated, Splunk would have already given you&amp;nbsp;discrepancyDetails.record/0,&amp;nbsp;discrepancyDetails.record/1, etc.) &amp;nbsp;Is discrepancyDetails a hash node or an array node? &amp;nbsp;I will assume the data illustration as correct.&lt;/P&gt;&lt;P&gt;Second, your sample code suggests that the count you wanted is to be grouped by (modified) keys in discrepancyDetails. &amp;nbsp;But the stats command as illustrated should give you no output at all. &amp;nbsp;I can sense two possibilities: you either want&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count(discrepancyDetails.*) as discrepancyDetails.*&lt;/LI-CODE&gt;&lt;P&gt;or&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count by discrepancyDetails.*&lt;/LI-CODE&gt;&lt;P&gt;which one is it? &amp;nbsp;I will assume the former.&lt;/P&gt;&lt;P&gt;Then, I'm still unclear about the 3rd requirement. &amp;nbsp;What is a null actual? &amp;nbsp;Do you mean "expected =&amp;gt;"? &amp;nbsp;There is no way for me to make a meaningful speculation. &amp;nbsp;I will ignore this ask until you can clarify.&lt;/P&gt;&lt;P&gt;Based on my reinterpretation, what you ask (except 3) can be achieved with&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/\/\d+\"/\"/g"
| rename discrepancyDetails.* AS bad.*
| spath
| stats count(discrepancyDetails.*) as discrepancyDetails.*&lt;/LI-CODE&gt;&lt;P&gt;Hope this helps&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 07:41:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649788#M224661</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-07-10T07:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649799#M224665</link>
      <description>&lt;P&gt;hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;,&lt;BR /&gt;I have updated the post with desired results, please give it a try now.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:09:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649799#M224665</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-10T08:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649802#M224666</link>
      <description>&lt;P&gt;hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;yes you are right about mvexpand and {} use in the SPL, it turns out that the following query also returns the same result, please note that the &lt;STRONG&gt;transpose&lt;/STRONG&gt; is important.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="demo1" sourcetype="demo2" 
| search discrepancyDetails AND Stats 
| spath "Stats.discrepancy" 
| search "Stats.discrepancy" &amp;gt; 0 
| stats count(discrepancyDetails.*) as discrepancyDetails.*
| transpose&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;SPAN&gt;However, I appreciate your suggestion, but it seems that the provided answer is not yielding the desired results. It appears that the solution is renaming the "discrepancyDetails" fields to "bad," resulting in duplicated "Interested" fields with prefixes "discrepancyDetails." and "bad." in my Splunk fields section. Moreover, the numeric characters in the keys are not being replaced with an empty string. Could you please kindly assist me in finding a more effective solution? Thank you for your understanding.&lt;BR /&gt;&lt;BR /&gt;I have also added desired results for point 2 and 3 in the original post, please give it a try.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:22:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649802#M224666</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-10T08:22:24Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649805#M224668</link>
      <description>&lt;P&gt;Requirement 2&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| spath discrepancyDetails
| rex mode=sed field=discrepancyDetails "s/\/\d+/\//g"
| eval keys=json_keys(discrepancyDetails)
| rex mode=sed field=keys "s/[\[\]\\\"]//g"
| eval keys=split(keys,",")
| stats count by keys&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:47:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649805#M224668</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-07-10T08:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649806#M224669</link>
      <description>&lt;P&gt;Requirement 3 is still unclear - all keys have values, none of them are null&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:49:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649806#M224669</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-07-10T08:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649809#M224670</link>
      <description>&lt;P&gt;hey&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;The values are of two types:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;"#DEL": This indicates that the field is deleted.&lt;/LI&gt;&lt;LI&gt;"&amp;lt;expected&amp;gt; =&amp;gt; &amp;lt;actual&amp;gt;": This pattern represents the actual and expected values of the field.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Therefore, we need to group all the fields that have "#DEL" and "null(&amp;lt;actual&amp;gt;)" values.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 08:56:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649809#M224670</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-10T08:56:41Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649881#M224691</link>
      <description>&lt;P&gt;The illustration of desired output eliminates a lot of guess work. &amp;nbsp;You are correct. &amp;nbsp;After renaming the original discrepancyDetails.*, I should have excluded them before preceding.&lt;/P&gt;&lt;P&gt;So, my previous search should address requirement 2 when bad.* are excluded (it cannot be combined into the same stats as 3 based on your illustration).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex mode=sed "s/\/\d+\"/\/\"/g"
| rename discrepancyDetails.* as bad.*
| fields - bad.*
| spath
| stats count(discrepancyDetails.*) as discrepancyDetails.*
| eval legend = "count"
| transpose header_field=legend column_name=Unique_key&lt;/LI-CODE&gt;&lt;P&gt;To address 3, values need to be preserved in stats, then table calculated after transpose.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename discrepancyDetails.* as bad.*
| fields - bad.*
| rex mode=sed "s/\/\d+\"/\/\"/g"
| spath
| stats values(discrepancyDetails.*) as discrepancyDetails.*
| eval legend = "value"
| transpose header_field=legend column_name=Unique_key
| where match(value, "#DEL|=&amp;gt; *null")
| rex field=value mode=sed "s/.+=&amp;gt; *//"
| stats values(Unique_key) as Unique_key count by value
| table Unique_key value count
| rename value as "#DEL or null"&lt;/LI-CODE&gt;&lt;P&gt;The following is a data emulation that gives the exact desired outputs. &amp;nbsp;You can play with it and compare with real data.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval _raw = "{
  \"severity\": \"INFO\",
  \"time\": \"2023-07-09 18:53:53.930\",
  \"Stats\": {
    \"discrepancy\" : 10
  },
  \"discrepancyDetails\": {
    \"record/0\": \"#DEL\",
    \"record/1\": \"#DEL\",
    \"recordD\": \"#DEL\",
    \"recordX\": \"expected =&amp;gt; actual\",
    \"recordY\": \"someExpectedVal =&amp;gt; null\",
    \"recordN\": \"someExpectedValN =&amp;gt; null\"
  }
}
"
| spath
``` data emulation above ```&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 10 Jul 2023 17:19:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/649881#M224691</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-07-10T17:19:08Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650200#M224789</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;please let me know if you are still not clear.&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2023 14:22:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650200#M224789</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-12T14:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650879#M225040</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;this worked fine for requirement 3,&lt;BR /&gt;just a follow up ask for requirement 3, I want to filter out all the fields that do not contain certain substring in the keys,&lt;BR /&gt;I am not really able to figure our how can I filter out this.&lt;BR /&gt;&lt;BR /&gt;for instance, let us say I want to remove all the keys from the result that contain "Y", considering sample example "recordY" would be removed from the result.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 17:48:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650879#M225040</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-17T17:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650901#M225047</link>
      <description>&lt;P&gt;To filter out certain keys, simply add the condition in the last "where" before stats. For example,&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rename discrepancyDetails.* as bad.*
| fields - bad.*
| rex mode=sed "s/\/\d+\"/\/\"/g"
| spath
| stats values(discrepancyDetails.*) as discrepancyDetails.*
| eval legend = "value"
| transpose header_field=legend column_name=Unique_key
| where match(value, "#DEL|=&amp;gt; *null") AND NOT match(Unique_key, "Y$") ``` add any negated condition ```
| rex field=value mode=sed "s/.+=&amp;gt; *//"
| stats values(Unique_key) as Unique_key count by value
| table Unique_key value count
| rename value as "#DEL or null"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:18:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650901#M225047</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-07-18T05:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650914#M225051</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;In requirement 3 what if I want to group remaining keys under different group,&lt;BR /&gt;so my result column would have header '#DEL or null or others' and all the other keys that do not fall under '#DEL' and 'null' category should be grouped under 'others' column.&lt;BR /&gt;could you help me with this query is well?&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jul 2023 05:46:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/650914#M225051</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-18T05:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/651059#M225100</link>
      <description>&lt;P&gt;I'm not sure if I understand. &amp;nbsp;Do you mean something like the following?&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="211.453125px"&gt;&lt;DIV class=""&gt;Unique_key&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="50.25px"&gt;#DEL or null&lt;/TD&gt;&lt;TD width="124px"&gt;other&lt;/TD&gt;&lt;TD width="40px"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="211.453125px"&gt;&lt;DIV class=""&gt;discrepancyDetails.record/&lt;/DIV&gt;&lt;DIV class=""&gt;discrepancyDetails.recordD&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="50.25px"&gt;#DEL&lt;/TD&gt;&lt;TD width="124px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="211.453125px"&gt;discrepancyDetails.recordX&lt;/TD&gt;&lt;TD width="50.25px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="124px"&gt;actual&lt;/TD&gt;&lt;TD width="40px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="211.453125px"&gt;&lt;DIV class=""&gt;discrepancyDetails.recordN&lt;/DIV&gt;&lt;DIV class=""&gt;discrepancyDetails.recordY&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="50.25px"&gt;null&lt;/TD&gt;&lt;TD width="124px"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="40px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;To get the above, just get rid of "where" command and manipulate field name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=value mode=sed "s/.+=&amp;gt; *//"
| stats values(Unique_key) as Unique_key count by value
| eval other = if(match(value, "#DEL|null"), null(), value)
| eval "#DEL or null" = if(match(value, "#DEL|null"), value, null)
| table Unique_key "#DEL or null" other count&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm not sure if the table is useful.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 04:39:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/651059#M225100</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-07-19T04:39:29Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/651060#M225101</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;, I want something like this&lt;/P&gt;&lt;TABLE width="301px"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="211.453px"&gt;&lt;DIV class=""&gt;Unique_key&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="58.0625px"&gt;#DEL or null or others&lt;/TD&gt;&lt;TD width="52.9062px"&gt;count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="211.453px"&gt;&lt;DIV class=""&gt;discrepancyDetails.record/&lt;/DIV&gt;&lt;DIV class=""&gt;discrepancyDetails.recordD&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="58.0625px"&gt;#DEL&lt;/TD&gt;&lt;TD width="52.9062px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="211.453px"&gt;discrepancyDetails.recordX&lt;BR /&gt;.&lt;BR /&gt;.&lt;/TD&gt;&lt;TD width="58.0625px"&gt;others&lt;/TD&gt;&lt;TD width="52.9062px"&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="211.453px"&gt;&lt;DIV class=""&gt;discrepancyDetails.recordN&lt;/DIV&gt;&lt;DIV class=""&gt;discrepancyDetails.recordY&lt;/DIV&gt;&lt;/TD&gt;&lt;TD width="58.0625px"&gt;null&lt;/TD&gt;&lt;TD width="52.9062px"&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| rex field=value mode=sed "s/.+=&amp;gt; *//"
| eval value = if(match(value, "#DEL|null"), value, "others")
| stats values(Unique_key) as Unique_key count by value
| table Unique_key value count
| rename value as "#DEL or null or others"&lt;/LI-CODE&gt;&lt;P&gt;I tried something like this but it doesn't seem to be working not sure why.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 05:32:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/651060#M225101</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-19T05:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Fetching statistics: Unique discrepancy details, removing numerical characters, and identifying null and deleted val</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/651063#M225104</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/33901"&gt;@yuanliu&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;SPAN&gt;I was able to achieve it through this; I missed the part where the value is a multivalued field. After using mvmap, it worked fine.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&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;| rex field=value mode=sed "s/.+=&amp;gt; *//"
| eval value = mvmap(value, if(match(value, "#DEL|null"), value, "others"))
| stats values(Unique_key) as Unique_key count by value
| table Unique_key value count
| rename value as "#DEL or null or others"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 05:44:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Fetching-statistics-Unique-discrepancy-details-removing/m-p/651063#M225104</guid>
      <dc:creator>adikrhd</dc:creator>
      <dc:date>2023-07-19T05:44:51Z</dc:date>
    </item>
  </channel>
</rss>

