<?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: Regex on multiline event - how to match multiple occurences of a matching group? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214742#M62966</link>
    <description>&lt;P&gt;Splunk uses perl regex strings, not ruby.  regex101.com is good site for testing regex strings.  Also, the &lt;CODE&gt;rex&lt;/CODE&gt; command will only return the first match unless the max_match option is used.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex max_match=0 "(?&amp;lt;QueueCount&amp;gt;\d+)\s(?&amp;lt;QueueName&amp;gt;[a-zA-Z_]+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 06 Jan 2016 13:25:33 GMT</pubDate>
    <dc:creator>richgalloway</dc:creator>
    <dc:date>2016-01-06T13:25:33Z</dc:date>
    <item>
      <title>Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214741#M62965</link>
      <description>&lt;H4&gt;About the source&lt;/H4&gt;

&lt;P&gt;I have a SQL report scheduled every 15 minute reporting the status of queues in our case handler system. Splunk is instructed to read all as one event - so when searching in Splunk the event is returned like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;TO_CHAR(SYSDATE,'                                                               
-----------------                                                               
01062016 09:00:00                                                               
HANGING_WOBS_COUNT QUEUE                                                        
------------------ -------------------------                                    
                 2 LIV_InitialCheck                                             
                 1 LIV_InitialCreate                                            
                 1 LIV_LB                                                       
                 0 BPF_Operations                                               
                 0 CE_Operations                                                
                 0 LIV_AttachmentMarkDeleted                                    
                 0 LIV_DeleteIndeksCase                                         
                 0 LIV_InitialLookup                                            
                 0 LIV_InitialMerge                                             
...
25 rows selected.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I open the source file in &lt;A href="https://notepad-plus-plus.org/"&gt;Notepad++&lt;/A&gt; and view all characters it looks like this &lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/930i3FF4E2414587A391/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;H4&gt;What I have done&lt;/H4&gt;

&lt;OL&gt;
&lt;LI&gt;Using &lt;A href="http://rubular.com/"&gt;Rubular.com&lt;/A&gt; created and verified the following regex &lt;CODE&gt;^\s{3,}(?&amp;amp;lt;QueueCount&amp;amp;gt;\d+)\s(?&amp;amp;lt;QueueName&amp;amp;gt;\w+)&lt;/CODE&gt; It captures each queuesize and -name&lt;/LI&gt;
&lt;LI&gt;Verified the same regex using the &lt;A href="http://docs.splunk.com/Splexicon:Fieldextractor"&gt;field extractor&lt;/A&gt; . It captures only the first queue LIV_InitialCheck&lt;/LI&gt;
&lt;LI&gt;Testing the same regex in the search field &lt;CODE&gt;... | rex "^\s{3,}(?&amp;amp;lt;QueueCount&amp;amp;gt;\d+)\s(?&amp;amp;lt;QueueName&amp;amp;gt;\w+)"&lt;/CODE&gt; matches nothing&lt;/LI&gt;
&lt;LI&gt;Prefixing the regex with  &lt;CODE&gt;(?m)&lt;/CODE&gt; makes it match the first occurence (same as #2), but not the rest.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;So what does my regex miss in order for Splunk to capture all occurences the same way as Rubular does?&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 10:43:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214741#M62965</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2016-01-06T10:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214742#M62966</link>
      <description>&lt;P&gt;Splunk uses perl regex strings, not ruby.  regex101.com is good site for testing regex strings.  Also, the &lt;CODE&gt;rex&lt;/CODE&gt; command will only return the first match unless the max_match option is used.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | rex max_match=0 "(?&amp;lt;QueueCount&amp;gt;\d+)\s(?&amp;lt;QueueName&amp;gt;[a-zA-Z_]+)" | ...
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jan 2016 13:25:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214742#M62966</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2016-01-06T13:25:33Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214743#M62967</link>
      <description>&lt;P&gt;Aww Rich beat me to it. But this may also work for you:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "-------------------------(?&amp;lt;QueueName&amp;gt;[\s\S]+)$" 
| makemv tokenizer="(?&amp;lt;token&amp;gt;\d\s[A-Za-z]+_[A-Za-z]+?)\b" QueueName
| mvexpand QueueName
| rex field=QueueName "^(?&amp;lt;QueueCount&amp;gt;\d+?)\s(?&amp;lt;QueueName&amp;gt;[A-Za-z]+_[A-Za-z]+?)\b" 
| table QueueCount QueueName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Jan 2016 15:00:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214743#M62967</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2016-01-06T15:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214744#M62968</link>
      <description>&lt;P&gt;Tnx! &lt;/P&gt;

&lt;P&gt;That was what I needed.&lt;/P&gt;

&lt;P&gt;R.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 15:07:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214744#M62968</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2016-01-06T15:07:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214745#M62969</link>
      <description>&lt;P&gt;You are very close to answering my next issue, since I immediately realized that indexing it all as one event makes it hard, if not impossible, to use the queuecount and queuesize as a key-value pair for alerting. But I found two errors (at least I think it is)&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;There are 25 rows returned, that is 25 queuenames, but your search only returns 12 events&lt;/LI&gt;
&lt;LI&gt;The search only return 0 as count, it skips queues with other values.&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 06 Jan 2016 15:36:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214745#M62969</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2016-01-06T15:36:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214746#M62970</link>
      <description>&lt;P&gt;Yes I strongly suggest that break them into seperate events. But its your call. &lt;/P&gt;

&lt;P&gt;My search should work fine, but I did make some assumptions - I'm assuming your queue names are all XYZ_Something. If they vary you'll need to play with the regex.  Also I just copied the data from this website - the actual formatting may be different in your source data - you may need to play around with the rex commands. The regex101 site that Rich posted is excellent for this.&lt;/P&gt;

&lt;P&gt;Here's the output from my search: &lt;A href="http://imgur.com/2SY7lDA"&gt;http://imgur.com/2SY7lDA&lt;/A&gt;&lt;BR /&gt;
&lt;IMG src="http://imgur.com/2SY7lDA" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Jan 2016 16:05:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214746#M62970</guid>
      <dc:creator>jplumsdaine22</dc:creator>
      <dc:date>2016-01-06T16:05:38Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214747#M62971</link>
      <description>&lt;P&gt;Rolling up my sleeves and will dive into the bits and pieces of the search string now to get it working, tnx for the input&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 10:20:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214747#M62971</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2016-01-08T10:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214748#M62972</link>
      <description>&lt;P&gt;Realized the following&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Splitting up the search string you provided and adding one "pipe" after fully understanding each part and it did work as expected&lt;/LI&gt;
&lt;LI&gt;But I realized that the log format is a drawback for what I want to monitor (queuesizes over time), since the searchstring becomes so complex. So decided to create a script that parses the inital logfile and creates an additional file where each line has the format "timestamp queuename queuesize" (off course the best would have been to do it with the inital logfile, but ... to much effort since I then need to communicate with offshore resources...&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Fri, 08 Jan 2016 20:28:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214748#M62972</guid>
      <dc:creator>rune_hellem</dc:creator>
      <dc:date>2016-01-08T20:28:26Z</dc:date>
    </item>
    <item>
      <title>Re: Regex on multiline event - how to match multiple occurences of a matching group?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214749#M62973</link>
      <description>&lt;P&gt;This was perfect!!!! &lt;/P&gt;</description>
      <pubDate>Wed, 02 Oct 2019 19:27:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-on-multiline-event-how-to-match-multiple-occurences-of-a/m-p/214749#M62973</guid>
      <dc:creator>jaxjohnny2000</dc:creator>
      <dc:date>2019-10-02T19:27:47Z</dc:date>
    </item>
  </channel>
</rss>

