<?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 Matching/Please give any solution in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449725#M127343</link>
    <description>&lt;P&gt;Now working. One change in the log. Message for System message is:  Rohi is online and Ready to chat. It its not ready to chat.&lt;/P&gt;

&lt;P&gt;This is the one whcih I executed.&lt;/P&gt;

&lt;P&gt;index="use_case_one" &lt;BR /&gt;
 | makemv tokenizer="(?ms)(.&lt;EM&gt;?)\s&lt;/EM&gt;[\r\n]{2,}\s*" DATA&lt;BR /&gt;
 | rex field=DATA "(?\S+) is online and ready to chat."&lt;BR /&gt;
 | eval DATA=mvindex(DATA, mvfind(DATA, "online and ready to chat") + 1, -1)&lt;BR /&gt;
 | eval agentFilterRegEx = " [AP]M[\r\n\s]+" . agent . "[\r\n\s]"&lt;BR /&gt;
 | eval agentFirstResponse = mvindex(DATA, mvfind(DATA, agentFilterRegEx))&lt;BR /&gt;
 | rex field=agentFirstResponse "(?ms)^(?[^\r\n]+)[\r\n]+[^\r\n]+[\r\n]+(?.*)$"&lt;BR /&gt;
 | eval agentFirstResponseTime = strptime(agentFirstResponseTime, "%m/%d/%Y %H:%M:%S %p")&lt;BR /&gt;
 | fieldformat agentFirstResponseTime = strftime(agentFirstResponseTime, "%m/%d/%Y %H:%M:%S %p")&lt;BR /&gt;
 | table "Session Log" "DATA"&lt;/P&gt;</description>
    <pubDate>Wed, 30 Sep 2020 01:05:23 GMT</pubDate>
    <dc:creator>rajaguru2790</dc:creator>
    <dc:date>2020-09-30T01:05:23Z</dc:date>
    <item>
      <title>Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449717#M127335</link>
      <description>&lt;P&gt;A field has multiple lines like a  chat log. Below aLL DATA IS in one field of Splunk in the same way as below. Now need to match agent's initial response and capture in a separate field. Aju is the user and Rohi is the agent. Whenever chat is assigned to agent system messgae generated(In this example 1/1/2019 2:42:59 AM Rohi system message: ready to chat). Need to match the next line of agent response time after this agent system message "Rohi system message: ready to chat" in the entire log . That is called initial reponse for this chat (In this example it's timestamp/transcript is (1/1/2019 2:51:16 AM  Rohi Hello Aju my name is Rohi. How can I help you today?) )Please help me on calculating Initial reponse time to a separate field using REGEX or someother way. Thanks&lt;/P&gt;

&lt;P&gt;1/1/2019 2:42:55 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;Hi Team&lt;/H2&gt;

&lt;P&gt;1/1/2019 2:42:56 AM &lt;BR /&gt;
System &lt;BR /&gt;
The data has been added: &lt;/P&gt;

&lt;H2&gt; - Customer Info&lt;/H2&gt;

&lt;P&gt;1/1/2019 2:42:59 AM &lt;BR /&gt;
Rohi&lt;/P&gt;

&lt;H2&gt;System Message: Rohi is ready to chat. &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:43:09 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;Wish you a very happy ne year &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:43:12 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;new* &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:43:25 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;I need to KNOW ABOUT A CAR&lt;/H2&gt;

&lt;P&gt;1/1/2019 2:43:32 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;please help me  &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:45:07 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;Anyone there ? &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:47:13 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;?? &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:49:23 AM &lt;BR /&gt;
Aju &lt;/P&gt;

&lt;H2&gt;?? Hi Rohi You there? &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:51:16 AM &lt;BR /&gt;
Rohi&lt;/P&gt;

&lt;H2&gt;Hello Aju my name is Rohi. How can I help you today? &lt;/H2&gt;

&lt;P&gt;1/1/2019 2:51:27 AM &lt;/P&gt;

