<?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 do you find two string values in every group of events grouped by a particular field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446887#M126741</link>
    <description>&lt;P&gt;@rohanmiskin,&lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | rex field=error_code "^(?&amp;lt;status_code&amp;gt;\d+).*" | stats first(error_code) as request last(error_code) as error values(status_code) as status_code by corrid | where status_code in (304,400,404,500) | table request corrid error status_code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;MY Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="A  B   C
10.30 2019  1111    POST /data1
10.31 2019  1111    data verified
10.32 2019  1111    404 not found
10.30 2019  2222    Get /data2
10.31 2019  2222    data verified
10.32 2019  2222    400 error
10.30 2019  3333    DELETE /data3
10.31 2019  3333    data verified
10.32 2019  3333    304 not modified
10.30 2019  4444    PUT /data4
10.31 2019  4444    data verified
10.32 2019  4444    201 Created
" 
| multikv 
|rename B as corrid,C as error_code
| rex field=error_code "^(?&amp;lt;status_code&amp;gt;\d+).*" | stats first(error_code) as request last(error_code) as error values(status_code) as status_code by corrid | where status_code in (304,400,404,500) | table request corrid error status_code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 06 Feb 2019 12:45:48 GMT</pubDate>
    <dc:creator>kamlesh_vaghela</dc:creator>
    <dc:date>2019-02-06T12:45:48Z</dc:date>
    <item>
      <title>How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446884#M126738</link>
      <description>&lt;P&gt;I have log events for a spring boot application in the format&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;10.30 2019 | 1111 | POST /data1&lt;BR /&gt;
10.31 2019 | 1111 | data verified&lt;BR /&gt;
10.32 2019 | 1111 | 404 not found&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;10.30 2019 | 2222  | Get /data2&lt;BR /&gt;
10.31 2019 | 2222 | data verified&lt;BR /&gt;
10.32 2019 | 2222 | 400 error&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;10.30 2019 | 3333 | DELETE /data3&lt;BR /&gt;
10.31 2019 | 3333 | data verified&lt;BR /&gt;
10.32 2019 | 3333 | 304 not modified&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;10.30 2019 | 4444 | PUT /data4&lt;BR /&gt;
10.31 2019 | 4444 | data verified&lt;BR /&gt;
10.32 2019 | 4444 | 201 Created&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;Every HTTP request has a unique correlation ID and is maintained till the request either gets failed or succeeded.&lt;/P&gt;

&lt;P&gt;In our case 1111,2222,3333,4444 are the correlation IDs for 4 different requests, POST,GET,DELETE,PUT respectively.&lt;/P&gt;

&lt;P&gt;I want to get the result with error codes 304,400,404,500 (excluding success scenarios i.e 201) in this format&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;request         | corrid | error code         |
POST /data1     | 1111   | 404 not found      | 
Get /data2      | 2222   | 400 error          | 
DELETE /data3   | 3333   | 304 not modified   |
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 11:54:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446884#M126738</guid>
      <dc:creator>rohanmiskin</dc:creator>
      <dc:date>2019-02-06T11:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446885#M126739</link>
      <description>&lt;P&gt;I have uploaded the above data and tried the below query: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source="abcde.txt" host="test" sourcetype="csv4" ip="10.30 2019"  | join corr_id [search source="abcde.txt" host="test" sourcetype="csv4" ip="10.32 2019" | table corr_id activity | where NOT (activity like "201%") | rename activity as error_code] | table corr_id activity error_code
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 12:28:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446885#M126739</guid>
      <dc:creator>vishaltaneja070</dc:creator>
      <dc:date>2019-02-06T12:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446886#M126740</link>
      <description>&lt;P&gt;@rohanmiskin,&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Updated:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your base search"
|stats values(eval(if(match(request,"PUT|DELETE|GET|POST"),request,null()))) as Request,
       values(eval(if(match(response,"^\d"),response,null())))  as Response by code
