<?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: search by http response code in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33524#M7134</link>
    <description>&lt;P&gt;Well, if you're writing the transforms.conf, you can "get it right the first time" by naming the fields whatever you like; each item in the FIELDS list will act as the new field name for the extracted fields.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Apr 2012 17:58:00 GMT</pubDate>
    <dc:creator>sowings</dc:creator>
    <dc:date>2012-04-24T17:58:00Z</dc:date>
    <item>
      <title>search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33515#M7125</link>
      <description>&lt;P&gt;Hi, I would like to search status=304 or 500 in web server's access log but the search result is empty.&lt;BR /&gt;
Here is one sample line in the access log. Any advice? Thanks in advance!&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2012-04-23      10:56:51        10.39.19.101    "user_D"      "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E; InfoPath.2)"       GET     /ask/faq.html    -       304     0       0.0010
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Apr 2012 15:06:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33515#M7125</guid>
      <dc:creator>shangshin</dc:creator>
      <dc:date>2012-04-23T15:06:37Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33516#M7126</link>
      <description>&lt;P&gt;I'm assuming that the "304" in your sample line is the status code you want.&lt;/P&gt;

&lt;P&gt;Do you have it extracted as a field? If not - you'll need to extract it to make it searchable. You can still search for 304 or 500 or 404 as strings, but then you might also get results where the number is found elsewhere in the event.&lt;/P&gt;

&lt;P&gt;For guidance on field extraction, see the docs pages for the Interactive Field Extractor&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Addfieldsatsearchtime"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Knowledge/Addfieldsatsearchtime&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;When you have the field extracted (e.g. as &lt;CODE&gt;status&lt;/CODE&gt;) you can simply search for it;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=your_sourcetype status=304 OR status=500
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;HR /&gt;

&lt;P&gt;UPDATE:&lt;/P&gt;

&lt;P&gt;I'm not sure I can help you with IFX problems, but you can make these field extractions directly in the &lt;CODE&gt;props.conf&lt;/CODE&gt; file. Just put the following &lt;CODE&gt;EXTRACT&lt;/CODE&gt; lines under the stanza for your sourcetype.&lt;BR /&gt;
Please note that there are several &lt;CODE&gt;props.conf&lt;/CODE&gt; files, but unless you have a heavy forwarder reading the log files and sending them to the indexer, you could/should create/edit &lt;CODE&gt;/opt/splunk/etc/system/local/props.conf&lt;/CODE&gt; on the indexer. Just make sure that you have the correct ownership/permissions on the file if you create a new one.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[your_sourcetype]
EXTRACT-wl_status = (?&amp;lt;status&amp;gt;\S+)\s+\S+\s+\S+$
EXTRACT-wl_timetaken = (?&amp;lt;time_taken&amp;gt;\S+)$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Your search would look something like;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=your_sourcetype NOT status=200 OR time_taken &amp;gt; 90
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps,&lt;/P&gt;

&lt;P&gt;Kristian&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2012 15:16:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33516#M7126</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-23T15:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33517#M7127</link>
      <description>&lt;P&gt;Thanks -- Kristian.&lt;/P&gt;

&lt;P&gt;I followed example in the docs page and tried to add a new error code field. However, I got the error message when hitting the save button. Can you shed some light on this or provide a sample for this real use case?&lt;/P&gt;

&lt;P&gt;Encountered the following error while trying to save: In handler 'props-extract': cannot find transform name=device_id=[w+](?&amp;lt;err_code&amp;gt;[^:]+)&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:42:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33517#M7127</guid>
      <dc:creator>shangshin</dc:creator>
      <dc:date>2020-09-28T11:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33518#M7128</link>
      <description>&lt;P&gt;Hmm, what kind of log are you working on (post some sample data)? Not really familiar with the error message, are you using transforms?&lt;/P&gt;

&lt;P&gt;Show some sample events and tell us what you want to extract.&lt;/P&gt;

&lt;P&gt;/k&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2012 15:58:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33518#M7128</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-23T15:58:02Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33519#M7129</link>
      <description>&lt;P&gt;It's a weblogic access log file and the column headers are &lt;/P&gt;