&lt;P&gt;Chat goes on....&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 13:16:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449717#M127335</guid>
      <dc:creator>rajaguru2790</dc:creator>
      <dc:date>2019-06-26T13:16:53Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449718#M127336</link>
      <description>&lt;P&gt;Hi rajaguru2790,&lt;BR /&gt;
Try something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rex "System Message: \w+ is ready to chat\.\s+\d+\/\d+\/\d+\s\d+:\d+:\d+\s+\w+\s+\w+\s+(?P&amp;lt;my_field&amp;gt;.+)$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You can test it at &lt;A href="https://regex101.com/r/fjaU3e/1"&gt;https://regex101.com/r/fjaU3e/1&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2019 14:12:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449718#M127336</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2019-06-26T14:12:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449719#M127337</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/183161"&gt;@rajaguru2790&lt;/a&gt; ,&lt;/P&gt;

&lt;P&gt;You can use the following:&lt;BR /&gt;
&lt;PRE&gt;| rex "^(?&amp;lt;chat_start_time&amp;gt;[^\r\n]+)[\r\n]+[\S\s]+System\s+Message:\s+(?&amp;lt;agent&amp;gt;\S+) is ready to chat[\S\s]+[\r\n]+(?&amp;lt;initial_response_time&amp;gt;[^\r\n]+)[\r\n]+\2[\r\n]+(?&amp;lt;initial_response&amp;gt;[^\r\n]+)[\r\n]+" &lt;BR /&gt;
| eval chat_start_time = strptime(chat_start_time, "%m/%d/%Y %I:%M:%S %p") &lt;BR /&gt;
| eval initial_response_time = strptime(initial_response_time, "%m/%d/%Y %I:%M:%S %p")&lt;BR /&gt;
| eval agent_response_time = tostring(initial_response_time - chat_start_time, "duration")&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;This will look something like this:&lt;BR /&gt;
&lt;IMG src="https://community.splunk.com/storage/temp/273972-screenshot-from-2019-06-26-12-50-41.png" alt="alt text" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:03:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449719#M127337</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2020-09-30T01:03:54Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449720#M127338</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval DATA="1/1/2019 2:42:55 AM 
Aju 
Hi Team

1/1/2019 2:42:56 AM 
System 
The data has been added: 
- Customer Info

1/1/2019 2:42:59 AM 
Rohi
System Message: Rohi is ready to chat. 

1/1/2019 2:43:09 AM 
Aju 
Wish you a very happy ne year 

1/1/2019 2:43:12 AM 
Aju 
new* 

1/1/2019 2:43:25 AM 
Aju 
I need to KNOW ABOUT A CAR

1/1/2019 2:43:32 AM 
Aju 
please help me 

1/1/2019 2:45:07 AM 
Aju 
Anyone there ? 

1/1/2019 2:47:13 AM 
Aju 
?? 

1/1/2019 2:49:23 AM 
Aju 
?? Hi Rohi You there? 

1/1/2019 2:51:16 AM 
Rohi
Hello Aju my name is Rohi. How can I help you today? 

1/1/2019 2:51:27 AM"

| rename COMMENT AS "Everything above generates sample event data; everything below is your solution"

| makemv tokenizer="(?ms)(.*?)\s*[\r\n]{2,}\s*" DATA
| rex field=DATA "(?&amp;lt;agent&amp;gt;\S+) is ready to chat\."
| eval DATA=mvindex(DATA, mvfind(DATA, "ready to chat") + 1, -1)
| eval agentFilterRegEx = " [AP]M[\r\n\s]+" . agent . "[\r\n\s]"
| eval agentFirstResponse = mvindex(DATA, mvfind(DATA, agentFilterRegEx))
| rex field=agentFirstResponse "(?ms)^(?&amp;lt;agentFirstResponseTime&amp;gt;[^\r\n]+)[\r\n]+[^\r\n]+[\r\n]+(?&amp;lt;agentFirstResponse&amp;gt;.*)$"
| eval agentFirstResponseTime = strptime(agentFirstResponseTime, "%m/%d/%Y %H:%M:%S %p")
| fieldformat agentFirstResponseTime = strftime(agentFirstResponseTime, "%m/%d/%Y %H:%M:%S %p")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Jun 2019 19:12:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449720#M127338</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-29T19:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449721#M127339</link>
      <description>&lt;P&gt;Thanks for the help. I am getting this error. &lt;/P&gt;

