<?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: Does the use of the stats command on a field clear that field's value? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184087#M53036</link>
    <description>&lt;P&gt;Fantastic, this is perfect, provides exactly what I was asking for. Thank you!&lt;/P&gt;

&lt;P&gt;No, reading the docs yet again on stats doesn't do much for me, that's why there's Q&amp;amp;A places like this ...   &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Award Points to Chanfoli!&lt;/P&gt;</description>
    <pubDate>Wed, 14 Jan 2015 20:49:49 GMT</pubDate>
    <dc:creator>Michael</dc:creator>
    <dc:date>2015-01-14T20:49:49Z</dc:date>
    <item>
      <title>Does the use of the stats command on a field clear that field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184083#M53032</link>
      <description>&lt;P&gt;I'm trying to find visitors (IP addresses) to my web site that present with more than one UserAgent. (i.e., Baidu is known to change it's UserAgent in mid-stream...).&lt;/P&gt;

&lt;P&gt;This works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=webserver GET  | stats dc(useragent) AS num_agents by clientip |  where num_agents&amp;gt;1 | table clientip,num_agents
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=webserver GET  | transaction clientip | table clientip,useragent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But, if I stats the useragent field, it all of a sudden empties it... So, the below works -- but the values in the column for useragent is empty:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=webserver GET | transaction clientip | stats dc(useragent) AS num_agents by clientip |  where num_agents&amp;gt;1 | table clientip,useragent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thots?&lt;/P&gt;

&lt;P&gt;thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2015 18:40:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184083#M53032</guid>
      <dc:creator>Michael</dc:creator>
      <dc:date>2015-01-14T18:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Does the use of the stats command on a field clear that field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184084#M53033</link>
      <description>&lt;P&gt;In short, yes. &lt;STRONG&gt;stats&lt;/STRONG&gt; works on the results you provide and only returns the fields that you specify. You might try adding values(useragent) to your stats command. &lt;/P&gt;

&lt;P&gt;More info on stats here:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/Search/Usethestatscommandandfunctions"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/Search/Usethestatscommandandfunctions&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I would add that I am not sure of your intended use of transaction in this search. It looks to me like the net effect with transaction defaults would be to group all of your events with the same client ip  (up to 1000) in the search into a single result and add potentially meaningless fields, depending on the data in your logs. It may also slow down your search quite a bit.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2015 18:56:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184084#M53033</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-14T18:56:02Z</dc:date>
    </item>
    <item>
      <title>Re: Does the use of the stats command on a field clear that field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184085#M53034</link>
      <description>&lt;P&gt;Here is a search I was playing with which might get you closer to what you appear to be looking for, without the transaction overhead and possible confusion.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;GET clientip=* | stats dc(useragent) AS num_agents, values(useragent) by clientip | sort -num_agents
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:38:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184085#M53034</guid>
      <dc:creator>chanfoli</dc:creator>
      <dc:date>2015-01-14T19:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: Does the use of the stats command on a field clear that field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184086#M53035</link>
      <description>&lt;P&gt;Just to be precise: &lt;CODE&gt;stats&lt;/CODE&gt; does not clear any field's value - but any field not provided with a &lt;CODE&gt;stats&lt;/CODE&gt; command is not available afterwards in the search pipeline. Have a look at the &lt;CODE&gt;eventstats&lt;/CODE&gt; command &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/Eventstats"&gt;http://docs.splunk.com/Documentation/Splunk/6.2.1/SearchReference/Eventstats&lt;/A&gt; which handle that.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2015 19:47:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184086#M53035</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2015-01-14T19:47:35Z</dc:date>
    </item>
    <item>
      <title>Re: Does the use of the stats command on a field clear that field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184087#M53036</link>
      <description>&lt;P&gt;Fantastic, this is perfect, provides exactly what I was asking for. Thank you!&lt;/P&gt;

&lt;P&gt;No, reading the docs yet again on stats doesn't do much for me, that's why there's Q&amp;amp;A places like this ...   &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Award Points to Chanfoli!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2015 20:49:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184087#M53036</guid>
      <dc:creator>Michael</dc:creator>
      <dc:date>2015-01-14T20:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Does the use of the stats command on a field clear that field's value?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184088#M53037</link>
      <description>&lt;BLOCKQUOTE&gt;
&lt;P&gt;"Just to be precise: stats does not clear any field's value - but any field not provided with a stats command is not available afterwards in the search pipeline."&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 14 Jan 2015 20:51:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Does-the-use-of-the-stats-command-on-a-field-clear-that-field-s/m-p/184088#M53037</guid>
      <dc:creator>Michael</dc:creator>
      <dc:date>2015-01-14T20:51:36Z</dc:date>
    </item>
  </channel>
</rss>

