<?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 extract multiple values for multiple fields from my sample multiline event using rex? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254918#M76331</link>
    <description>&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex "(?&amp;lt;status&amp;gt;(IN|OUT)):\s+"(?&amp;lt;license&amp;gt;[^"]*)"\s+(?&amp;lt;username&amp;gt;[^@]*)@(?&amp;lt;machine&amp;gt;.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should give you the fields you asked for on all lines that have the fields in them.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/OFuLuZ/1"&gt;Link to regex101 sample&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 04 Dec 2016 01:45:28 GMT</pubDate>
    <dc:creator>Richfez</dc:creator>
    <dc:date>2016-12-04T01:45:28Z</dc:date>
    <item>
      <title>How to extract multiple values for multiple fields from my sample multiline event using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254917#M76330</link>
      <description>&lt;P&gt;Below is my mentioned sample event details. I want to extract fields into a table using regex operations.&lt;BR /&gt;&lt;BR /&gt;
I need to only get IN and OUT status. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  |  license  |  username  |  machine

IN      |  lic_1    |  user1     |  WKS1xxxx
OUT     |  lic_2    |  user2     |  WKS1xxxx
IN      |  lic_3    |  user3     |  WKS1xxxx
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Sample data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;15:21:54 (app1) DENIED: "lic_1" user1@WKS1xxxx  (licenses are reserved for others. (-101,396:10054 ""))
15:21:54 (app1) DENIED: "lic_1" user1@WKS1xxxx  (User/host not on INCLUDE list for feature. (-39,349:10054 ""))
15:21:54 (app1) DENIED: "lic_1" user1@WKS1xxxx  (All licenses are reserved for others. (-101,396:10054 ""))
15:21:54 (app1) DENIED: "lic_1" user1@WKS1xxxx  (User/host not on INCLUDE list for feature. (-39,349:10054 ""))
15:21:54 (app1) DENIED: "lic_1" user1@WKS1xxxx  (All licenses are reserved for others. (-101,396:10054 ""))
15:21:54 (app1) DENIED: "lic_1" user1@WKS1xxxx  (User/host not on INCLUDE list for feature. (-39,349:10054 ""))
15:21:54 (app1) OUT: "lic_1" user1@WKS1xxxx  
15:21:54 (app1) UNSUPPORTED: "lic_2" (PORT_AT_HOST_PLUS   ) user1@WKS1xxxx  (License server system does not support this feature. (-18,327:10054 ""))
15:21:54 (app1) UNSUPPORTED: "lic_3" (PORT_AT_HOST_PLUS   ) user1@WKS1xxxx  (License server system does not support this feature. (-18,327:10054 ""))
15:21:54 (app1) UNSUPPORTED: "lic_2" (PORT_AT_HOST_PLUS   ) user1@WKS1xxxx  (License server system does not support this feature. (-18,327:10054 ""))
15:21:54 (app1) IN: "lic_3" user2@WKS2xxxx  
15:22:04 (app1) IN: "lic_1" user1@WKS1xxxx  
15:22:20 (app1) OUT: "lic_3" user3@WKS22xxx
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 03 Dec 2016 20:27:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254917#M76330</guid>
      <dc:creator>vijax</dc:creator>
      <dc:date>2016-12-03T20:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values for multiple fields from my sample multiline event using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254918#M76331</link>
      <description>&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; ... | rex "(?&amp;lt;status&amp;gt;(IN|OUT)):\s+"(?&amp;lt;license&amp;gt;[^"]*)"\s+(?&amp;lt;username&amp;gt;[^@]*)@(?&amp;lt;machine&amp;gt;.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That should give you the fields you asked for on all lines that have the fields in them.&lt;/P&gt;

&lt;P&gt;&lt;A href="https://regex101.com/r/OFuLuZ/1"&gt;Link to regex101 sample&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Dec 2016 01:45:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254918#M76331</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2016-12-04T01:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values for multiple fields from my sample multiline event using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254919#M76332</link>
      <description>&lt;P&gt;If each line is a single event above then @rich71777 's answer should hold good, however if more than one such lines exist per event then please give this a try:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your query to get the events
| rex max_match=0 field=_raw "(?&amp;lt;status&amp;gt;(IN|OUT)):\s*\"(?&amp;lt;license&amp;gt;[^\"]+)\"\s*(?&amp;lt;username&amp;gt;[^@]+)@(?&amp;lt;machine&amp;gt;[\S]+)"
| eval allValues=mvzip( status, mvzip(license, mvzip(username, machine, "~"), "~"), "~")
| mvexpand allValues
| rex field=allValues "(?&amp;lt;myStatus&amp;gt;[^~]+)~(?&amp;lt;myLicense&amp;gt;[^~]+)~(?&amp;lt;myUser&amp;gt;[^~]+)~(?&amp;lt;myMachine&amp;gt;.*)"
| table myStatus, myLicense, myUser, myMachine
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Dec 2016 02:51:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254919#M76332</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-04T02:51:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values for multiple fields from my sample multiline event using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254920#M76333</link>
      <description>&lt;P&gt;Hi &lt;/P&gt;

&lt;P&gt;In gokadroid answer, replace &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(?&amp;lt;license&amp;gt;[^"]+)  
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (?&amp;lt;license&amp;gt;[^\"]+)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;to have a good answer. He forgot to escape " character &lt;/P&gt;</description>
      <pubDate>Mon, 05 Dec 2016 11:22:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254920#M76333</guid>
      <dc:creator>chimell</dc:creator>
      <dc:date>2016-12-05T11:22:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values for multiple fields from my sample multiline event using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254921#M76334</link>
      <description>&lt;P&gt;thanks all , gokadroid answer was great , and chimell pointed out the error. the final rex would include chimell changes&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 14:26:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254921#M76334</guid>
      <dc:creator>vijax</dc:creator>
      <dc:date>2016-12-08T14:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract multiple values for multiple fields from my sample multiline event using rex?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254922#M76335</link>
      <description>&lt;P&gt;Thanks @chimell and @vijax ...nice catch! Updated as per comments. Up vote for both of you for refining the answer.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Dec 2016 16:18:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-multiple-values-for-multiple-fields-from-my/m-p/254922#M76335</guid>
      <dc:creator>gokadroid</dc:creator>
      <dc:date>2016-12-08T16:18:06Z</dc:date>
    </item>
  </channel>
</rss>