&lt;P&gt;Error in 'rex' command: regex="System Message: \w+ is ready to chat.\s+\d+\/\d+\/\d+\s\d+:\d+:\d+\s+\w+\s+\w+\s+(?P.+)$" has exceeded configured match_limit, consider raising the value in limits.conf&lt;/P&gt;

&lt;P&gt;I chnaged the limits.conf in local like below. But didnot work&lt;/P&gt;

&lt;P&gt;[rex]&lt;BR /&gt;
match_limit = 0&lt;BR /&gt;
depth_limit = 0&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:05:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449721#M127339</guid>
      <dc:creator>rajaguru2790</dc:creator>
      <dc:date>2020-09-30T01:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449722#M127340</link>
      <description>&lt;P&gt;Error in 'rex' command: regex="System Message: \w+ is ready to chat.\s+\d+\/\d+\/\d+\s\d+:\d+:\d+\s+\w+\s+\w+\s+(?P.+)$" has exceeded configured match_limit, consider raising the value in limits.conf&lt;/P&gt;

&lt;P&gt;I chnaged the limits.conf in local like below. But didnot work&lt;/P&gt;

&lt;P&gt;[rex]&lt;BR /&gt;
match_limit = 0&lt;BR /&gt;
depth_limit = 0&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:05:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449722#M127340</guid>
      <dc:creator>rajaguru2790</dc:creator>
      <dc:date>2020-09-30T01:05:12Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449723#M127341</link>
      <description>&lt;P&gt;Hi . Thanks for teh help. Like this there are 10000 chats with different names . How can I take this generically. Please assist&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 06:26:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449723#M127341</guid>
      <dc:creator>rajaguru2790</dc:creator>
      <dc:date>2019-07-01T06:26:12Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449724#M127342</link>
      <description>&lt;P&gt;This should work as-is, so long as the field with your message is called &lt;CODE&gt;DATA&lt;/CODE&gt;.  If not, just change the field name everywhere.  Of course, you throw out the stuff before the &lt;CODE&gt;COMMENT&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jul 2019 15:26:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449724#M127342</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-07-01T15:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449725#M127343</link>
      <description>&lt;P&gt;Now working. One change in the log. Message for System message is:  Rohi is online and Ready to chat. It its not ready to chat.&lt;/P&gt;

&lt;P&gt;This is the one whcih I executed.&lt;/P&gt;

