<?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 display certain stats values command in a search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419921#M120746</link>
    <description>&lt;P&gt;Also: doing a dedup on only process_name doesn't make much sense if you want to get results for each host. I guess you will want to do &lt;CODE&gt;| dedup process_name host&lt;/CODE&gt;. Then again: if you have already done that, there is no point in doing a stats like that. As you already have the latest line for each host,process_name pair.&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 00:53:36 GMT</pubDate>
    <dc:creator>FrankVl</dc:creator>
    <dc:date>2020-09-30T00:53:36Z</dc:date>
    <item>
      <title>How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419915#M120740</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;

&lt;P&gt;I use the stats command below&lt;BR /&gt;
but some process_name have no process_cpu_used_percent value&lt;BR /&gt;
So how to do for displaying in my stats values command only the process_name which have a process_cpu_used_percent?&lt;BR /&gt;
thanks in advance&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats latest(time) as time, values(COUNTRY) as COUNTRY, values(TOWN) as TOWN, values(SITE) as SITE, values(ROOM) as ROOM, values(process_name) as process_name, values(process_cpu_used_percent) as process_cpu_used_percent by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419915#M120740</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-30T00:53:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419916#M120741</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Please try below query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| where isnotnull(process_cpu_used_percent)
| stats latest(time) as time, values(COUNTRY) as COUNTRY, values(TOWN) as TOWN, values(SITE) as SITE, values(ROOM) as ROOM, values(process_name) as process_name, values(process_cpu_used_percent) as process_cpu_used_percent by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 08:54:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419916#M120741</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-06-12T08:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419917#M120742</link>
      <description>&lt;P&gt;hi&lt;BR /&gt;
it doesnt works&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| inputlookup host.csv 
    | table host] index="x" sourcetype="perfmonmk:process" 
| where process_cpu_used_percent&amp;gt;80 
| lookup x.csv HOSTNAME as host output SITE COUNTRY TOWN ROOM 
| where SITE=$SITE$ 
| eval time = strftime(_time, "%m/%d/%Y %H:%M") 
| dedup process_name 
| eval process_cpu_used_percent=round(process_cpu_used_percent,2). " %" 
| where isnotnull(process_cpu_used_percent) 
| stats latest(time) as time, values(COUNTRY) as COUNTRY, values(TOWN) as TOWN, values(SITE) as SITE, values(ROOM) as ROOM, values(process_name) as process_name, values(process_cpu_used_percent) as process_cpu_used_percent by host
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jun 2019 09:11:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419917#M120742</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-06-12T09:11:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419918#M120743</link>
      <description>&lt;P&gt;Filtering the results for only those containing process_cpu_used_percent values as &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/163905"&gt;@harsmarvania57&lt;/a&gt; suggests would be a good start. There is still another issue with your approach though. &lt;CODE&gt;values()&lt;/CODE&gt; returns the values of that field in lexicographic order, which means, that you loose the correlation between process_name and the process_cpu_used_percent. You get a list of process names and a list of cpu percentages, but have no way of telling which belongs to which.&lt;/P&gt;

&lt;P&gt;The following would be a better way to get the latest process_cpu_used_percent value for each process on each host.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
 | where isnotnull(process_cpu_used_percent)
 | stats latest(time) as time, values(COUNTRY) as COUNTRY, values(TOWN) as TOWN, values(SITE) as SITE, values(ROOM) as ROOM,  latest(process_cpu_used_percent) as process_cpu_used_percent by host,process_name
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note: I moved the process_name to the by clause and changed &lt;CODE&gt;values(process_cpu_used_percent)&lt;/CODE&gt; to &lt;CODE&gt;latest(process_cpu_used_percent)&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Instead of doing &lt;CODE&gt;| where isnotnull(process_cpu_used_percent)&lt;/CODE&gt; you can also simply add &lt;CODE&gt;process_cpu_used_percent=*&lt;/CODE&gt; to your initial search (assuming this is a field that is present in your events and not the result of some intermediate calculation).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419918#M120743</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T00:53:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419919#M120744</link>
      <description>&lt;P&gt;&lt;CODE&gt;| where process_cpu_used_percent&amp;gt;80&lt;/CODE&gt; already returns only events with this field (and additionally dropping any of them where it is below 80). So I don't see how this can result in output with empty process_cpu_used_percent values???&lt;/P&gt;

&lt;P&gt;But perhaps take a look at my answer below for improving your stats command in general, as your current approach is flawed.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419919#M120744</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T00:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419920#M120745</link>
      <description>&lt;P&gt;As you are using &lt;CODE&gt;| where process_cpu_used_percent&amp;gt;80&lt;/CODE&gt; initially, I don't think &lt;CODE&gt;| where isnotnull(process_cpu_used_percent)&lt;/CODE&gt; is necessary in this case because you are already filtering &lt;CODE&gt;process_cpu_used_percent&lt;/CODE&gt; initially with values greater 80.&lt;/P&gt;

