<?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 two multi-valued field value in pairs and do operation on those pairs separately. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352081#M161241</link>
    <description>&lt;P&gt;For ex: I want to plot a graph of mytime vs perc from below sample data. Hence I need to have mytime and perc in two separate fields and 30 rows.( I need to have them in different rows as, I need to trim last 3 zeroes in mytime and then convert it to readable time). Also, I need to do all this in a Splunk query(Dont want to touch any props or tranforms files)&lt;BR /&gt;
Please help!!! Thank you!&lt;/P&gt;

&lt;P&gt;"data":[{"mytime":1490572800000,"perc":0.9940119760479041},{"mytime":1490659200000,"perc":0.9965156794425087},{"mytime":1490745600000,"perc":0.6004728132387707},{"mytime":1490832000000,"perc":0.9732246798603027},{"mytime":1490918400000,"perc":0.8205128205128205},{"mytime":1491004800000,"perc":0.6938300349243306},{"mytime":1491091200000,"perc":0.7467760844079718},{"mytime":1491177600000,"perc":0.8126463700234192},{"mytime":1491264000000,"perc":0.9976470588235294},{"mytime":1491350400000,"perc":0.9988262910798122},{"mytime":1491436800000,"perc":0.9593175853018373},{"mytime":1491523200000,"perc":0.9434954007884363},{"mytime":1491609600000,"perc":0.6474442988204456},{"mytime":1491696000000,"perc":0.9529964747356052},{"mytime":1491782400000,"perc":0.9534883720930233},{"mytime":1491868800000,"perc":0.991869918699187},{"mytime":1491955200000,"perc":0.9953216374269006},{"mytime":1492041600000,"perc":0.9953488372093023},{"mytime":1492128000000,"perc":0.9988425925925926},{"mytime":1492214400000,"perc":0.6813953488372093},{"mytime":1492300800000,"perc":0.9929824561403509},{"mytime":1492387200000,"perc":0.9907407407407407},{"mytime":1492473600000,"perc":0.9311551925320887},{"mytime":1492560000000,"perc":0.9965034965034965},{"mytime":1492646400000,"perc":0.9883720930232558},{"mytime":1492732800000,"perc":0.9875156054931336},{"mytime":1492819200000,"perc":0.9906542056074766},{"mytime":1492905600000,"perc":0.9881093935790726},{"mytime":1492992000000,"perc":0.9964830011723329},{"mytime":1493078400000,"perc":0.9848308051341891}]}&lt;/P&gt;</description>
    <pubDate>Thu, 27 Apr 2017 15:00:57 GMT</pubDate>
    <dc:creator>nisha12345</dc:creator>
    <dc:date>2017-04-27T15:00:57Z</dc:date>
    <item>
      <title>how to extract two multi-valued field value in pairs and do operation on those pairs separately.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352081#M161241</link>
      <description>&lt;P&gt;For ex: I want to plot a graph of mytime vs perc from below sample data. Hence I need to have mytime and perc in two separate fields and 30 rows.( I need to have them in different rows as, I need to trim last 3 zeroes in mytime and then convert it to readable time). Also, I need to do all this in a Splunk query(Dont want to touch any props or tranforms files)&lt;BR /&gt;
Please help!!! Thank you!&lt;/P&gt;

&lt;P&gt;"data":[{"mytime":1490572800000,"perc":0.9940119760479041},{"mytime":1490659200000,"perc":0.9965156794425087},{"mytime":1490745600000,"perc":0.6004728132387707},{"mytime":1490832000000,"perc":0.9732246798603027},{"mytime":1490918400000,"perc":0.8205128205128205},{"mytime":1491004800000,"perc":0.6938300349243306},{"mytime":1491091200000,"perc":0.7467760844079718},{"mytime":1491177600000,"perc":0.8126463700234192},{"mytime":1491264000000,"perc":0.9976470588235294},{"mytime":1491350400000,"perc":0.9988262910798122},{"mytime":1491436800000,"perc":0.9593175853018373},{"mytime":1491523200000,"perc":0.9434954007884363},{"mytime":1491609600000,"perc":0.6474442988204456},{"mytime":1491696000000,"perc":0.9529964747356052},{"mytime":1491782400000,"perc":0.9534883720930233},{"mytime":1491868800000,"perc":0.991869918699187},{"mytime":1491955200000,"perc":0.9953216374269006},{"mytime":1492041600000,"perc":0.9953488372093023},{"mytime":1492128000000,"perc":0.9988425925925926},{"mytime":1492214400000,"perc":0.6813953488372093},{"mytime":1492300800000,"perc":0.9929824561403509},{"mytime":1492387200000,"perc":0.9907407407407407},{"mytime":1492473600000,"perc":0.9311551925320887},{"mytime":1492560000000,"perc":0.9965034965034965},{"mytime":1492646400000,"perc":0.9883720930232558},{"mytime":1492732800000,"perc":0.9875156054931336},{"mytime":1492819200000,"perc":0.9906542056074766},{"mytime":1492905600000,"perc":0.9881093935790726},{"mytime":1492992000000,"perc":0.9964830011723329},{"mytime":1493078400000,"perc":0.9848308051341891}]}&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2017 15:00:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352081#M161241</guid>
      <dc:creator>nisha12345</dc:creator>
      <dc:date>2017-04-27T15:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract two multi-valued field value in pairs and do operation on those pairs separately.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352082#M161242</link>
      <description>&lt;P&gt;hello there,&lt;BR /&gt;
