<?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: Format output for timechart by in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448011#M126967</link>
    <description>&lt;P&gt;Hi Kamlesh&lt;BR /&gt;
I shared some sample events in the answer below.&lt;BR /&gt;
Thanks for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 07 Feb 2019 13:10:57 GMT</pubDate>
    <dc:creator>tgdvopab</dc:creator>
    <dc:date>2019-02-07T13:10:57Z</dc:date>
    <item>
      <title>Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448007#M126963</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;

&lt;P&gt;My splunk search generates the following output via timechart:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time;cpu_core:host1;cpu_core:host2
2019-02-06 00:30:00;1;2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Because I use the "by-clause" in the timechart, I get the field names like above --&amp;gt; cpu_core:hostname&lt;/P&gt;

&lt;P&gt;But I want for each hostname one own rown, for example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time,hostname;cpu_core
2019-02-06 00:30:00;host1;1
2019-02-06 00:30:00;host2;2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;How can I achieve this?&lt;/P&gt;

&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 12:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448007#M126963</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2019-02-07T12:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448008#M126964</link>
      <description>&lt;P&gt;@tgdvopab,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your current search"|rename "cpu_core: *" as *|untable _time,hostname,cpu_core
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If this is not what your are looking for, please provide your current search&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 12:49:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448008#M126964</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-02-07T12:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448009#M126965</link>
      <description>&lt;P&gt;@tgdvopab &lt;BR /&gt;
Can you please share sample events?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 12:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448009#M126965</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-02-07T12:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448010#M126966</link>
      <description>&lt;P&gt;Thank you very much! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; This seems to work as long as I have one field. What if I have multiple fields?&lt;BR /&gt;
My query looks like the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=performance_monitoring sourcetype="perf:cpu"
| timechart limit=0 useother=false span=30min avg(cpu_user_percent) as avg_cpu_user_percent, avg(cpu_system_percent) as avg_cpu_system_percent by hostname
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The following fields are generated:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time;avg_cpu_system_percent: host1;avg_cpu_system_percent: host2;avg_cpu_user_percent: host1;avg_cpu_user_percent: host2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And the data looks like the following:&lt;/P&gt;

&lt;P&gt;2019-02-06 01:30:00;0.08933333333333333;0.11600000000000002;0.166;0.18533333333333335&lt;BR /&gt;
2019-02-06 02:00:00;0.08833333333333335;0.109;0.164;0.18233333333333332&lt;/P&gt;

&lt;P&gt;Now I would like to have the fields in the same order as explained:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time;hostname;avg_cpu_system_percent;avg_cpu_user_percent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is this possible?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 13:10:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448010#M126966</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2019-02-07T13:10:20Z</dc:date>
    </item>
    <item>
      <title>Re: Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448011#M126967</link>
      <description>&lt;P&gt;Hi Kamlesh&lt;BR /&gt;
I shared some sample events in the answer below.&lt;BR /&gt;
Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 13:10:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448011#M126967</guid>
      <dc:creator>tgdvopab</dc:creator>
      <dc:date>2019-02-07T13:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448012#M126968</link>
      <description>&lt;P&gt;@tgdvopab &lt;/P&gt;

&lt;P&gt;you can use something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=performance_monitoring sourcetype="perf:cpu" | bin _time span=30m | stats avg(cpu_user_percent) as avg_cpu_user_percent, avg(cpu_system_percent) as avg_cpu_system_percent by _time, hostname
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 13:50:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448012#M126968</guid>
      <dc:creator>vishaltaneja070</dc:creator>
      <dc:date>2019-02-07T13:50:28Z</dc:date>
    </item>
    <item>
      <title>Re: Format output for timechart by</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448013#M126969</link>
      <description>&lt;P&gt;@tgdvopab,&lt;/P&gt;

&lt;P&gt;I'm adding in @renjith.nair's search. Can you please try this search?? &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=performance_monitoring sourcetype="perf:cpu" 
| timechart limit=0 useother=false span=30min avg(cpu_user_percent) as avg_cpu_user_percent, avg(cpu_system_percent) as avg_cpu_system_percent by hostname 
| untable _time,hostname,cpu_core 
| eval column="",host="" 
| foreach hostname 
    [ eval column=mvindex(split('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',":"),0),host=mvindex(split('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',":"),1) ] 
| eval {column}=cpu_core 
| fields - cpu_core,hostname,column 
| stats values(*) as * by _time host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;My Sample Search:&lt;/STRONG&gt; I've used internal index to perform this like operations. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="_internal" component=* group=per_* 
| timechart avg(kbps) as avg_cpu_user_percent, avg(kb) as avg_cpu_system_percent by group 
| untable _time,hostname,cpu_core 
| eval column="",host="" 
| foreach hostname 
    [ eval column=mvindex(split('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',":"),0),host=mvindex(split('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;',":"),1) ] 
| eval {column}=cpu_core | fields - cpu_core,hostname,column | stats values(*) as * by _time host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 14:21:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Format-output-for-timechart-by/m-p/448013#M126969</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-02-07T14:21:13Z</dc:date>
    </item>
  </channel>
</rss>

