<?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 make rows value into columns. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420974#M120943</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;, thanks for answer.&lt;/P&gt;

&lt;P&gt;however, what i was trying to do is building/finding a way to have  "% Idle Time" as field name and field Value as value to "% Idle Time" &lt;/P&gt;

&lt;P&gt;that is "% Idle Time" = "99.880239676329609"&lt;/P&gt;

&lt;P&gt;Similarly i want apply this for all counter(% Idle Time, %_Processor time, %_Disk Time etc.) and have corresponding Values (field  Value in below example event ) assigned from events. &lt;/P&gt;

&lt;P&gt;example of an event.&lt;/P&gt;

&lt;P&gt;05/28/2018 17:33:53.560 +1000&lt;BR /&gt;
collection="Host LogicalDisk Stats"&lt;BR /&gt;
object=LogicalDisk&lt;BR /&gt;
counter="% Idle Time"&lt;BR /&gt;
instance=D:&lt;BR /&gt;
Value=99.880239676329609&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:00:17 GMT</pubDate>
    <dc:creator>pratapbhanu2047</dc:creator>
    <dc:date>2020-09-29T20:00:17Z</dc:date>
    <item>
      <title>How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420972#M120941</link>
      <description>&lt;P&gt;I am trying to convert values from rows into columns. below is a example data &lt;/P&gt;

&lt;P&gt;ServerName  Counter Value&lt;BR /&gt;
server1 %_Processor time    85&lt;BR /&gt;
server1 %_Disk Time 90&lt;BR /&gt;
server1 Pages/sec   44&lt;BR /&gt;
server2 %_Processor time    75&lt;BR /&gt;
server2 %_Disk Time 80&lt;BR /&gt;
server2 Pages/sec   Null&lt;/P&gt;

&lt;P&gt;to Something like &lt;/P&gt;

&lt;P&gt;ServerName  %_Processor time %_Disk Time    Pages/sec&lt;BR /&gt;
server1 85  90  44&lt;BR /&gt;
server2 75  80  Null&lt;/P&gt;

&lt;P&gt;Could anyone, Please help me here.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:42:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420972#M120941</guid>
      <dc:creator>pratapbhanu2047</dc:creator>
      <dc:date>2020-09-29T19:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420973#M120942</link>
      <description>&lt;P&gt;&lt;STRONG&gt;[UPDATED ANSWER]&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;updated field names.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourBaseSearch&amp;gt;
| chart last(Value) by host counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;IMG src="https://wiki.splunk.com/images/a/ae/Performance_Counter_Over_Host.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;@pratapbhanu2047, Just pipe the following chart command to your existing search which returns the tabular result as per your question:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; &amp;lt;yourCurrentSearch&amp;gt;
| chart last(Value) by host counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Following is a run anywhere search based on sample data provided.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| fields - _time
| eval data="server1,%_Processor time,85;server1,%_Disk Time,90;server1,Pages/sec,44;server2,%_Processor time,75;server2,%_Disk Time,80;server2,Pages/sec,Null" 
| makemv data delim=";" 
| mvexpand data 
| makemv data delim=","
| eval host=mvindex(data,0),counter=mvindex(data,1),Value=mvindex(data,2)
| fields - data
| table host counter value
| chart last(Value) by host counter
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 May 2018 11:56:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420973#M120942</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-27T11:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420974#M120943</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;, thanks for answer.&lt;/P&gt;

&lt;P&gt;however, what i was trying to do is building/finding a way to have  "% Idle Time" as field name and field Value as value to "% Idle Time" &lt;/P&gt;

&lt;P&gt;that is "% Idle Time" = "99.880239676329609"&lt;/P&gt;

&lt;P&gt;Similarly i want apply this for all counter(% Idle Time, %_Processor time, %_Disk Time etc.) and have corresponding Values (field  Value in below example event ) assigned from events. &lt;/P&gt;

&lt;P&gt;example of an event.&lt;/P&gt;

&lt;P&gt;05/28/2018 17:33:53.560 +1000&lt;BR /&gt;
collection="Host LogicalDisk Stats"&lt;BR /&gt;
object=LogicalDisk&lt;BR /&gt;
counter="% Idle Time"&lt;BR /&gt;
instance=D:&lt;BR /&gt;
Value=99.880239676329609&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:00:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420974#M120943</guid>
      <dc:creator>pratapbhanu2047</dc:creator>
      <dc:date>2020-09-29T20:00:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420975#M120944</link>
      <description>&lt;P&gt;You should be able to construct a REPORT action in props and transforms, to extract both counter name and value from an event and use the counter name as field name and value as field value. Should look something like below example):&lt;/P&gt;

