<?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 How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143201#M39759</link>
    <description>&lt;P&gt;I need to extract from 2 fields and compile them into multiple fields.&lt;/P&gt;

&lt;P&gt;1st field contains all the counter names.&lt;BR /&gt;
Example&lt;BR /&gt;
Event:&lt;BR /&gt;
&lt;STRONG&gt;label=counter1,counter2,counter3&lt;/STRONG&gt;&lt;BR /&gt;
The label doesn't change. Event is all the same for label type.&lt;/P&gt;

&lt;P&gt;2nd field contains all the counts.&lt;BR /&gt;
Example&lt;BR /&gt;
&lt;STRONG&gt;Event1= 0,10,20&lt;BR /&gt;
Event2=2,30,15&lt;BR /&gt;
...&lt;BR /&gt;
EventN=x,y,z&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I can use split and mv to do the extraction.&lt;BR /&gt;
How can I compile those counter and counts into key value pairs inline?&lt;BR /&gt;
I need to use the values from counter field as a new field. Values from count field as the new values. The pair will be position based and split by comma?&lt;/P&gt;</description>
    <pubDate>Tue, 14 Apr 2015 08:54:26 GMT</pubDate>
    <dc:creator>gnorud</dc:creator>
    <dc:date>2015-04-14T08:54:26Z</dc:date>
    <item>
      <title>How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143201#M39759</link>
      <description>&lt;P&gt;I need to extract from 2 fields and compile them into multiple fields.&lt;/P&gt;

&lt;P&gt;1st field contains all the counter names.&lt;BR /&gt;
Example&lt;BR /&gt;
Event:&lt;BR /&gt;
&lt;STRONG&gt;label=counter1,counter2,counter3&lt;/STRONG&gt;&lt;BR /&gt;
The label doesn't change. Event is all the same for label type.&lt;/P&gt;

&lt;P&gt;2nd field contains all the counts.&lt;BR /&gt;
Example&lt;BR /&gt;
&lt;STRONG&gt;Event1= 0,10,20&lt;BR /&gt;
Event2=2,30,15&lt;BR /&gt;
...&lt;BR /&gt;
EventN=x,y,z&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;I can use split and mv to do the extraction.&lt;BR /&gt;
How can I compile those counter and counts into key value pairs inline?&lt;BR /&gt;
I need to use the values from counter field as a new field. Values from count field as the new values. The pair will be position based and split by comma?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 08:54:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143201#M39759</guid>
      <dc:creator>gnorud</dc:creator>
      <dc:date>2015-04-14T08:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143202#M39760</link>
      <description>&lt;P&gt;Hi  gnorud,&lt;/P&gt;

&lt;P&gt;Try with this format of query with &lt;STRONG&gt;mvindex&lt;/STRONG&gt; function and &lt;STRONG&gt;rex_macth&lt;/STRONG&gt; attribute:&lt;/P&gt;

&lt;P&gt;Hi, try this &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ...| rex "your rex P? &amp;lt;label&amp;gt;..." max_match=0| eval label1=mvindex(label,0) | eval label2=mvindex(label,1) | eval label3=mvindex(label,2) |  rex "your rex P?&amp;lt;Count&amp;gt;..." max_match=0|eval Count1=mvindex(Count,0) | eval Count2=mvindex(Count,1)| eval count3=mvindex(Count,2) |table label1 label2 label3 Count1 Count2 Count3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You will get the key value pair of each field.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 09:13:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143202#M39760</guid>
      <dc:creator>ngatchasandra</dc:creator>
      <dc:date>2015-04-14T09:13:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143203#M39761</link>
      <description>&lt;P&gt;The purpose is to create a tabulate output with label as column name, then populate each row by using count values. &lt;BR /&gt;
Labels are extracted from counter fields by delimiter comma,&lt;BR /&gt;
Values are extracted and assigned to each label cell.&lt;/P&gt;