&lt;P&gt;We would like to require some rawdata to test this (please mask any sensitive data).&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 09:24:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419920#M120745</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-06-12T09:24:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419921#M120746</link>
      <description>&lt;P&gt;Also: doing a dedup on only process_name doesn't make much sense if you want to get results for each host. I guess you will want to do &lt;CODE&gt;| dedup process_name host&lt;/CODE&gt;. Then again: if you have already done that, there is no point in doing a stats like that. As you already have the latest line for each host,process_name pair.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419921#M120746</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T00:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419922#M120747</link>
      <description>&lt;P&gt;i candoing | where process_cpu_used_percent=* because I already doing | where process_cpu_used_percent&amp;gt;80&lt;BR /&gt;
you code works fine even if it would be better for me to have in a same line all the process where process_cpu_used_percent has a value by host &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419922#M120747</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-30T00:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419923#M120748</link>
      <description>&lt;P&gt;Yeah, as mentioned in one of my other comments: filtering for process_cpu_used_percent is not needed if you already do | where process_cpu_used_percent&amp;gt;80. But you can simply move that to your initial search instead of a separate where command.&lt;/P&gt;

&lt;P&gt;But take a look at my other comments as well, because your approach (especially the dedup) still seems weird.&lt;/P&gt;

&lt;P&gt;There are ways to get it on a single line, but using values() is not the best way, as (like I mentioned) you loose track of which percentage was for which process.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419923#M120748</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T00:53:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419924#M120749</link>
      <description>&lt;P&gt;sorry I have a lot of misundestanding because the language&lt;BR /&gt;
ok for dedup for the rest I do a synthesis :&lt;/P&gt;

&lt;P&gt;In my initial dashboard I have now :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| inputlookup host.csv 
    | table host] index="ai-wkst-perfmon-fr" sourcetype="perfmonmk:process" 
| bucket _time span=3m 
| where process_cpu_used_percent&amp;gt;80 

| lookup lookup_cmdb_fo_all.csv HOSTNAME as host output SITE 
| search SITE=$tok_filtersite|s$ 
| stats count(process_name) as Total by host
| sort -Total limit=10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In the drilldown I have :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[| inputlookup host.csv 
    | table host] index="ai-wkst-perfmon-fr" sourcetype="perfmonmk:process" 
| where process_cpu_used_percent&amp;gt;80 
| lookup lookup_cmdb_fo_all.csv HOSTNAME as host output SITE COUNTRY TOWN ROOM 
| where SITE=$SITE$ 
| eval time = strftime(_time, "%m/%d/%Y %H:%M") 
| eval process_cpu_used_percent=round(process_cpu_used_percent,2). " %" 
| stats latest(time) as time, values(COUNTRY) as COUNTRY, values(TOWN) as TOWN, values(SITE) as SITE, values(ROOM) as ROOM, latest(process_cpu_used_percent) as process_cpu_used_percent by host process_name
| table time host COUNTRY TOWN SITE ROOM process_name process_cpu_used_percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;is there still weird things??&lt;BR /&gt;
I also doesnt understand to things : I havent the same number of events in the 2 searches and why I am obliget to used also  | where process_cpu_used_percent&amp;gt;80  in my drilldown?&lt;BR /&gt;
Normally the data have been already filtered in the dashboard source no??&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419924#M120749</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2020-09-30T00:53:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419925#M120750</link>
      <description>&lt;P&gt;You mean the Total in the dashboard is larger than when you manually count the number of process names listed for a certain host in your drilldown search?&lt;/P&gt;

&lt;P&gt;That makes sense, as you do a &lt;CODE&gt;count(process_name)&lt;/CODE&gt;, which simply counts the number of events with a value in the process_name field. It doesn't count unique process names. If you want to count unique process names by host, you need to use dc(process_name).&lt;/P&gt;

&lt;P&gt;A drilldown is just a new search ran on its own (but possibly parameterized by values from your dashboard).&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 00:53:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419925#M120750</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2020-09-30T00:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to display certain stats values command in a search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419926#M120751</link>
      <description>&lt;P&gt;thanks you are the best&lt;BR /&gt;
and sorry for all my questions but i am rookie have never been teached and have no support around me....&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jun 2019 10:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-display-certain-stats-values-command-in-a-search/m-p/419926#M120751</guid>
      <dc:creator>jip31</dc:creator>
      <dc:date>2019-06-12T10:32:59Z</dc:date>
    </item>
  </channel>
</rss>