|where !LIKE(Response ,"20%")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Try,&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;"your base search" 
|stats earliest(request) as Request,latest(request) as Response by corrid |where !LIKE(Response ,"20%")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Feb 2019 12:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446886#M126740</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-02-06T12:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446887#M126741</link>
      <description>&lt;P&gt;@rohanmiskin,&lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | rex field=error_code "^(?&amp;lt;status_code&amp;gt;\d+).*" | stats first(error_code) as request last(error_code) as error values(status_code) as status_code by corrid | where status_code in (304,400,404,500) | table request corrid error status_code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;MY Sample Search:&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval _raw="A  B   C
10.30 2019  1111    POST /data1
10.31 2019  1111    data verified
10.32 2019  1111    404 not found
10.30 2019  2222    Get /data2
10.31 2019  2222    data verified
10.32 2019  2222    400 error
10.30 2019  3333    DELETE /data3
10.31 2019  3333    data verified
10.32 2019  3333    304 not modified
10.30 2019  4444    PUT /data4
10.31 2019  4444    data verified
10.32 2019  4444    201 Created
" 
| multikv 
|rename B as corrid,C as error_code
| rex field=error_code "^(?&amp;lt;status_code&amp;gt;\d+).*" | stats first(error_code) as request last(error_code) as error values(status_code) as status_code by corrid | where status_code in (304,400,404,500) | table request corrid error status_code
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 06 Feb 2019 12:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446887#M126741</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-02-06T12:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446888#M126742</link>
      <description>&lt;P&gt;actually for a particular corrid,  POST /data1,Get /data2 etc are no the earliest and the status codes are not the latest. The are other logs too before POST /data1,Get /data2 and after status codes.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 10:51:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446888#M126742</guid>
      <dc:creator>rohanmiskin</dc:creator>
      <dc:date>2019-02-07T10:51:54Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446889#M126743</link>
      <description>&lt;P&gt;actually for a particular corrid,  POST /data1,Get /data2 etc are no the first and the status codes are not the last logs. The are other logs too before POST /data1,Get /data2 and after status codes.&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 10:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446889#M126743</guid>
      <dc:creator>rohanmiskin</dc:creator>
      <dc:date>2019-02-07T10:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446890#M126744</link>
      <description>&lt;P&gt;@rohanmiskin&lt;/P&gt;

&lt;P&gt;Ip is constant for one kind of event like Post/DELETE/PUT?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Feb 2019 11:01:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446890#M126744</guid>
      <dc:creator>vishaltaneja070</dc:creator>
      <dc:date>2019-02-07T11:01:01Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446891#M126745</link>
      <description>&lt;P&gt;@rohanmiskin ,&lt;/P&gt;

&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; "your base search"
 |stats values(eval(if(match(request,"PUT|DELETE|GET|POST"),request,null()))) as Request,
        values(eval(if(match(response,"^\d"),response,null())))  as Response by code
 |where !LIKE(Response ,"20%")
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 13:09:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446891#M126745</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-02-07T13:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446892#M126746</link>
      <description>&lt;P&gt;@rohanmiskin,&lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;YOUR_SEARCH | rex field=error_code "^(?&amp;lt;status_code&amp;gt;\d+).*" | eval Request= if(match(error_code,"PUT|DELETE|GET|POST"),error_code,null()), Response= if(match(error_code,"^\d"),error_code,null()) 
| stats values(Request) as request values(Response) as error values(status_code) as status_code by corrid | where status_code in (304,400,404,500) | table request corrid error status_code
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 14:43:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446892#M126746</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2019-02-07T14:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: How do you find two string values in every group of events grouped by a particular field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446893#M126747</link>
      <description>&lt;P&gt;May or may not be.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 05:41:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-you-find-two-string-values-in-every-group-of-events/m-p/446893#M126747</guid>
      <dc:creator>rohanmiskin</dc:creator>
      <dc:date>2019-02-08T05:41:44Z</dc:date>
    </item>
  </channel>
</rss>

