<?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 do I extract multiple events from one event using SPL? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361110#M169995</link>
    <description>&lt;P&gt;I have data that represents values on bidirectional connections for a graph structure.&lt;/P&gt;

&lt;P&gt;For example, each event has fields like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NodeA: "nodea"
NodeB: "nodeb"
Forward_Metric: 5
Reverse_Metric: 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Usually, I want the data in this format, but occasionally, I'd like to separate this line into 2 events like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NodeA: "nodea"
NodeB: "nodeb"
Metric: 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NodeA: "nodeb"
NodeB: "nodea"
Metric: 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I've done is create a string with the multiple events that I then split up into an mv and deal with that, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval combined=NodeA.",".NodeB.",".Forward_Metric.";".NodeB.",".NodeA.",".Reverse_Metric
| fields _time, combined
| makemv delim=";" combined
| mvexpand combined
| rex field=combined "(?&amp;lt;NodeA&amp;gt;.*),(?&amp;lt;NodeB&amp;gt;.*),(?&amp;lt;Metric&amp;gt;.*)"
| fields - combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there anything in splunk to eliminate any of these steps?  Or just a better way to do it?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
    <pubDate>Tue, 24 Apr 2018 22:58:23 GMT</pubDate>
    <dc:creator>danwilson</dc:creator>
    <dc:date>2018-04-24T22:58:23Z</dc:date>
    <item>
      <title>How do I extract multiple events from one event using SPL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361110#M169995</link>
      <description>&lt;P&gt;I have data that represents values on bidirectional connections for a graph structure.&lt;/P&gt;

&lt;P&gt;For example, each event has fields like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NodeA: "nodea"
NodeB: "nodeb"
Forward_Metric: 5
Reverse_Metric: 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Usually, I want the data in this format, but occasionally, I'd like to separate this line into 2 events like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NodeA: "nodea"
NodeB: "nodeb"
Metric: 5
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;NodeA: "nodeb"
NodeB: "nodea"
Metric: 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I've done is create a string with the multiple events that I then split up into an mv and deal with that, like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval combined=NodeA.",".NodeB.",".Forward_Metric.";".NodeB.",".NodeA.",".Reverse_Metric
| fields _time, combined
| makemv delim=";" combined
| mvexpand combined
| rex field=combined "(?&amp;lt;NodeA&amp;gt;.*),(?&amp;lt;NodeB&amp;gt;.*),(?&amp;lt;Metric&amp;gt;.*)"
| fields - combined
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there anything in splunk to eliminate any of these steps?  Or just a better way to do it?&lt;/P&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2018 22:58:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361110#M169995</guid>
      <dc:creator>danwilson</dc:creator>
      <dc:date>2018-04-24T22:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract multiple events from one event using SPL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361111#M169996</link>
      <description>&lt;P&gt;Try this - &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; your search that creates these fields -
| table nodeA nodeB  Forward_Metric  Reverse_Metric

| rename COMMENT as "create an MV field with two values then duplicate the record"
| eval fan=mvrange(0,2)
| mvexpand fan

| rename COMMENT as "create the three needed values in new fields"
| eval nodeA1=if(fan=0,nodeA,nodeB)
| eval nodeB1=if(fan=0,nodeB,nodeA)
| eval Metric=if(fan=0,Forward_Metric,Reverse_Metric)

| rename COMMENT as "drop unneeded fields then rename to what you want"
| table nodeA1 nodeB1 Metric
| rename nodeA1 as nodeA, nodeB1 as nodeB
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 24 Apr 2018 23:17:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361111#M169996</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2018-04-24T23:17:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I extract multiple events from one event using SPL?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361112#M169997</link>
      <description>&lt;P&gt;I like that idea.  It's still not as clean as I was hoping, but it's better than what I was doing.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Apr 2018 11:08:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-extract-multiple-events-from-one-event-using-SPL/m-p/361112#M169997</guid>
      <dc:creator>danwilson</dc:creator>
      <dc:date>2018-04-25T11:08:41Z</dc:date>
    </item>
  </channel>
</rss>

