<?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: Possible losing field values when using &amp;quot;stats...by field_name&amp;quot; in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398971#M115668</link>
    <description>&lt;P&gt;Thanks, woodcock, but there is no "... | sort" using  anywhere. And the output is less than 50 rows.&lt;/P&gt;

&lt;P&gt;PS: the full command is like the following:&lt;BR /&gt;
eventtype=cisco-security-events dest_ip!="255.255.255.255" dest_ip!="0.0.0.0" src_ip="*" | eval isLocalIP=&lt;CODE&gt;local-ip-list(src_ip)&lt;/CODE&gt; | where isLocalIP!=1 AND isnotnull(threat_reason) AND threat_reason!="-" | dedup src_ip | table src_ip | stats count by src_ip&lt;/P&gt;

&lt;P&gt;among it, the macro is defined as the following:&lt;BR /&gt;
case(cidrmatch("10.0.0.0/8", $field$),1,cidrmatch("172.12.0.0/12", $field$),1,cidrmatch("192.168.0.0/16", $field$),1,cidrmatch("169.254.0.0/16", $field$),1,cidrmatch("fe80::/64", $field$),1,cidrmatch("fec0::/10", $field$),1,cidrmatch("fc00::/7", $field$),1,$field$=="0.0.0.0",1,isnotnull($field$),0)&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 23:31:53 GMT</pubDate>
    <dc:creator>PeterZhang</dc:creator>
    <dc:date>2020-09-29T23:31:53Z</dc:date>
    <item>
      <title>Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398969#M115666</link>
      <description>&lt;P&gt;I thought the result of using "...| dedup src_ip | table src_ip | sort str(src_ip)" should be the same with the result of using "...| stats count by src_ip | fields - count".&lt;/P&gt;

&lt;P&gt;But actually it may lose some values for "src_ip" field when using "...| stats count by src_ip | fields - count".&lt;/P&gt;

&lt;P&gt;If using "...| search src_ip=59.160.18.202", it can find related events,&lt;/P&gt;

&lt;P&gt;if using the "...| dedup src_ip | table src_ip | sort str(src_ip)" command, it can find "59.160.18.202" for "src_ip" field on "Statistics" tab,&lt;/P&gt;

&lt;P&gt;but if using the  "...| stats count by src_ip | fields - count" command, the value "59.160.18.202" for "src_ip" field on "Statistics" tab will be lost.&lt;/P&gt;

&lt;P&gt;Not sure what's the reason, need your kind advice, thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:21:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398969#M115666</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2020-09-29T23:21:31Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398970#M115667</link>
      <description>&lt;P&gt;Are you using &lt;CODE&gt;... | sort&lt;/CODE&gt; anywhere?  If so, try using &lt;CODE&gt;| sort 0 ....&lt;/CODE&gt;.  The &lt;CODE&gt;0&lt;/CODE&gt; makes it unlimited; without it, Splunk limits the output set to 10K rows.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 06:40:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398970#M115667</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-01T06:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398971#M115668</link>
      <description>&lt;P&gt;Thanks, woodcock, but there is no "... | sort" using  anywhere. And the output is less than 50 rows.&lt;/P&gt;

&lt;P&gt;PS: the full command is like the following:&lt;BR /&gt;
eventtype=cisco-security-events dest_ip!="255.255.255.255" dest_ip!="0.0.0.0" src_ip="*" | eval isLocalIP=&lt;CODE&gt;local-ip-list(src_ip)&lt;/CODE&gt; | where isLocalIP!=1 AND isnotnull(threat_reason) AND threat_reason!="-" | dedup src_ip | table src_ip | stats count by src_ip&lt;/P&gt;