&lt;P&gt;props.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[yoursourcetype here]
REPORT-extract-counter-name-and-value = extract-counter-name-and-value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[extract-counter-name-and-value]
REGEX = (?s)counter="([^\"]+)".*Value=([\d\.]+)
FORMAT = $1::$2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 May 2018 09:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420975#M120944</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-05-28T09:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420976#M120945</link>
      <description>&lt;P&gt;Edited my answer to include the &lt;CODE&gt;(?s)&lt;/CODE&gt; modifier in the regex to make &lt;CODE&gt;.&lt;/CODE&gt; match newlines.&lt;/P&gt;</description>
      <pubDate>Mon, 28 May 2018 09:45:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420976#M120945</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2018-05-28T09:45:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420977#M120946</link>
      <description>&lt;P&gt;@pratapbhanu2047 have you tried my answer?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yourCurrentSearch&amp;gt;
 | chart last(Value) by ServerName Counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My example is a run anywhere search based on your first table using the following query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | makeresults
 | fields - _time
 | eval data="server1,%_Processor time,85;server1,%_Disk Time,90;server1,Pages/sec,44;server2,%_Processor time,75;server2,%_Disk Time,80;server2,Pages/sec,Null" 
 | makemv data delim=";" 
 | mvexpand data 
 | makemv data delim=","
 | eval ServerName=mvindex(data,0),Counter=mvindex(data,1),Value=mvindex(data,2)
 | fields - data
 | table ServerName Counter Value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Then final pipe inverses the results using &lt;CODE&gt;chart&lt;/CODE&gt; command as per your question:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | chart last(Value) by ServerName Counter
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 May 2018 12:22:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420977#M120946</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-28T12:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420978#M120947</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/201110"&gt;@niketn&lt;/a&gt;, yes i tried. However it did help a bit..but I am not able to resolve it. &lt;/P&gt;

&lt;P&gt;I did found out that i can use eval with chart or stats &lt;/P&gt;

&lt;P&gt;index=acn_&lt;EM&gt;_tier&lt;/EM&gt; sourcetype="Perfmon:sqlserver:buffer_manager" &lt;BR /&gt;
| eval Value=round(Value,2) &lt;BR /&gt;
| eval My{counter}=Value &lt;BR /&gt;
| stats avg("My*") by host &lt;BR /&gt;
| fillnull&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:42:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420978#M120947</guid>
      <dc:creator>pratapbhanu2047</dc:creator>
      <dc:date>2020-09-29T19:42:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420979#M120948</link>
      <description>&lt;P&gt;@pratapbhanu2047 can you post the code in comment using the code button &lt;CODE&gt;101010&lt;/CODE&gt; or shortcut key &lt;CODE&gt;CTRL+K&lt;/CODE&gt; so that special characters do not escape?&lt;/P&gt;

&lt;P&gt;The chart command can control one field on x-axis and another one on y-axis. The first parameter after by clause is actually treated as over (or x-axis). Second on y-axis. I have replaced ServerName with host as per your query&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;yourIndexName&amp;gt; sourcetype="Perfmon:sqlserver:buffer_manager"
| chart last(Value) by host counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you want to invert you would use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=&amp;lt;yourIndexName&amp;gt; sourcetype="Perfmon:sqlserver:buffer_manager"
| chart last(Value) by counter host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please try both and see if one of them matches result you are seeking!&lt;BR /&gt;
PS: Just noticed &lt;CODE&gt;counter&lt;/CODE&gt; should be lower case.&lt;/P&gt;</description>
      <pubDate>Mon, 28 May 2018 16:12:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420979#M120948</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-05-28T16:12:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to make rows value into columns.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420980#M120949</link>
      <description>&lt;P&gt;Another question on this, the uf data collected runs every 15 mins, so if i have to see the same output based on each run time, how do i do that.. it does not work for me when i run&lt;BR /&gt;
|chart last(Value) by host counter _time&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2018 06:26:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-make-rows-value-into-columns/m-p/420980#M120949</guid>
      <dc:creator>jiaqya</dc:creator>
      <dc:date>2018-10-10T06:26:45Z</dc:date>
    </item>
  </channel>
</rss>

