<?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 How to extract HTTP status codes in report? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432103#M123461</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;
I know how to extract the HTTP Status from Splunk. But I need it in the below format which I am not able to do:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;If any status with 2% and 3% then it will show as "Success"&lt;/LI&gt;
&lt;LI&gt;Apart from that, it will show all the status codes (example 400, 428, 430, 500, 520 or anything )&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I am able to extract all the codes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval status=case(like(status,"2%"),"2xx",like(status,"3%"),"3xx",like(status,"4%"),"4xx",like(status,"5%"),"5xx") | stats count by status | eventstats sum(count) as perc | eval perc=round(count*100/perc,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But in this, the table is like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  count  perc
2xx  3154   96.63
3xx  44  1.35
4xx  66  2.02
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I remove the eval and like statement then it will show the result as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status count perc
200 2922  88.84
201 252   7.66
302 22  0.67
304 25  0.76
401 9    0.27
404 6    0.18
422 53  1.61
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whereas I want the result as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Status              count   perc
success(2X and 3X)  300     8.00
401                 9       0.27
404                 6       0.18
422                 53      1.61
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can anyone help me? Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 17 Jun 2019 15:53:01 GMT</pubDate>
    <dc:creator>ruchijain</dc:creator>
    <dc:date>2019-06-17T15:53:01Z</dc:date>
    <item>
      <title>How to extract HTTP status codes in report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432103#M123461</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;
I know how to extract the HTTP Status from Splunk. But I need it in the below format which I am not able to do:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;If any status with 2% and 3% then it will show as "Success"&lt;/LI&gt;
&lt;LI&gt;Apart from that, it will show all the status codes (example 400, 428, 430, 500, 520 or anything )&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I am able to extract all the codes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;|eval status=case(like(status,"2%"),"2xx",like(status,"3%"),"3xx",like(status,"4%"),"4xx",like(status,"5%"),"5xx") | stats count by status | eventstats sum(count) as perc | eval perc=round(count*100/perc,2)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But in this, the table is like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status  count  perc
2xx  3154   96.63
3xx  44  1.35
4xx  66  2.02
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If I remove the eval and like statement then it will show the result as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;status count perc
200 2922  88.84
201 252   7.66
302 22  0.67
304 25  0.76
401 9    0.27
404 6    0.18
422 53  1.61
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Whereas I want the result as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Status              count   perc
success(2X and 3X)  300     8.00
401                 9       0.27
404                 6       0.18
422                 53      1.61
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Can anyone help me? Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 15:53:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432103#M123461</guid>
      <dc:creator>ruchijain</dc:creator>
      <dc:date>2019-06-17T15:53:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract HTTP status codes in report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432104#M123462</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search
|eval status=if(like(status,"2%") OR like(status,"3%"),"Success",status) 
| top 0 status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The top command does what you want to do with your stats-eventstats-eval combo.&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 16:11:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432104#M123462</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2019-06-17T16:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract HTTP status codes in report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432105#M123463</link>
      <description>&lt;P&gt;@ruchijain Try below&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;your base search&amp;gt;| eval status=if(like(status,"2%") OR like(status,"3%"),"Success",status) | stats count by status| eventstats sum(count) as perc | eval perc=round(count*100/perc,2)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jun 2019 17:20:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432105#M123463</guid>
      <dc:creator>Vijeta</dc:creator>
      <dc:date>2019-06-17T17:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to extract HTTP status codes in report?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432106#M123464</link>
      <description>&lt;P&gt;If you want what you exactly wrote:&lt;/P&gt;

&lt;PRE&gt;... [ you search ] ...
| eval status = if(match(status, "^[23]\d\d"), "success(2X and 3X)", status)
| top status&lt;/PRE&gt;</description>
      <pubDate>Mon, 17 Jun 2019 17:35:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-extract-HTTP-status-codes-in-report/m-p/432106#M123464</guid>
      <dc:creator>jnudell_2</dc:creator>
      <dc:date>2019-06-17T17:35:18Z</dc:date>
    </item>
  </channel>
</rss>