&lt;P&gt;among it, the macro is defined as the following:&lt;BR /&gt;
case(cidrmatch("10.0.0.0/8", $field$),1,cidrmatch("172.12.0.0/12", $field$),1,cidrmatch("192.168.0.0/16", $field$),1,cidrmatch("169.254.0.0/16", $field$),1,cidrmatch("fe80::/64", $field$),1,cidrmatch("fec0::/10", $field$),1,cidrmatch("fc00::/7", $field$),1,$field$=="0.0.0.0",1,isnotnull($field$),0)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:31:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398971#M115668</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2020-09-29T23:31:53Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398972#M115669</link>
      <description>&lt;P&gt;Let's go line by line:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventtype=cisco-security-events dest_ip!="255.255.255.255" dest_ip!="0.0.0.0" src_ip="*"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You should add &lt;CODE&gt;index=...&lt;/CODE&gt; to EVERY search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval isLocalIP=`local-ip-list(src_ip)`
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That one is fine&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where isLocalIP!=1 AND isnotnull(threat_reason) AND threat_reason!="-"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;There is redundancy here and this is more efficient:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| where isLocalIP!=1 AND threat_reason!="-"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the rest of your stuff makes no sense whatsoever so clearly the commands do not do what you think they do.  Together they ensure that &lt;CODE&gt;count&lt;/CODE&gt; will always have a value of &lt;CODE&gt;1&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| dedup src_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The command above keeps exactly 1 event for each distinct value of &lt;CODE&gt;src_ip&lt;/CODE&gt;.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| table src_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is not only unnecessary, but craters your search performance because &lt;CODE&gt;table&lt;/CODE&gt; is a finalizing command.  Remove that line completely and replace it with nothing.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count by src_ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Because we already eliminated everything but 1 event for each distinct value of &lt;CODE&gt;src_ip&lt;/CODE&gt;, you might just as well do something silly like this, because you will get the same result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval count = "1"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 03 Mar 2019 05:24:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398972#M115669</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-03T05:24:42Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398973#M115670</link>
      <description>&lt;P&gt;Rather than running dedup + table, have you tried running stats values(src_ip)? Do you get different results?&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 05:30:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398973#M115670</guid>
      <dc:creator>johnvr</dc:creator>
      <dc:date>2019-03-03T05:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398974#M115671</link>
      <description>&lt;P&gt;Sorry, the above commands are not using for a certain purpose except SPL exploring.&lt;/P&gt;

&lt;P&gt;Yes, table command is not necessary, but the problem is that if not using "dedup" before "stats", one of the value of "src_ip" will get lost. By the way, it lost on "statistic" tab as well. "dedup" can keep exactly 1 event for each distinct value of "src_ip", but still doesn't make sense that some values(59.160.18.202) of the "src_ip" will get lost when using "stats" without "dedup".&lt;/P&gt;

&lt;P&gt;Also attached the comparing charts of these two situation as the following:&lt;BR /&gt;
&lt;IMG src="https://drive.google.com/open?id=1Ge81kDwiT5zAKV275wQAr6-FFhXWLT_t" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://drive.google.com/open?id=1recLI8akRt26h0XWWF6Fvaou6kbh2TNE" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:32:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398974#M115671</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2020-09-29T23:32:42Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398975#M115672</link>
      <description>&lt;P&gt;The value "59.160.18.202" for "src_ip" field will get lost on both "stats values(src_ip)" and "stats list(src_ip)" statistic as well unless adding preceding "dedup".&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 23:32:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398975#M115672</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2020-09-29T23:32:45Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398976#M115673</link>
      <description>&lt;P&gt;Show me the tabular results without the &lt;CODE&gt;dedup&lt;/CODE&gt;command in the search.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 07:59:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398976#M115673</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-03T07:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398977#M115674</link>
      <description>&lt;P&gt;Hi woodcock, I exported the tabular results without/with dedup command to the following link:&lt;BR /&gt;
&lt;A href="https://drive.google.com/open?id=1otAU7hqSG5VwUQPdJsixe54pYnCqmvdl"&gt;https://drive.google.com/open?id=1otAU7hqSG5VwUQPdJsixe54pYnCqmvdl&lt;/A&gt;&lt;BR /&gt;
&lt;A href="https://drive.google.com/open?id=1gvVB-JjFY2CmlQjXhFEMhPGP3YzuZWoS"&gt;https://drive.google.com/open?id=1gvVB-JjFY2CmlQjXhFEMhPGP3YzuZWoS&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;thanks.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 08:10:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398977#M115674</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2019-03-03T08:10:38Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398978#M115675</link>
      <description>&lt;P&gt;This is absolutely a bug.  Open a support case.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 08:30:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398978#M115675</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-03T08:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398979#M115676</link>
      <description>&lt;P&gt;Thanks, that's what I think as well.&lt;BR /&gt;
But I don't have a support account to report the bug.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 08:33:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398979#M115676</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2019-03-03T08:33:40Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398980#M115677</link>
      <description>&lt;P&gt;If you bought a Splunk license, you are obligated to maintain a support contact as well.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 08:36:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398980#M115677</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-03-03T08:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: Possible losing field values when using "stats...by field_name"</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398981#M115678</link>
      <description>&lt;P&gt;I don't have a Splunk license so far. I think that it would be better if Splunk can have some way to receive potential bug report even without a Splunk license.&lt;/P&gt;</description>
      <pubDate>Sun, 03 Mar 2019 08:42:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Possible-losing-field-values-when-using-quot-stats-by-field-name/m-p/398981#M115678</guid>
      <dc:creator>PeterZhang</dc:creator>
      <dc:date>2019-03-03T08:42:19Z</dc:date>
    </item>
  </channel>
</rss>

