<?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: Help with regex to Extract HTTP reponse codes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297448#M89751</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "(http_srv|http_cli).+(?&amp;lt;HTTP_Code&amp;gt;\d{3})(\[|\sIP)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 22 Aug 2017 16:44:47 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-08-22T16:44:47Z</dc:date>
    <item>
      <title>Help with regex to Extract HTTP reponse codes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297447#M89750</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;

&lt;P&gt;I have the below sample events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;8 Aug 2017 14:45:54 [WARN ] http_srv: Total latency exceeded threshold: 0.180145 seconds (internal 0.180000 s) origin 0.140000 seconds MCHit 0 Status: **200** IP: 69.xxx.xxx.13:2062 URL: 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sample event 2&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;18 Aug 2017 15:06:30 [WARN ] http_cli: Origin latency exceeded threshold: 0.141100 seconds GET Status: **200**[OK] Bytes: 10081 Origin URL: http://linear-scope010.com/LIVE/1007/hls/ae/MSNBC_HD/900.m3u8 refReqId 13542238 reqWait 0 (id 3289754508)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sample event 3 &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Aug 2017 17:58:07 [WARN ] http_srv: DONE 4199750 0.023084 **404**[Not ...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;sample event 4-this does not have the http code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;22 Aug 2017 15:50:27 [WARN ] Content Generator: Discontinuity Sequence mismatch adding 982 at frag 1989008, adjusting previous (id 26007997)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want a help with regex to extract the HTTP Response codes of events  which  have http_srv or http_cli in the events and save them in field called HTTP_Code .&lt;BR /&gt;
Thanks in advance&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:29:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297447#M89750</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2020-09-29T15:29:04Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex to Extract HTTP reponse codes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297448#M89751</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "(http_srv|http_cli).+(?&amp;lt;HTTP_Code&amp;gt;\d{3})(\[|\sIP)"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 22 Aug 2017 16:44:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297448#M89751</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-22T16:44:47Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex to Extract HTTP reponse codes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297449#M89752</link>
      <description>&lt;P&gt;Hi vrmandadi,&lt;BR /&gt;
I'm not able to extract HTTP_Values for all samples using only one regex, but I can do it in two regexes:&lt;BR /&gt;
to extract HTTP_Code from samples 1, you can use the following regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(http_srv|http_cli).*Status:\s(?&amp;lt;HTTP_Code1&amp;gt;\d+)\s
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;instead for the Sample 2 and 3 use this regex&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(http_srv|http_cli).*\s(?&amp;lt;HTTP_Code2&amp;gt;\d+)(\[OK|\[Not)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After you can merge results using coalesce function:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval HTTP_Code=coalesce(HTTP_Code1,HTTP_Code2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 02:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297449#M89752</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2020-09-30T02:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: Help with regex to Extract HTTP reponse codes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297450#M89753</link>
      <description>&lt;P&gt;Hello @somesoni2&lt;/P&gt;

&lt;P&gt;Thanks for the somesh it worked&lt;/P&gt;</description>
      <pubDate>Tue, 22 Aug 2017 17:24:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Help-with-regex-to-Extract-HTTP-reponse-codes/m-p/297450#M89753</guid>
      <dc:creator>vrmandadi</dc:creator>
      <dc:date>2017-08-22T17:24:27Z</dc:date>
    </item>
  </channel>
</rss>

