<?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 convert multiple fieldname=fieldvalue entries into category=fieldname, value=fieldvalue pairs for timechart in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170944#M48960</link>
    <description>&lt;P&gt;assuming your initial results have fields that are &lt;CODE&gt;_time first_field second_field third_field&lt;/CODE&gt; then you want &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| untable _time category count | rename count as value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and that will unwind the results you have into the results that have fields of &lt;CODE&gt;_time category value&lt;/CODE&gt;, just like you need. &lt;/P&gt;

&lt;P&gt;The untable command is basically the inverse of the xyseries command.   To really understand these two commands it helps to play around a little with the stats command vs the chart command.   Take these two searches: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal group=per_sourcetype_thruput | stats count by date_hour series&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;vs &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal group=per_sourcetype_thruput | chart count over date_hour by series&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;They look very similar and in fact they present the same information but in very different formats.  Run them both and  think about them. &lt;/P&gt;

&lt;P&gt;Now, you can turn the first resultset into the second by appending &lt;CODE&gt;| xyseries date_hour series count&lt;/CODE&gt;,  and you can turn the second resultset into the first by appending &lt;CODE&gt;| untable date_hour series count&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Untable"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Untable&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 20 May 2014 06:33:59 GMT</pubDate>
    <dc:creator>sideview</dc:creator>
    <dc:date>2014-05-20T06:33:59Z</dc:date>
    <item>
      <title>How to convert multiple fieldname=fieldvalue entries into category=fieldname, value=fieldvalue pairs for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170943#M48959</link>
      <description>&lt;P&gt;I have data where each row contains a timestamp and a set of fieldname=fieldvalue entries.  I want to convert selected fieldnames from each row into multiple rows each with timestamp, category=fieldname, value=fieldvalue.&lt;/P&gt;

&lt;P&gt;Source data&lt;BR /&gt;
&lt;PRE&gt;2014-05-19 10:00 first_field=1 second_field=1 third_field=2 other=5&lt;BR /&gt;
2014-05-19 10:10 first_field=2 second_field=1 third_field=3 ignore=foo&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;If I want first_field, second_field, and third_value, I want the output to be something like&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;2014-05-19 10:00 category=first_field value=1&lt;BR /&gt;
2014-05-19 10:00 category=second_field value=1&lt;BR /&gt;
2014-05-19 10:00 category=third_field value=2&lt;BR /&gt;
2014-05-19 10:10 category=first_field value=2&lt;BR /&gt;
2014-05-19 10:10 category=second_field value=1&lt;BR /&gt;
2014-05-19 10:10 category=third_field value=3&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;I want to run the final data through &lt;TT&gt; | timechart avg(value) by category&lt;/TT&gt; (or other stats function) to look at multiple categories at once.  Data will be "clean" in that ranges for different categories extracted at once will be compatible.&lt;/P&gt;

&lt;P&gt;I know I've seen this done, but can't find the right keywords to search on to (re-)discover the examples.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:39:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170943#M48959</guid>
      <dc:creator>alange</dc:creator>
      <dc:date>2020-09-28T16:39:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert multiple fieldname=fieldvalue entries into category=fieldname, value=fieldvalue pairs for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170944#M48960</link>
      <description>&lt;P&gt;assuming your initial results have fields that are &lt;CODE&gt;_time first_field second_field third_field&lt;/CODE&gt; then you want &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| untable _time category count | rename count as value
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and that will unwind the results you have into the results that have fields of &lt;CODE&gt;_time category value&lt;/CODE&gt;, just like you need. &lt;/P&gt;

&lt;P&gt;The untable command is basically the inverse of the xyseries command.   To really understand these two commands it helps to play around a little with the stats command vs the chart command.   Take these two searches: &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal group=per_sourcetype_thruput | stats count by date_hour series&lt;/CODE&gt; &lt;/P&gt;

&lt;P&gt;vs &lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;index=_internal group=per_sourcetype_thruput | chart count over date_hour by series&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;They look very similar and in fact they present the same information but in very different formats.  Run them both and  think about them. &lt;/P&gt;

&lt;P&gt;Now, you can turn the first resultset into the second by appending &lt;CODE&gt;| xyseries date_hour series count&lt;/CODE&gt;,  and you can turn the second resultset into the first by appending &lt;CODE&gt;| untable date_hour series count&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Xyseries&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Untable"&gt;http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Untable&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 May 2014 06:33:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170944#M48960</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2014-05-20T06:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to convert multiple fieldname=fieldvalue entries into category=fieldname, value=fieldvalue pairs for timechart</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170945#M48961</link>
      <description>&lt;P&gt;That was what I needed.  As an example (to make sure I could do what I want) I offer the following which displays min, avg, max as three lines on a graph:&lt;BR /&gt;
&lt;PRE&gt;index=_internal group=per_sourcetype_thruput series=access_combined&lt;BR /&gt;
 | bucket _time span=10m&lt;BR /&gt;
 | stats min(kbps) as min avg(kbps) as avg max(kbps) as max by _time&lt;BR /&gt;
 | untable _time category count | rename count as value&lt;BR /&gt;
 | timechart span=10m avg(value) by category&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;With appropriate use of fields/table/stats and rename before the untable/rename, I can choose exactly what to show in the by split of the timechart.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:41:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-convert-multiple-fieldname-fieldvalue-entries-into/m-p/170945#M48961</guid>
      <dc:creator>alange</dc:creator>
      <dc:date>2020-09-28T16:41:27Z</dc:date>
    </item>
  </channel>
</rss>

