<?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 use field values as column headers? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23162#M4098</link>
    <description>&lt;P&gt;There's a few ways to attack this. I'm not sure but Splunk may pick up the key/value pair and extract it as-is.&lt;/P&gt;

&lt;P&gt;Not sure if it needs a , to separate the key/value pairs, but you can test that pretty easily (if you see a Counter #* field in the left-hand field-picker.&lt;/P&gt;

&lt;P&gt;If you do have the fields already extracted, a simple:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(search terms) | table _time,host,Counter_#1,Counter_#2,Counter_#3&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Will give you a table of your values as you describe. You might want to rename the host field as it may get mixed up with Splunk's 'host' field (the source host of the logs). Lookup the 'rename' command in the Splunk docco to do it at search time.&lt;/P&gt;

&lt;P&gt;If Splunk is not extracting your fields automatically, here is the docco for setting it up manually:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles#Examples_of_custom_search-time_field_extractions_using_field_transforms"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles#Examples_of_custom_search-time_field_extractions_using_field_transforms&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You can also look into the 'multikv' search command, to do the extraction manually in every search command you do.&lt;/P&gt;

&lt;P&gt;Hopefully Splunk will extract the fields automatically, and you just need to search and output your data as a table.&lt;/P&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Apr 2012 10:10:28 GMT</pubDate>
    <dc:creator>Splunker</dc:creator>
    <dc:date>2012-04-10T10:10:28Z</dc:date>
    <item>
      <title>How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23161#M4097</link>
      <description>&lt;P&gt;It is best to demonstrate with an example:&lt;/P&gt;

&lt;P&gt;Example of data:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://imglink.ru/pictures/10-04-12/f8d82de72f0afa9f872b0d541c6dcba0.jpg" alt="Example of data" /&gt;&lt;/P&gt;

&lt;P&gt;And expected tesult table:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://imglink.ru/pictures/10-04-12/371bb283096064979af19e2e26604389.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 09:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23161#M4097</guid>
      <dc:creator>Print</dc:creator>
      <dc:date>2012-04-10T09:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23162#M4098</link>
      <description>&lt;P&gt;There's a few ways to attack this. I'm not sure but Splunk may pick up the key/value pair and extract it as-is.&lt;/P&gt;

&lt;P&gt;Not sure if it needs a , to separate the key/value pairs, but you can test that pretty easily (if you see a Counter #* field in the left-hand field-picker.&lt;/P&gt;

&lt;P&gt;If you do have the fields already extracted, a simple:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;(search terms) | table _time,host,Counter_#1,Counter_#2,Counter_#3&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Will give you a table of your values as you describe. You might want to rename the host field as it may get mixed up with Splunk's 'host' field (the source host of the logs). Lookup the 'rename' command in the Splunk docco to do it at search time.&lt;/P&gt;

&lt;P&gt;If Splunk is not extracting your fields automatically, here is the docco for setting it up manually:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles#Examples_of_custom_search-time_field_extractions_using_field_transforms"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Createandmaintainsearch-timefieldextractionsthroughconfigurationfiles#Examples_of_custom_search-time_field_extractions_using_field_transforms&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;You can also look into the 'multikv' search command, to do the extraction manually in every search command you do.&lt;/P&gt;

&lt;P&gt;Hopefully Splunk will extract the fields automatically, and you just need to search and output your data as a table.&lt;/P&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 10:10:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23162#M4098</guid>
      <dc:creator>Splunker</dc:creator>
      <dc:date>2012-04-10T10:10:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23163#M4099</link>
      <description>&lt;P&gt;This was the first thing I tried &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(search) | table host, _time, counter, Value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Unfortunately this way does not work:&lt;/P&gt;

&lt;P&gt;&lt;IMG src="http://imglink.ru/pictures/10-04-12/aace8f48faa98767f60d6ef4c1d073e1.jpg" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 10:35:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23163#M4099</guid>
      <dc:creator>Print</dc:creator>
      <dc:date>2012-04-10T10:35:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23164#M4100</link>
      <description>&lt;P&gt;It's pretty easy to accomplish as long as you have just two fields to grab values from, for instance &lt;CODE&gt;_time&lt;/CODE&gt; and &lt;CODE&gt;counter&lt;/CODE&gt;. In that case you can chart over &lt;CODE&gt;_time&lt;/CODE&gt; by &lt;CODE&gt;counter&lt;/CODE&gt;. Like so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | chart first(Value) over _time by counter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I use &lt;CODE&gt;first&lt;/CODE&gt; here because &lt;CODE&gt;chart&lt;/CODE&gt; needs a statistical function to handle the numerical result from &lt;CODE&gt;Value&lt;/CODE&gt;. Because this is the only value for the event, any statistical function that returns the same value as the original will do, like &lt;CODE&gt;avg()&lt;/CODE&gt;, &lt;CODE&gt;min()&lt;/CODE&gt;, &lt;CODE&gt;max()&lt;/CODE&gt;, etc.&lt;/P&gt;

&lt;P&gt;If you want &lt;CODE&gt;host&lt;/CODE&gt; as well it gets more complicated, because &lt;CODE&gt;chart&lt;/CODE&gt; can't handle splitting on multiple fields like that. If it's an absolute requirement you can sort of solve it, but there's unfortunately no straightforward way of doing it (that I know of).&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 11:33:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23164#M4100</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-10T11:33:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23165#M4101</link>
      <description>&lt;P&gt;Thanks Ayn!&lt;BR /&gt;
It's not exactly what I need, but... it's realy close!&lt;BR /&gt;
Yes, actually I need to take into account the 'host' column (and one another in reality). &lt;BR /&gt;
In addition I ran into a problem: if you use this method, you cannot get more than 10 fields, 11th field appears as 'OTHER'.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 12:11:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23165#M4101</guid>
      <dc:creator>Print</dc:creator>
      <dc:date>2012-04-10T12:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23166#M4102</link>
      <description>&lt;P&gt;You could use &lt;CODE&gt;stats&lt;/CODE&gt; and &lt;CODE&gt;xyseries&lt;/CODE&gt; in combination to resolve this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats first(Value) as Value by _time,counter | xyseries _time counter Value
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 10 Apr 2012 12:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23166#M4102</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-10T12:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23167#M4103</link>
      <description>&lt;P&gt;Nice. But it works only for splunk chart.&lt;BR /&gt;
Actually I'm more interested in a simple table (in order to further analysis in Excel with pivot tables).&lt;BR /&gt;
Is there any way to solve the initial problem as long as I know all the possible values for the 'counter' field?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 13:07:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23167#M4103</guid>
      <dc:creator>Print</dc:creator>
      <dc:date>2012-04-10T13:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23168#M4104</link>
      <description>&lt;P&gt;What you get &lt;EM&gt;is&lt;/EM&gt; a table. What's not working?&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 13:09:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23168#M4104</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-10T13:09:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23169#M4105</link>
      <description>&lt;P&gt;Yes of course:)&lt;BR /&gt;
But I would like to have a table with columns named by 'counter' field values and with the values from the corresponding 'Value' fields (as shown in figure 'Expected result table' above).&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 13:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23169#M4105</guid>
      <dc:creator>Print</dc:creator>
      <dc:date>2012-04-10T13:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23170#M4106</link>
      <description>&lt;P&gt;I don't understand - this kind of table is exactly what you get by running the command I wrote. (at least it's what I get...)&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 13:36:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23170#M4106</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-04-10T13:36:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to use field values as column headers?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23171#M4107</link>
      <description>&lt;P&gt;Yeah, excuse me please. You're absolutely right.&lt;BR /&gt;
This is my mistake. I just tried to add the host and instance to my query... Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Apr 2012 14:16:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-field-values-as-column-headers/m-p/23171#M4107</guid>
      <dc:creator>Print</dc:creator>
      <dc:date>2012-04-10T14:16:38Z</dc:date>
    </item>
  </channel>
</rss>