&lt;P&gt;date time c-ip cs(proxy-remote-user) cs(user-agent) cs-method cs-uri-stem cs-uri-query sc-status bytes time-taken&lt;/P&gt;

&lt;P&gt;We would like to get alerts if status code (sc-status) is not 200 or time-taken is greater than 90 seconds. This is a real use case and I would appreciate if you can provide an example of field extractor.&lt;/P&gt;</description>
      <pubDate>Mon, 23 Apr 2012 16:25:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33519#M7129</guid>
      <dc:creator>shangshin</dc:creator>
      <dc:date>2012-04-23T16:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33520#M7130</link>
      <description>&lt;P&gt;see update above. /k&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2012 08:08:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33520#M7130</guid>
      <dc:creator>kristian_kolb</dc:creator>
      <dc:date>2012-04-24T08:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33521#M7131</link>
      <description>&lt;P&gt;Thanks a lot. field extractor for status code is GOOD! But strangely, time_taken doesn't seem to work because nothing is returned from the search. &lt;/P&gt;

&lt;P&gt;I also tried to create the index for the user_id on column 4 using &lt;BR /&gt;
EXTRACT-wl_userid = ^\S+\s+\S+\s+\S+\s+(?&lt;USERID&gt;\S+)\s+&lt;/USERID&gt;&lt;/P&gt;

&lt;P&gt;I would apprecaite if you can shed some light on this so we can demonstarte a usful product.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:42:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33521#M7131</guid>
      <dc:creator>shangshin</dc:creator>
      <dc:date>2020-09-28T11:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33522#M7132</link>
      <description>&lt;P&gt;Looks like that data is separated by tabs.  I'd suggest:&lt;/P&gt;

&lt;P&gt;props.conf:&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
[your_sourcetype_here]&lt;BR /&gt;
REPORT-myfields = wl_kv_and_fields&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;

&lt;P&gt;Then in transforms.conf:&lt;BR /&gt;
&lt;PRE&gt;&lt;BR /&gt;
[wl_kv_and_fields]&lt;BR /&gt;
DELIMS = "\t"&lt;BR /&gt;
FIELDS = date, time, c-ip, proxy-remote-user, user-agent, cs-method, cs-uri-stem, cs-uri-query, sc-status, bytes, time-taken&lt;BR /&gt;
&lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:43:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33522#M7132</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2020-09-28T11:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33523#M7133</link>
      <description>&lt;P&gt;You may also need to set field aliases.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2012 17:54:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33523#M7133</guid>
      <dc:creator>rcovert</dc:creator>
      <dc:date>2012-04-24T17:54:50Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33524#M7134</link>
      <description>&lt;P&gt;Well, if you're writing the transforms.conf, you can "get it right the first time" by naming the fields whatever you like; each item in the FIELDS list will act as the new field name for the extracted fields.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Apr 2012 17:58:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33524#M7134</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2012-04-24T17:58:00Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33525#M7135</link>
      <description>&lt;P&gt;This is exactly what we need!!! Many thanks.&lt;BR /&gt;
Now the backend is set up. One quick question for the search operator:&lt;/P&gt;

&lt;P&gt;When should I add the operator AND &lt;/P&gt;

&lt;P&gt;Result is returned as expected:&lt;BR /&gt;
sourcetype="weblogic_access_log" proxy_remote_user="my_user_id"&lt;/P&gt;

&lt;P&gt;No result is returned:&lt;BR /&gt;
sourcetype="weblogic_access_log" and proxy_remote_user="my_user_id"&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:43:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33525#M7135</guid>
      <dc:creator>shangshin</dc:creator>
      <dc:date>2020-09-28T11:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: search by http response code</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33526#M7136</link>
      <description>&lt;P&gt;Operator AND is implied.  If you don't specify, Splunk assumes AND.&lt;/P&gt;

&lt;P&gt;The AND and OR operators must be in all caps to differentiate them from search terms.  &lt;/P&gt;

&lt;P&gt;In your second example above, Splunk thinks you're also looking for the word "and" in a weblogic_access_log where proxy_remote_user="my_user_id".&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 11:43:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-by-http-response-code/m-p/33526#M7136</guid>
      <dc:creator>sowings</dc:creator>
      <dc:date>2020-09-28T11:43:10Z</dc:date>
    </item>
  </channel>
</rss>