&lt;P&gt;index="use_case_one" &lt;BR /&gt;
 | makemv tokenizer="(?ms)(.&lt;EM&gt;?)\s&lt;/EM&gt;[\r\n]{2,}\s*" DATA&lt;BR /&gt;
 | rex field=DATA "(?\S+) is online and ready to chat."&lt;BR /&gt;
 | eval DATA=mvindex(DATA, mvfind(DATA, "online and ready to chat") + 1, -1)&lt;BR /&gt;
 | eval agentFilterRegEx = " [AP]M[\r\n\s]+" . agent . "[\r\n\s]"&lt;BR /&gt;
 | eval agentFirstResponse = mvindex(DATA, mvfind(DATA, agentFilterRegEx))&lt;BR /&gt;
 | rex field=agentFirstResponse "(?ms)^(?[^\r\n]+)[\r\n]+[^\r\n]+[\r\n]+(?.*)$"&lt;BR /&gt;
 | eval agentFirstResponseTime = strptime(agentFirstResponseTime, "%m/%d/%Y %H:%M:%S %p")&lt;BR /&gt;
 | fieldformat agentFirstResponseTime = strftime(agentFirstResponseTime, "%m/%d/%Y %H:%M:%S %p")&lt;BR /&gt;
 | table "Session Log" "DATA"&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:05:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449725#M127343</guid>
      <dc:creator>rajaguru2790</dc:creator>
      <dc:date>2020-09-30T01:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449726#M127344</link>
      <description>&lt;P&gt;Guess something like this is the only way, huh. Shame Splunk doesn't support using &lt;CODE&gt;(?P=name)&lt;/CODE&gt; to match a named subpattern. That way you could have done it with a single regex: &lt;A href="https://regex101.com/r/d8F6SN/1/"&gt;https://regex101.com/r/d8F6SN/1/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Edit: oh, wait, that is supported: &lt;CODE&gt;| rex "(?s)System Message: (?&amp;lt;agent&amp;gt;\w+) is ready to chat.*?[\r\n]+[\d\/]+\s+[\d:]+\s+\w+\s+[\r\n]+(?P=agent)[\r\n]+(?&amp;lt;agentFirstResponse&amp;gt;.*?)[\r\n]+[\d\/]+\s+[\d:]+\s+\w+"&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Or see the answer from @jnudell_2 for a similar solution using &lt;CODE&gt;\1&lt;/CODE&gt; instead of &lt;CODE&gt;(?P=agent)&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 10:03:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449726#M127344</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-07-02T10:03:22Z</dc:date>
    </item>
    <item>
      <title>Re: Regex Matching/Please give any solution</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449727#M127345</link>
      <description>&lt;P&gt;That is not the same regex that jnudell_2 suggested. Did you actually try the correct regex? I've tested this as well and it seems to work fine.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults | eval _raw="1/1/2019 2:42:55 AM 
Aju 
Hi Team

1/1/2019 2:42:56 AM 
System 
The data has been added: 
- Customer Info

1/1/2019 2:42:59 AM 
Rohi
System Message: Rohi is ready to chat. 

1/1/2019 2:43:09 AM 
Aju 
Wish you a very happy ne year 

1/1/2019 2:43:12 AM 
Aju 
new* 

1/1/2019 2:43:25 AM 
Aju 
I need to KNOW ABOUT A CAR

1/1/2019 2:43:32 AM 
Aju 
please help me 

1/1/2019 2:45:07 AM 
Aju 
Anyone there ? 

1/1/2019 2:47:13 AM 
Aju 
?? 

1/1/2019 2:49:23 AM 
Aju 
?? Hi Rohi You there? 

1/1/2019 2:51:16 AM 
Rohi
Hello Aju my name is Rohi. How can I help you today? 

1/1/2019 2:51:27 AM

Chat goes on...."
 | rex "^(?&amp;lt;chat_start_time&amp;gt;[^\r\n]+)[\r\n]+[\S\s]+System\s+Message:\s+(?&amp;lt;agent&amp;gt;\S+) is ready to chat[\S\s]+[\r\n]+(?&amp;lt;initial_response_time&amp;gt;[^\r\n]+)[\r\n]+\2[\r\n]+(?&amp;lt;initial_response&amp;gt;[^\r\n]+)[\r\n]+"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternatively, this rex also works: &lt;CODE&gt;| rex "System Message: (?&amp;lt;agent&amp;gt;\w+) is ready to chat.*?[\r\n]+[\d\/]+\s+[\d:]+\s+\w+\s+[\r\n]+(?P=agent)[\r\n]+(?&amp;lt;agentFirstResponse&amp;gt;.*?)[\r\n]+[\d\/]+\s+[\d:]+\s+\w+"&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jul 2019 10:24:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Regex-Matching-Please-give-any-solution/m-p/449727#M127345</guid>
      <dc:creator>FrankVl</dc:creator>
      <dc:date>2019-07-02T10:24:20Z</dc:date>
    </item>
  </channel>
</rss>

