<?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: rex multiple matches in single event in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468407#M131890</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     index=abc source="unknown.log" "192.0.44.13" | rex max_match=0 "Value 0: (?&amp;lt;device&amp;gt;.*)" | rex max_match=0 "Value 1: (?&amp;lt;ip&amp;gt;.*)"  | stats count by device ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 28 Aug 2019 14:06:45 GMT</pubDate>
    <dc:creator>harsmarvania57</dc:creator>
    <dc:date>2019-08-28T14:06:45Z</dc:date>
    <item>
      <title>rex multiple matches in single event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468406#M131889</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I using a query :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=abc source="unknown.log" "192.0.44.13" | rex "Value 0: (?&amp;lt;device&amp;gt;.*)" | rex "Value 1: (?&amp;lt;ip&amp;gt;.*)"  | stats count by device ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this gives me only 2 results whereas i have multiple results. &lt;/P&gt;

&lt;P&gt;The only problem is all the matches are in single event. which looks like below. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Wed Aug 21 18:34:57 2019: Unknown trap abc at: 
Value 0: abc
Value 1: 192.2.86.53
Value 2: 
Value 3: 
Value 4:
Value 5: 
Value 6: 
Value 7: 
Value 8: 
Value 9: 
Value 10: 
Wed Aug 21 18:34:57 2019: Unknown trap abc at: 
Value 0: xyz
Value 1: 192.2.87.42
Value 2: 
Value 3: 
Value 4:
Value 5: 
Value 6: 
Value 7: 
Value 8: 
Value 9: 
Value 10: 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see here since the at the same time events occur they get merged to a single even and i want all the matches for "Value 0:" and "Value 1:" from the single event. &lt;/P&gt;

&lt;P&gt;The query which i have pasted works and fetches me only the first match not all. &lt;/P&gt;

&lt;P&gt;Please help. &lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 13:36:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468406#M131889</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2019-08-28T13:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: rex multiple matches in single event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468407#M131890</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     index=abc source="unknown.log" "192.0.44.13" | rex max_match=0 "Value 0: (?&amp;lt;device&amp;gt;.*)" | rex max_match=0 "Value 1: (?&amp;lt;ip&amp;gt;.*)"  | stats count by device ip
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 28 Aug 2019 14:06:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468407#M131890</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-08-28T14:06:45Z</dc:date>
    </item>
    <item>
      <title>Re: rex multiple matches in single event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468408#M131891</link>
      <description>&lt;P&gt;Hi @harsmarvania57&lt;/P&gt;

&lt;P&gt;It worked like magic but whats the logic behind using it ? Can you please explain.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 14:20:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468408#M131891</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2019-08-28T14:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: rex multiple matches in single event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468409#M131892</link>
      <description>&lt;P&gt;&lt;CODE&gt;max_match=0&lt;/CODE&gt; in rex command will match same regex N number of times.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 14:23:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468409#M131892</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2019-08-28T14:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: rex multiple matches in single event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468410#M131893</link>
      <description>&lt;P&gt;Hi surekhasplunk,&lt;BR /&gt;
is it possible for you divide your event in different ones? they seem to be different events.&lt;/P&gt;

&lt;P&gt;Anyway, you can extract more values for each field but all the values are in the same field, you haven't different rows, so when you try to use stats you haven't a count for each value.&lt;BR /&gt;
in other words, you'll have something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time                    message             Value_0   Value_1
Wed Aug 21 18:34:57 2019 Unknown trap abc at abc       192.2.86.53
Wed Aug 21 18:34:57 2019 Unknown trap abc at xyz        192.2.87.42
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;but both the values are in the same field value, this means that you have to use also mvexpand command.&lt;BR /&gt;
Try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=abc source="unknown.log" "192.0.44.13" 
| rex max_match=0 "Value 0: (?&amp;lt;device&amp;gt;.*)" 
| rex max_match=0 "Value 1: (?&amp;lt;ip&amp;gt;.*)"  
| mvexpand device
| mvexpand ip
| stats count by device ip
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 14:25:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468410#M131893</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-08-28T14:25:03Z</dc:date>
    </item>
    <item>
      <title>Re: rex multiple matches in single event</title>
      <link>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468411#M131894</link>
      <description>&lt;P&gt;ok... thanks a ton &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; @harsmarvania57 &lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 14:31:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/rex-multiple-matches-in-single-event/m-p/468411#M131894</guid>
      <dc:creator>surekhasplunk</dc:creator>
      <dc:date>2019-08-28T14:31:13Z</dc:date>
    </item>
  </channel>
</rss>

