<?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: A table with fields as lines in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63406#M15664</link>
    <description>&lt;P&gt;I agree with @&lt;A href="http://answers.splunk.com/users/186682/zeroactive"&gt;zeroactive&lt;/A&gt;. But this may do what you want&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| stats avg(Field*) as Field*
| eval Metric="Average"
| append [ search yoursearchhere
   | stats median(Field*) as Field*
   | eval Metric="Median" ]
| append [ search yoursearchhere
   | stats sparkline(count(Field*)) as Field*
   | eval Metric="Sparkline" ]
| table Metric Field*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Fri, 13 Sep 2013 16:32:59 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2013-09-13T16:32:59Z</dc:date>
    <item>
      <title>A table with fields as lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63404#M15662</link>
      <description>&lt;P&gt;We got some events ,with an extract we got &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Event 1 : Field1=VALUE11,Field2=VALUE12,Field3=VALUE13,... 
Event 2 : Field1=VALUE21,Field2=VALUE22,Field3=VALUE23,... 
Event 3 : Field1=VALUE31,Field2=VALUE32,Field3=VALUE33,... 
etc... 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What we would like is obtain a table like this: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Metric    |     Field1        |      Field 2      |    Field 3 ... 
----------------------------------------------------------------------------------
      Avg | avg(Field1)       | avg(Field2)       | avg(Field3) ... 
   Median | median(Field1)    | median(Field2)    | median(Field3) ... 
Sparkline | sparkline(Field1) | sparkline(Field2) | sparkline(Field3) ... 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What the best way to do that? &lt;BR /&gt;
Seems impossible to find an easy way. &lt;BR /&gt;
We tried in this direction : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval metric=mvappend("avg","median") | mvexpand metric | eval value=case(metric=="swFCPortRxC3Frames",swFCPortRxC3Frames,metric=="swFCPortRxC2Frames",swFCPortRxC2Frames) | chart latest(value) by metric swFCPortIndex
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thx for your help !&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2013 14:13:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63404#M15662</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2013-09-13T14:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: A table with fields as lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63405#M15663</link>
      <description>&lt;P&gt;Odd way to look at data...  Why not do the table by Field ID, with columns for Avg, Median, and Sparkline?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2013 14:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63405#M15663</guid>
      <dc:creator>zeroactive</dc:creator>
      <dc:date>2013-09-13T14:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: A table with fields as lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63406#M15664</link>
      <description>&lt;P&gt;I agree with @&lt;A href="http://answers.splunk.com/users/186682/zeroactive"&gt;zeroactive&lt;/A&gt;. But this may do what you want&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchhere
| stats avg(Field*) as Field*
| eval Metric="Average"
| append [ search yoursearchhere
   | stats median(Field*) as Field*
   | eval Metric="Median" ]
| append [ search yoursearchhere
   | stats sparkline(count(Field*)) as Field*
   | eval Metric="Sparkline" ]
| table Metric Field*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Sep 2013 16:32:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63406#M15664</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2013-09-13T16:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: A table with fields as lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63407#M15665</link>
      <description>&lt;P&gt;The sparklines will be the count of the samples, and wont plot the actual values.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2013 18:11:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63407#M15665</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-09-13T18:11:35Z</dc:date>
    </item>
    <item>
      <title>Re: A table with fields as lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63408#M15666</link>
      <description>&lt;P&gt;Lots of metrics in the same event require you to know what the field names are if you're going to perform stats on them. The workaround is to use untable. Whenever you think "How the heck .." - untable is usually the answer. xyseries is its inverse.&lt;/P&gt;

&lt;P&gt;I have data similar to yours. every 2 minute I have a feed of disk utilization that looks like :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Event 1: sda=0.0;sda1=0.0;sda2=0.0
Event 2: sda=10.3;sda1=1.0;sda2=9.3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here's the search that only hits the index once, and works for arbitrarily named fields :&lt;BR /&gt;
The 1st "table" is where you include / filter the fields you are interested in - this allows far more flexibility than using wildcards in the stats commands.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;initial search
| table _time sd*
| untable _time field value
| eval metric="raw"
| appendpipe [ | stats avg(value) as data by field | eval metric="Average" ]
| appendpipe [ | stats median(value) as data by field | eval metric="Median" ]
| appendpipe [ | stats sparkline(avg(value)) as data by field | eval metric="Sparkline" ]
| where metric !="raw"
| xyseries metric field data
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;result : &lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/spark.png" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;You can save yourself a lot of headache by transposing the columns and rows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;initial search
| table _time sd*
| untable _time field value
| chart avg(value) as Average median(value) as Median sparkline(avg(value)) as sparkline by field
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;IMG src="http://splunk-base.splunk.com//storage/spark2.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Sep 2013 19:00:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63408#M15666</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2013-09-13T19:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: A table with fields as lines</title>
      <link>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63409#M15667</link>
      <description>&lt;P&gt;You 're right, but i needed the untable() function that i didn't know to do that &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Sep 2013 07:37:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/A-table-with-fields-as-lines/m-p/63409#M15667</guid>
      <dc:creator>timmalos</dc:creator>
      <dc:date>2013-09-16T07:37:34Z</dc:date>
    </item>
  </channel>
</rss>

