<?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 generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330968#M98516</link>
    <description>&lt;P&gt;OK, for older versions, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search here
| eval OverMem=if((mem&amp;gt;80), "YES", null())
| eval OverCpu=if((cpu&amp;gt;80), "YES", null())
| bin _time span=1d
| eval time=strftime(_time, "%m/%d")
| chart count(OverCpu) AS cpu count(OverMem) AS mem OVER host BY time
| rename "cpu: *" AS "* cpu" "mem: *" AS "* mem"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 17 Apr 2017 14:42:15 GMT</pubDate>
    <dc:creator>woodcock</dc:creator>
    <dc:date>2017-04-17T14:42:15Z</dc:date>
    <item>
      <title>How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330963#M98511</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to create a report that looks at two fields: &lt;CODE&gt;mem&lt;/CODE&gt; and &lt;CODE&gt;cpu&lt;/CODE&gt;&lt;BR /&gt;
It should display the count of &lt;CODE&gt;mem&lt;/CODE&gt; and &lt;CODE&gt;cpu&lt;/CODE&gt; by &lt;CODE&gt;devname&lt;/CODE&gt; (Device ID) when  mem&amp;gt;80 and when cpu&amp;gt;80 over time (7 days).&lt;/P&gt;

&lt;P&gt;Each log contains a value for &lt;CODE&gt;devname&lt;/CODE&gt;, &lt;CODE&gt;mem&lt;/CODE&gt; and &lt;CODE&gt;cpu&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Something like this:&lt;/STRONG&gt;&lt;BR /&gt;
&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/2771i3BE583972D79AF8C/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;I can do a stats count for ONE field, but wanted to incorporate both. Maybe need to use contingency?&lt;BR /&gt;
If the report as shown in the above is unattainable, I am open to doing two reports: one for &lt;CODE&gt;mem&lt;/CODE&gt; and another for &lt;CODE&gt;cpu&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thanks everyone in advance!&lt;BR /&gt;
I'll post comments of trial and error as I keep searching the web.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 20:06:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330963#M98511</guid>
      <dc:creator>mhassan24</dc:creator>
      <dc:date>2017-04-14T20:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330964#M98512</link>
      <description>&lt;P&gt;@mhassan24, Have you already built the data in tabular format that you have posted? If not you will have to give some sample raw events.&lt;/P&gt;</description>
      <pubDate>Fri, 14 Apr 2017 22:43:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330964#M98512</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-14T22:43:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330965#M98513</link>
      <description>&lt;P&gt;What you want is pretty easy to calculate, although I don't know if it makes sense to sum the cpu and memory in this way... &lt;BR /&gt;
But the hard part is formatting... it is quite difficult to produce this exact format in Splunk.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| bucket _time span=1d
| stats sum(mem) as daily_mem sum(cpu) as daily_cpu by devname _time
| eventstats sum(mem) as totalmem sum(cpu) as totalcpu by devname
| where totalmem &amp;gt; 80 or totalcpu &amp;gt; 80
| fields - totalmem totalcpu
| eval daily = daily_mem . "     " . daily_cpu
| eval date = strftime(_time,"%x") . "\nmem      cpu"
| xyseries devname date daily
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The alignment of the data may need to be tweaked, and it may never be perfect.&lt;BR /&gt;
To make the reports separately is easier; here is one for just memory&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| bucket _time span=1d
| eval date = strftime(_time,"%x")
| stats sum(mem) as mem by devname date
| addtotals
| where total &amp;gt; 80
| fields - total
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 15 Apr 2017 06:16:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330965#M98513</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2017-04-15T06:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330966#M98514</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search here
| eval OverMem=if((mem&amp;gt;80), "YES", null()),
       OverCpu=if((cpu&amp;gt;80), "YES", null())
| bin _time span=1d
| eval time=strftime(_time, "%m/%d")
| chart count(OverCpu) AS cpu count(OverMem) AS mem OVER host BY time
| rename "cpu: *" AS "* cpu" "mem: *" AS "* mem"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 16 Apr 2017 00:15:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330966#M98514</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-16T00:15:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330967#M98515</link>
      <description>&lt;P&gt;Thanks woodcock! I altered the report to only have mem for now.&lt;/P&gt;

&lt;P&gt;But, had two questions for you:&lt;/P&gt;

&lt;P&gt;1) How could the report be altered to only show devnames with counts (i.e. instances of mem &amp;gt; 80), omitting the others?&lt;BR /&gt;
2) Is there a way to get a total count as the last column?&lt;/P&gt;

&lt;P&gt;Thanks again for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 13:47:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330967#M98515</guid>
      <dc:creator>mhassan24</dc:creator>
      <dc:date>2017-04-17T13:47:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330968#M98516</link>
      <description>&lt;P&gt;OK, for older versions, try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Your base search here
| eval OverMem=if((mem&amp;gt;80), "YES", null())
| eval OverCpu=if((cpu&amp;gt;80), "YES", null())
| bin _time span=1d
| eval time=strftime(_time, "%m/%d")
| chart count(OverCpu) AS cpu count(OverMem) AS mem OVER host BY time
| rename "cpu: *" AS "* cpu" "mem: *" AS "* mem"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Apr 2017 14:42:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330968#M98516</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-17T14:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330969#M98517</link>
      <description>&lt;P&gt;Works really well and the query makes sense!&lt;/P&gt;

&lt;P&gt;How could the following be achieved? &lt;BR /&gt;
Feel free to give a tip without the actual query. I don't mind searching and figuring it out&lt;/P&gt;

&lt;P&gt;1) How could the report be altered to only show devnames with counts (i.e. instances of mem &amp;gt; 80), omitting the others?&lt;BR /&gt;
2) Is there a way to get a total count as the last column?&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 15:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330969#M98517</guid>
      <dc:creator>mhassan24</dc:creator>
      <dc:date>2017-04-17T15:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330970#M98518</link>
      <description>&lt;P&gt;I am not sure about #1 (I do not understand the ask) but for #2 use &lt;CODE&gt;addtotals&lt;/CODE&gt; command:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.3/SearchReference/Addtotals"&gt;http://docs.splunk.com/Documentation/Splunk/6.5.3/SearchReference/Addtotals&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;P.S. Don't forget to upvote helpful answers and click &lt;CODE&gt;Accept&lt;/CODE&gt; if when something works.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Apr 2017 23:08:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330970#M98518</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-04-17T23:08:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330971#M98519</link>
      <description>&lt;P&gt;Thanks woodcock! Much appreciated&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 15:25:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330971#M98519</guid>
      <dc:creator>mhassan24</dc:creator>
      <dc:date>2017-04-18T15:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330972#M98520</link>
      <description>&lt;P&gt;For #1, the ask is if the total mem&amp;gt;80 is 0, then I'd like it not to be on the chart displayed by the query&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 15:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330972#M98520</guid>
      <dc:creator>mhassan24</dc:creator>
      <dc:date>2017-04-18T15:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to generate a search that will the display the count of two fields if the memory and CPU usage is greater than 80 per day?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330973#M98521</link>
      <description>&lt;P&gt;Nvm, was able to do it with: &lt;CODE&gt;where Total &amp;gt; 1&lt;/CODE&gt;&lt;BR /&gt;
Thank you again!&lt;/P&gt;</description>
      <pubDate>Tue, 18 Apr 2017 15:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-generate-a-search-that-will-the-display-the-count-of-two/m-p/330973#M98521</guid>
      <dc:creator>mhassan24</dc:creator>
      <dc:date>2017-04-18T15:37:27Z</dc:date>
    </item>
  </channel>
</rss>

