<?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: splunk search query for CPU usage in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579831#M202039</link>
    <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this query seems to be specefic to fix inputs.....while all this values are subjecteedd to change dynamically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want to calculate average % usage of field "system CPU".&lt;/P&gt;&lt;P&gt;I HAVE&amp;nbsp; other fields extracted like : index type,host,sourcetype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i can create dasboards for cpu usage by&amp;nbsp;&amp;nbsp;index type,host,sourcetype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: we dont have extracted field for cpu percentage (CPU_perc)&lt;/P&gt;</description>
    <pubDate>Tue, 04 Jan 2022 07:08:46 GMT</pubDate>
    <dc:creator>Atul1507</dc:creator>
    <dc:date>2022-01-04T07:08:46Z</dc:date>
    <item>
      <title>splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579447#M201917</link>
      <description>&lt;P&gt;Hi i am new to splunk.&lt;BR /&gt;i have splink event like this&lt;BR /&gt;" system CPU | 6.039 % | system time | 0.009 % |&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;how can i get avg CPU % usage value against index type ? via report or dashboards.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 10:51:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579447#M201917</guid>
      <dc:creator>Atul1507</dc:creator>
      <dc:date>2021-12-29T10:51:10Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579450#M201920</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241798"&gt;@Atul1507&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you have many evevnts like the one you shared, do you want to calculate the average or the max value of CPU usage?&lt;/P&gt;&lt;P&gt;supposing that you already have the extraction of the CPU usave percentage, in numbers (without the % char)) and If average, please, try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=*
| stats avg(CPU_perc) AS CPU_perc BY index&lt;/LI-CODE&gt;&lt;P&gt;If instead you didn't extracted the CPU_perc field, please try something like this (always calculating average):&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=*
| rex "system CPU\|(?&amp;lt;CPU_perc&amp;gt;[^ ]+)\s+\%"
| eval CPU_perc=tonumber(CPU_perc)
| stats avg(CPU_perc) AS CPU_perc BY index&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 11:00:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579450#M201920</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-12-29T11:00:50Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579451#M201921</link>
      <description>&lt;P&gt;i tried these query ..but not seeing any output in CPU_perc field.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 11:23:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579451#M201921</guid>
      <dc:creator>Atul1507</dc:creator>
      <dc:date>2021-12-29T11:23:13Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579452#M201922</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241798"&gt;@Atul1507&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please, what out do you have in&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=*
| rex "system CPU\|(?&amp;lt;CPU_perc&amp;gt;\d+)\s+\%"
| table CPU_perc&lt;/LI-CODE&gt;&lt;P&gt;?&lt;/P&gt;&lt;P&gt;if you haven't any result, the field extraction is wrong, in this case, please share more examples of your data.&lt;/P&gt;&lt;P&gt;If instead you have results, please share some of them.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 11:27:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579452#M201922</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-12-29T11:27:23Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579456#M201924</link>
      <description>&lt;P&gt;cant share more details as its client server.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but there is no field extracted for CPU&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 11:51:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579456#M201924</guid>
      <dc:creator>Atul1507</dc:creator>
      <dc:date>2021-12-29T11:51:01Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579490#M201929</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241798"&gt;@Atul1507&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please, send some log, masking the relevant data (e.g. hostname or IP address), but maintain the data structure.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 29 Dec 2021 15:15:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579490#M201929</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-12-29T15:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579603#M201960</link>
      <description>&lt;P&gt;XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Idle|involuntary context switches|0|user time|0.48%|system time|0.45%|system CPU|7.14687%|iowait|0.0224%&lt;BR /&gt;XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Health|ProcMaxGB|0|ProcAlertGB|0|CurrentGB|16|SysMinFreePct|10|SysAlertFreePct|30|FreePct|77&lt;BR /&gt;XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Idle|involuntary context switches|0|user time|0.46%|system time|0.44%|system CPU|7.11321%|iowait|0.056%&lt;BR /&gt;XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Health|ProcMaxGB|0|ProcAlertGB|0|CurrentGB|16|SysMinFreePct|10|SysAlertFreePct|30|FreePct|77&lt;BR /&gt;XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Idle|involuntary context switches|0|user time|0.61%|system time|0.46%|system CPU|8.64004%|iowait|0.0448%&lt;BR /&gt;XXXXXXXXXXXXXXXXXXXXX"60 gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Health|ProcMaxGB|0|ProcAlertGB|0|CurrentGB|16|SysMinFreePct|10|SysAlertFreePct|30|FreePct|77&lt;/P&gt;</description>
      <pubDate>Thu, 30 Dec 2021 13:43:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579603#M201960</guid>
      <dc:creator>Atul1507</dc:creator>
      <dc:date>2021-12-30T13:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579679#M201984</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241798"&gt;@Atul1507&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;please try this sample:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval ppp="XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Idle|involuntary context switches|0|user time|0.48%|system time|0.45%|system CPU|7.14687%|iowait|0.0224%"