&lt;P&gt;With the output so I can chart based on _time&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 10:50:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143203#M39761</guid>
      <dc:creator>gnorud</dc:creator>
      <dc:date>2015-04-14T10:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143204#M39762</link>
      <description>&lt;P&gt;I don't know how are your events but something like this may help. I hope&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search    |rex "lable=(?&amp;lt;conter1&amp;gt;[^,]),(?&amp;lt;conter2&amp;gt;[^,]),(?&amp;lt;conter3&amp;gt;.*+)"|rex "Event=(?&amp;lt;cont1&amp;gt;\d+),(?&amp;lt;cont2&amp;gt;\d+),(?&amp;lt;cont3&amp;gt;\d+)\s"|eventstats count(count1) as counter1 by conter1|eventstat count(count2) as counter2 by conter2|eventstat count(count3) as counter3 by conter3|table counter1 counter2 counter3
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2015 11:17:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143204#M39762</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-14T11:17:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143205#M39763</link>
      <description>&lt;P&gt;Are you extract already the count values as a multivalue field? If not try to send me an entire event that contain the values count!&lt;/P&gt;

&lt;P&gt;I tried to reply you below!&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 12:31:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143205#M39763</guid>
      <dc:creator>ngatchasandra</dc:creator>
      <dc:date>2015-04-14T12:31:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143206#M39764</link>
      <description>&lt;P&gt;I reply you by considering that the count values are inside a multivalue field . Use query that follow:&lt;/P&gt;

&lt;P&gt;I consider values count in field like Count=0,2,3 for example.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   ....|eval CountNew=split(count,",")  |eval counter1=mvindex(CountNew,0) |eval counter2=mvindex(CountNew,1) |eval counter3= mvindex(countNew,2) | table counter1 counter2 counter3
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2015 12:49:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143206#M39764</guid>
      <dc:creator>ngatchasandra</dc:creator>
      <dc:date>2015-04-14T12:49:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143207#M39765</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
I don't need to extract count value.&lt;BR /&gt;
The count field in the log is multivalued separated by comma，count event is the number of occurance for each counter, counter name  is from another field.&lt;/P&gt;

&lt;P&gt;I want a timecharts to show linechart per counter and counts created inline. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 12:56:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143207#M39765</guid>
      <dc:creator>gnorud</dc:creator>
      <dc:date>2015-04-14T12:56:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143208#M39766</link>
      <description>&lt;P&gt;Hi &lt;BR /&gt;
The counts value is from count field. So I don't have to count events.  I need to assign counts values to each counter. &lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 12:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143208#M39766</guid>
      <dc:creator>gnorud</dc:creator>
      <dc:date>2015-04-14T12:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143209#M39767</link>
      <description>&lt;P&gt;This is my current workaround.&lt;/P&gt;

&lt;P&gt;However I need the field name to be created dynamically as well from another fields' multivalued event.&lt;BR /&gt;&lt;BR /&gt;
For example: as for a single event, field name = countertype; field value=(Counter1,counter2,counter3).&lt;/P&gt;

&lt;P&gt;I need extract from above event and create 3 new fields. &lt;BR /&gt;
Fields name = counter 1,2,3&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 13:15:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143209#M39767</guid>
      <dc:creator>gnorud</dc:creator>
      <dc:date>2015-04-14T13:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143210#M39768</link>
      <description>&lt;P&gt;i think that my query  assign counts values to each counter, counter1 counter2, counter3 . You can use timechart like follow:&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;....|eval CountNew=split(count,",")  |eval counter1=mvindex(CountNew,0) |eval counter2=mvindex(CountNew,1) |eval counter3= mvindex(countNew,2) |timechart count by counter1&lt;/CODE&gt; for example&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2015 13:35:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143210#M39768</guid>
      <dc:creator>ngatchasandra</dc:creator>
      <dc:date>2015-04-14T13:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract values from 2 multivalue fields as field names and values and generate new key value pairs dynamically?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143211#M39769</link>
      <description>&lt;P&gt;OK. Here you go: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search    |rex "lable=(?&amp;lt;conter1&amp;gt;[^,]),(?&amp;lt;conter2&amp;gt;[^,]),(?&amp;lt;conter3&amp;gt;[^\s]+)"|rex "Event=(?&amp;lt;cont1&amp;gt;\d+),(?&amp;lt;cont2&amp;gt;\d+),(?&amp;lt;cont3&amp;gt;\d+)\s"|eventstats values(count1) as counter1 by conter1|eventstat values(count2) as counter2 by conter2|eventstat values(count3) as counter3 by conter3|table counter1 counter2 counter3
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 Apr 2015 15:54:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-values-from-2-multivalue-fields-as-field-names/m-p/143211#M39769</guid>
      <dc:creator>stephanefotso</dc:creator>
      <dc:date>2015-04-14T15:54:18Z</dc:date>
    </item>
  </channel>
</rss>