i see the [ ] around the data, is the sample shared in your question a single event or each line is an event?&lt;BR /&gt;
should i consider the [ ] or they are there by accident, since if i simplify the data, it looks like that:&lt;BR /&gt;
&lt;STRONG&gt;"data":[{....},{....},{....}, ..... ,{.....}]}&lt;/STRONG&gt;&lt;BR /&gt;
is that the right format?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 00:01:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352082#M161242</guid>
      <dc:creator>adonio</dc:creator>
      <dc:date>2017-04-28T00:01:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract two multi-valued field value in pairs and do operation on those pairs separately.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352083#M161243</link>
      <description>&lt;P&gt;Following is a run anywhere search based on the sample data provided first two lines mimic the data using &lt;CODE&gt;makeresults&lt;/CODE&gt; and &lt;CODE&gt;eval&lt;/CODE&gt; and can be ignored&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults
| eval jsonData="{\"data\":[{\"mytime\":1490572800000,\"perc\":0.9940119760479041},{\"mytime\":1490659200000,\"perc\":0.9965156794425087},{\"mytime\":1490745600000,\"perc\":0.6004728132387707},{\"mytime\":1490832000000,\"perc\":0.9732246798603027},{\"mytime\":1490918400000,\"perc\":0.8205128205128205},{\"mytime\":1491004800000,\"perc\":0.6938300349243306},{\"mytime\":1491091200000,\"perc\":0.7467760844079718},{\"mytime\":1491177600000,\"perc\":0.8126463700234192},{\"mytime\":1491264000000,\"perc\":0.9976470588235294},{\"mytime\":1491350400000,\"perc\":0.9988262910798122},{\"mytime\":1491436800000,\"perc\":0.9593175853018373},{\"mytime\":1491523200000,\"perc\":0.9434954007884363},{\"mytime\":1491609600000,\"perc\":0.6474442988204456},{\"mytime\":1491696000000,\"perc\":0.9529964747356052},{\"mytime\":1491782400000,\"perc\":0.9534883720930233},{\"mytime\":1491868800000,\"perc\":0.991869918699187},{\"mytime\":1491955200000,\"perc\":0.9953216374269006},{\"mytime\":1492041600000,\"perc\":0.9953488372093023},{\"mytime\":1492128000000,\"perc\":0.9988425925925926},{\"mytime\":1492214400000,\"perc\":0.6813953488372093},{\"mytime\":1492300800000,\"perc\":0.9929824561403509},{\"mytime\":1492387200000,\"perc\":0.9907407407407407},{\"mytime\":1492473600000,\"perc\":0.9311551925320887},{\"mytime\":1492560000000,\"perc\":0.9965034965034965},{\"mytime\":1492646400000,\"perc\":0.9883720930232558},{\"mytime\":1492732800000,\"perc\":0.9875156054931336},{\"mytime\":1492819200000,\"perc\":0.9906542056074766},{\"mytime\":1492905600000,\"perc\":0.9881093935790726},{\"mytime\":1492992000000,\"perc\":0.9964830011723329},{\"mytime\":1493078400000,\"perc\":0.9848308051341891}]}"
| rex field=jsonData "\{\"mytime\":(?&amp;lt;Time&amp;gt;\d{10})000,\"perc\":(?&amp;lt;perc&amp;gt;[\d|\.]+)\}," max_match=0
| eval RawData=mvzip(Time,perc)
| table RawData
| mvexpand RawData
| eval arrRawData=split(RawData,",")
| eval Time=mvindex(arrRawData,0)
| eval perc=mvindex(arrRawData,1)
| fields - arrRawData
| fieldformat Time=strftime(Time,"%m/%d/%Y %H:%M:%S")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;1) &lt;CODE&gt;rex&lt;/CODE&gt; command is used to apply regular expression to fetch mytime and perc values. &lt;CODE&gt;max_match=0&lt;/CODE&gt; applies the regular expression multiple times on the same data. This should be set to some max number if you are aware like 10 etc.&lt;BR /&gt;
&lt;CODE&gt;\d{10}&lt;/CODE&gt; is used to extract only first 10 digits of epoch time.&lt;/P&gt;

&lt;P&gt;2) &lt;CODE&gt;mvzip&lt;/CODE&gt; is used to bring the two multivalue fields together match 1st mytime with 1st perc and so on.&lt;/P&gt;

&lt;P&gt;3) &lt;CODE&gt;mvexpand&lt;/CODE&gt; breaks into single value rows&lt;/P&gt;

&lt;P&gt;4) &lt;CODE&gt;split&lt;/CODE&gt; is used to create two fields mytime and perc based on comma (,) delimiter&lt;/P&gt;

&lt;P&gt;5) &lt;CODE&gt;fieldformat&lt;/CODE&gt; is used to display time in Human Readable format while retaining mytime as epoch time.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 11:18:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352083#M161243</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-04-28T11:18:23Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract two multi-valued field value in pairs and do operation on those pairs separately.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352084#M161244</link>
      <description>&lt;P&gt;Hello Adonio, yes the data is in right format. The source type contains each log in format --&amp;gt; "data":[{....},{....},{....}, ..... ,{.....}]}. However, I have to work on only the latest log.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 14:07:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352084#M161244</guid>
      <dc:creator>nisha12345</dc:creator>
      <dc:date>2017-04-28T14:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: how to extract two multi-valued field value in pairs and do operation on those pairs separately.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352085#M161245</link>
      <description>&lt;P&gt;Thank you for the response niketnilay.&lt;BR /&gt;
This works perfectly, but I need to perform this operation on latest log( everyday there will we new log with different values of mytime and perc). Could you please suggest solution for the same.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 14:14:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-extract-two-multi-valued-field-value-in-pairs-and-do/m-p/352085#M161245</guid>
      <dc:creator>nisha12345</dc:creator>
      <dc:date>2017-04-28T14:14:01Z</dc:date>
    </item>
  </channel>
</rss>

