<?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: How to edit my search to extract string value from an event and get the total count and range values? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337946#M100235</link>
    <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "response time \((?&amp;lt;response_time&amp;gt;[\d\.]+)\)" | stats count by response_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give count for each value of response_time.&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2017 21:07:25 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2017-03-06T21:07:25Z</dc:date>
    <item>
      <title>How to edit my search to extract string value from an event and get the total count and range values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337945#M100234</link>
      <description>&lt;P&gt;Need to extract string from event and get the total count and range values .&lt;/P&gt;

&lt;P&gt;I have event logs with a "response time (25) sec" and i would like to have the number in () extracted and total count with values in () and check how many are &amp;lt;25 sec and &amp;gt;25 .&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch | feildextracted"response time value from the bracket ()"= * | eval time = case(rep&amp;lt;=2, rep &amp;gt;20, ) | stats count as total by duration 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 20:26:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337945#M100234</guid>
      <dc:creator>guru865</dc:creator>
      <dc:date>2017-03-06T20:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to extract string value from an event and get the total count and range values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337946#M100235</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search | rex "response time \((?&amp;lt;response_time&amp;gt;[\d\.]+)\)" | stats count by response_time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give count for each value of response_time.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 21:07:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337946#M100235</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-06T21:07:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to extract string value from an event and get the total count and range values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337947#M100236</link>
      <description>&lt;P&gt;Following field extraction should work in your case however, you should consider &lt;BR /&gt;
1) either providing more sample data/mock data&lt;BR /&gt;
2) Interactive Field Extraction within Splunk to let Splunk come up with appropriate regular expression as per your data&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rex field=_raw "response\stime\s\((?&amp;lt;response_time&amp;gt;\d+)\)\ssec"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;For coming up with ranges you can try the following&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Option 1&lt;/STRONG&gt;: Splunk's &lt;STRONG&gt;rangemap&lt;/STRONG&gt; command which generates range field&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rangemap field=response_time green=0-2 blue=2-20 red=20-25 default=gray
| stats count as Total by range
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Option 2&lt;/STRONG&gt; If you want to do the same through &lt;STRONG&gt;case&lt;/STRONG&gt; you can try the following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval range=case(response_time&amp;lt;=2,"green",response_time&amp;gt;2 AND response_time&amp;lt;=20,"blue",response_time&amp;gt;20 AND response_time&amp;lt;=25,"red",1==1,"gray")
| stats count as Total by range
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The same can also be done via nested &lt;STRONG&gt;if&lt;/STRONG&gt; command but will become complicated with multiple ranges.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 21:11:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337947#M100236</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2017-03-06T21:11:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to extract string value from an event and get the total count and range values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337948#M100237</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;basesearch | rex "\((?&amp;lt;duration&amp;gt;[\d\.]+)\)" | stats count as total by duration | search count=25
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 21:28:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337948#M100237</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-06T21:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to extract string value from an event and get the total count and range values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337949#M100238</link>
      <description>&lt;P&gt;Thank You Niketnilay .&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:51:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337949#M100238</guid>
      <dc:creator>guru865</dc:creator>
      <dc:date>2017-03-06T22:51:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to edit my search to extract string value from an event and get the total count and range values?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337950#M100239</link>
      <description>&lt;P&gt;Thank you Woodcock .&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:52:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-edit-my-search-to-extract-string-value-from-an-event-and/m-p/337950#M100239</guid>
      <dc:creator>guru865</dc:creator>
      <dc:date>2017-03-06T22:52:01Z</dc:date>
    </item>
  </channel>
</rss>

