<?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 How to stats count and still have all fields available afterwards? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709248#M239701</link>
    <description>&lt;P&gt;Dear experts&lt;/P&gt;&lt;P&gt;According to the documentation after stats, I have only the fields left used during stats.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        | table importZeit_uF zbpIdentifier bpKurzName zbpIdentifier_bp status stoerCode
        
        | where stoerCode IN ("K02")
        | stats count as periodCount by zbpIdentifier 
        | sort -periodCount 
        | head 10
        | fields zbpIdentifier zbpIdentifier_bp periodCount importZeit_uF&lt;/LI-CODE&gt;&lt;P&gt;To explain in detail:&lt;/P&gt;&lt;P&gt;After table the following fields are available:&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;importZeit_uF zbpIdentifier bpKurzName zbpIdentifier_bp status stoerCode&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;After stats count there are only&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;zbpIdentifier periodCount&lt;/STRONG&gt; left.&lt;/P&gt;&lt;P&gt;Question:&amp;nbsp; How to change the code above to get the count, and have all fields available as before?&lt;/P&gt;&lt;P&gt;Thank you for your support.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jan 2025 16:52:04 GMT</pubDate>
    <dc:creator>Ste</dc:creator>
    <dc:date>2025-01-20T16:52:04Z</dc:date>
    <item>
      <title>How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709248#M239701</link>
      <description>&lt;P&gt;Dear experts&lt;/P&gt;&lt;P&gt;According to the documentation after stats, I have only the fields left used during stats.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        | table importZeit_uF zbpIdentifier bpKurzName zbpIdentifier_bp status stoerCode
        
        | where stoerCode IN ("K02")
        | stats count as periodCount by zbpIdentifier 
        | sort -periodCount 
        | head 10
        | fields zbpIdentifier zbpIdentifier_bp periodCount importZeit_uF&lt;/LI-CODE&gt;&lt;P&gt;To explain in detail:&lt;/P&gt;&lt;P&gt;After table the following fields are available:&amp;nbsp;&lt;BR /&gt;&lt;STRONG&gt;importZeit_uF zbpIdentifier bpKurzName zbpIdentifier_bp status stoerCode&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;After stats count there are only&amp;nbsp;&amp;nbsp;&lt;STRONG&gt;zbpIdentifier periodCount&lt;/STRONG&gt; left.&lt;/P&gt;&lt;P&gt;Question:&amp;nbsp; How to change the code above to get the count, and have all fields available as before?&lt;/P&gt;&lt;P&gt;Thank you for your support.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 16:52:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709248#M239701</guid>
      <dc:creator>Ste</dc:creator>
      <dc:date>2025-01-20T16:52:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709249#M239702</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253490"&gt;@Ste&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;you have to add to your stats command:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;values(*) AS *&lt;/LI-CODE&gt;&lt;P&gt;in your case:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;        | table importZeit_uF zbpIdentifier bpKurzName zbpIdentifier_bp status stoerCode
        
        | where stoerCode IN ("K02")
        | stats count as periodCount values(*) AS * by zbpIdentifier 
        | sort -periodCount 
        | head 10
        | fields zbpIdentifier zbpIdentifier_bp periodCount importZeit_uF&lt;/LI-CODE&gt;&lt;P&gt;but they are grouped for the zbpIdentifier.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 17:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709249#M239702</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-01-20T17:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709251#M239703</link>
      <description>One comment: Never use table before stats! After table all processing has moved into SH and it cannot utilize parallel processing with stats. If you want remove some fields before stats use always fields instead of table! You will get more performance that way. Of course after stats you processing continues on SH side, but stats use preprocessing part on each indexers at same time and only merging and final stats processing are done on SH side.&lt;BR /&gt;</description>
      <pubDate>Mon, 20 Jan 2025 18:01:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709251#M239703</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2025-01-20T18:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709255#M239705</link>
      <description>&lt;P&gt;Depends on what the desired outcome looks like. Since stats produces aggregated results you have to ask yourself what is it you really want. If you just want to add some aggregated value to each results row - that's what eventstats is for (be careful with it though because it can be memory-hungry). If you want to get aggregated field values you might use values() or list() as additional aggregation functions.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2025 20:33:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709255#M239705</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-01-20T20:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709258#M239706</link>
      <description>As you can check from there &lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commandsbytype" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Commandsbytype&lt;/A&gt; also this command move actions from indexers to SH side. And as &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt; said this command use lot of memory too.</description>
      <pubDate>Mon, 20 Jan 2025 20:48:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709258#M239706</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2025-01-20T20:48:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709300#M239714</link>
      <description>&lt;P&gt;Here's what I want to achieve:&lt;/P&gt;&lt;P&gt;We have several hundreds of boxes sending messages. The boxes are identified by the name in zbpIdentifier.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I want to know the Top ten of the boxes, depending on the number of messages they have sent over a given period of time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For this Top ten, I want then to display some more data details, that is why I try to "recover" all the data no more available after stats count.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 13:05:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709300#M239714</guid>
      <dc:creator>Ste</dc:creator>
      <dc:date>2025-01-21T13:05:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709303#M239715</link>
      <description>&lt;P&gt;Maybe this will give you what you are looking for, use the stats to include all the fields, and if you dont want the count in the table add a fields command after like | fields - periodCount&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| stats count as periodCount by zbpIdentifier zbpIdentifier_bp periodCount importZeit_uF
