<?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: Create Statistic Table Based on Regex in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562700#M196071</link>
    <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237237"&gt;@Wendy&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;You need to extract relevant values in the fields using rex and then use stats to count as per your requirements. Try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=indexname
| rex field=msg "(?&amp;lt;message&amp;gt;(Exception:\s)?(?i)Recaptcha\s(?&amp;lt;version&amp;gt;v\s?\d)[\w\W]+(successful|failure))" 
| eval version=replace(version, "\s+", ""), status=if(match(message, "Exception:"), "FAIL", "SUCCESS") 
| eventstats count as status_count by status 
| stats latest(_time) as _time, latest(*) as * count as message_count by message&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, a like would be appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Aug 2021 02:23:06 GMT</pubDate>
    <dc:creator>manjunathmeti</dc:creator>
    <dc:date>2021-08-10T02:23:06Z</dc:date>
    <item>
      <title>Create Statistic Table Based on Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562693#M196067</link>
      <description>&lt;P&gt;Hi experts, I am new to Splunk and came across this requirement at work.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Requirement:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I want to create a table showing numbers of 2 different versions of recaptcha being successfully and unsuccessfully processed.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Current Log info: &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Each event has a field named "msg" which contains many information, including wording like "&lt;SPAN&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;Exception: recaptcha v 2 validation failure,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;" "&lt;SPAN&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;Exception: recaptcha v 3 validation failure", "Recaptcha v2 verification: successful", Recaptcha v3 verification: successful" based on different events. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;Tasks:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;How can I create a regex expression to count number of all exceptions and number of different types of exceptions? &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;Same tasks for successful message, but I can figure it out if someone can help with the previous question? &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="key level-1"&gt;&lt;SPAN class="t string"&gt;Thank you.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 01:33:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562693#M196067</guid>
      <dc:creator>Wendy</dc:creator>
      <dc:date>2021-08-10T01:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Create Statistic Table Based on Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562699#M196070</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237237"&gt;@Wendy&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;can you share the sample raw event to write a regex. You can anonymize the critical info if any.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 02:06:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562699#M196070</guid>
      <dc:creator>venkatasri</dc:creator>
      <dc:date>2021-08-10T02:06:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create Statistic Table Based on Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562700#M196071</link>
      <description>&lt;P&gt;hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/237237"&gt;@Wendy&lt;/a&gt;,&lt;BR /&gt;&lt;BR /&gt;You need to extract relevant values in the fields using rex and then use stats to count as per your requirements. Try this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=indexname
| rex field=msg "(?&amp;lt;message&amp;gt;(Exception:\s)?(?i)Recaptcha\s(?&amp;lt;version&amp;gt;v\s?\d)[\w\W]+(successful|failure))" 
| eval version=replace(version, "\s+", ""), status=if(match(message, "Exception:"), "FAIL", "SUCCESS") 
| eventstats count as status_count by status 
| stats latest(_time) as _time, latest(*) as * count as message_count by message&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this reply helps you, a like would be appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 02:23:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562700#M196071</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-08-10T02:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create Statistic Table Based on Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562734#M196080</link>
      <description>&lt;P&gt;HI &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/129090"&gt;@manjunathmeti&lt;/a&gt; , that helps. I just need to dissemble your query to understand how it works.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 13:01:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562734#M196080</guid>
      <dc:creator>Wendy</dc:creator>
      <dc:date>2021-08-10T13:01:03Z</dc:date>
    </item>
    <item>
      <title>Re: Create Statistic Table Based on Regex</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562753#M196087</link>
      <description>&lt;P&gt;1. Extract fields&amp;nbsp;message and&amp;nbsp;version from&amp;nbsp;msg using rex command. Check this slink for detailed regex explanation:&amp;nbsp;&amp;nbsp;&lt;A title="https://regex101.com/r/VjmWn6/1/" href="https://regex101.com/r/VjmWn6/1/" target="_self"&gt;https://regex101.com/r/VjmWn6/1/&lt;/A&gt;&amp;nbsp;:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;| rex field=msg "(?&amp;lt;message&amp;gt;(Exception:\s)?(?i)Recaptcha\s(?&amp;lt;version&amp;gt;v\s?\d)[\w\W]+(successful|failure))"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;2. Remove whitespace in field version. Evaluate status to&amp;nbsp;FAIL/SUCCESS based on&amp;nbsp;message field values:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;| eval version=replace(version, "\s+", ""), status=if(match(message, "Exception:"), "FAIL", "SUCCESS") &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;3. Count&amp;nbsp;FAIL/SUCCESS status. Check this link for details on eventstats command &lt;A href="https://docs.splunk.com/Documentation/Splunk/8.2.1/SearchReference/Eventstats" target="_self"&gt;eventstats&lt;/A&gt;&amp;nbsp;.&lt;BR /&gt;&lt;STRONG&gt;| eventstats count as status_count by status&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;4. Count events by the messages. Check this link for details on stats command&amp;nbsp;&lt;A href="https://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Stats" target="_self"&gt;stats&lt;/A&gt;&amp;nbsp;.&lt;BR /&gt;&lt;STRONG&gt;| stats latest(_time) as _time, latest(*) as * count as message_count by message&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Aug 2021 15:22:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Create-Statistic-Table-Based-on-Regex/m-p/562753#M196087</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2021-08-10T15:22:28Z</dc:date>
    </item>
  </channel>
</rss>