| append [ | makeresults | eval ppp="XXXXXXXXXXXXXXXXXXXXX gsystem.cpp:XXX] System_GSystem|GSystemWatcher|Idle|involuntary context switches|0|user time|0.48%|system time|0.45%|system CPU|12.14687%|iowait|0.0224%" ]
| rex field=ppp "CPU\|(?&amp;lt;system_CPU&amp;gt;[^\%]+)"
| stats avg(system_CPU)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 07:58:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579679#M201984</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-01-04T07:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579831#M202039</link>
      <description>&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But this query seems to be specefic to fix inputs.....while all this values are subjecteedd to change dynamically.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i want to calculate average % usage of field "system CPU".&lt;/P&gt;&lt;P&gt;I HAVE&amp;nbsp; other fields extracted like : index type,host,sourcetype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;so i can create dasboards for cpu usage by&amp;nbsp;&amp;nbsp;index type,host,sourcetype.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: we dont have extracted field for cpu percentage (CPU_perc)&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 07:08:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579831#M202039</guid>
      <dc:creator>Atul1507</dc:creator>
      <dc:date>2022-01-04T07:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579832#M202040</link>
      <description>Hi&lt;BR /&gt;In &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt; 's answer, he will use your given data as a sample. That was lines between makeresults ... rex. In real life you should add from "| rex ..." after that SPL which you are using to generate that sample data. And as you probably have this data on "field" _raw then you should remove field=ppp from rex or replace it as "field = _raw" (or what ever that field is where you sample data is).&lt;BR /&gt;&lt;BR /&gt;Yes, you can generate that data on dashboard with stats ... by index, host, sourcetype.&lt;BR /&gt;r. Ismo</description>
      <pubDate>Tue, 04 Jan 2022 07:14:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579832#M202040</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2022-01-04T07:14:45Z</dc:date>
    </item>
    <item>
      <title>Re: splunk search query for CPU usage</title>
      <link>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579840#M202045</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/241798"&gt;@Atul1507&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;&amp;nbsp;said (thanks to &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;), in my answer you have to find the approach to solve your need, not the full solution to all your needs, also because I can only a subset of your real data.&lt;/P&gt;&lt;P&gt;As he said, I used the | makeresults rows to have your data in my search, but in your real condition, you surely have a search that extract the data to use in this search.&lt;/P&gt;&lt;P&gt;So, analyze my answer to understand the approach to follow and adapt it to your real situation:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;extract all the fields you need, not only the one I used in the sample,&lt;/LI&gt;&lt;LI&gt;use, in the stats command, the BY cause to group the results for index or host or sourcetype, etc...&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 04 Jan 2022 07:57:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/splunk-search-query-for-CPU-usage/m-p/579840#M202045</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-01-04T07:57:25Z</dc:date>
    </item>
  </channel>
</rss>