| sort -periodCount&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 21 Jan 2025 13:17:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709303#M239715</guid>
      <dc:creator>erikwie</dc:creator>
      <dc:date>2025-01-21T13:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709305#M239717</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253490"&gt;@Ste&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;with my above solution you can reach your target, otherwise you can use a subsearch (less performant):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;your_search&amp;gt; [ search  &amp;lt;your_search&amp;gt;
        | where stoerCode IN ("K02")
        | stats count as periodCount by zbpIdentifier 
        | sort -periodCount 
        | head 10
        | fields zbpIdentifier ]
| table importZeit_uF zbpIdentifier bpKurzName zbpIdentifier_bp status stoerCode
        &lt;/LI-CODE&gt;&lt;P&gt;I prefer the other solution.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 13:18:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709305#M239717</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2025-01-21T13:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709309#M239719</link>
      <description>&lt;P&gt;There are several possible approaches but each of them has its own drawbacks.&lt;/P&gt;&lt;P&gt;The most obvious three are:&lt;/P&gt;&lt;P&gt;1) Use eventstats to add count to events, sort and limit by the count value. (might be memory-intensive as I said earlier)&lt;/P&gt;&lt;P&gt;2) Use subsearch to find the count, then search your whole body of data for those events (if you can't use "fast" commands like tstats for your subsearch you might hit all the subsearch-related problems; also you're effectively digging twice through your whole data set)&lt;/P&gt;&lt;P&gt;3) Add more values() aggregations to your stats listing specific fields (might cause problems with "linking" values from different fields; especially if potentially empty fields are involved).&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2025 14:40:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709309#M239719</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2025-01-22T14:40:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to stats count and still have all fields available afterwards?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709577#M239812</link>
      <description>&lt;P&gt;I've tried to test this, but it did not work for me.&lt;BR /&gt;The whole search was blocked and did not return any data.&amp;nbsp;&lt;BR /&gt;No need to dig in further here, as I had anyway to turn upside down the whole dashboard to solve performance issues. This turning upside down has also solved the issue discussed in here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 23 Jan 2025 10:21:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-stats-count-and-still-have-all-fields-available/m-p/709577#M239812</guid>
      <dc:creator>Ste</dc:creator>
      <dc:date>2025-01-23T10:21:04Z</dc:date>
    </item>
  </channel>
</rss>

