<?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: Query with an additional condition in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666208#M228545</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/228576"&gt;@ivan123357&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I'd try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=custom (evt_id=1 OR evt_id=2) earliest=-5m latest=-7m
|  stats
   last(evt_id) AS evt_id
   earliest(_time) AS earliest
   latest(_time) AS latest
   BY user_id
| where evt_id=1 OR (latest-earliest&amp;gt;300)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Wed, 25 Oct 2023 17:10:17 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-10-25T17:10:17Z</dc:date>
    <item>
      <title>Query with an additional condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666153#M228530</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Faced with writing a query with an additional check and I can't find a way out. I will be glad if you tell me the direction or help with advice.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We have the following custom logic:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1. When user do some action(it is not important) we generate an event in &lt;EM&gt;index=custom&amp;nbsp;&lt;/EM&gt;with the following fields: evt_id: 1,&amp;nbsp; user_id: 555 (example)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2.&amp;nbsp;The user should confirm that he is doing this "some action" in third-party app, and this app generate to the &lt;EM&gt;index=custom&amp;nbsp;&lt;/EM&gt;the next event: evt_id: 2, user_id:555 (example) msg:confirmed&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;3. If user NOT CONFIRMED the SOME ACTION from step 1 - we need to generate alert. It means, that Splunk&amp;nbsp;didn't&amp;nbsp;receive evt_id:2 in &lt;EM&gt;index=custom&amp;nbsp;&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The alert logic is following:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We need to alert &lt;STRONG&gt;when&amp;nbsp;&amp;nbsp;&lt;/STRONG&gt;&lt;EM&gt;evt_id: 1&amp;nbsp;&lt;/EM&gt;was more than 5 minutes ago(the time that the user has to confirm "some action') &lt;STRONG&gt;and when&amp;nbsp;&lt;/STRONG&gt;&lt;STRONG&gt;NO&lt;/STRONG&gt; evt_id: 2 with the same &lt;EM&gt;user_id&lt;/EM&gt; by the time the alert starts working.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I understood that I&amp;nbsp;need to do the first search like(example):&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=custom evt_id=1 earliest=-5m latest=-7m&lt;/LI-CODE&gt;&lt;P&gt;But I have no idea how to implement additional condition with evt_id:2. if we didn't have the &lt;EM&gt;user_id&lt;/EM&gt; field, then I could use &lt;EM&gt;stats&amp;nbsp; count&lt;/EM&gt; command but I need&amp;nbsp;&amp;nbsp;to correlate both events(1 and 2) with the field user_id.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for you help, have a nice day.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 13:55:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666153#M228530</guid>
      <dc:creator>ivan123357</dc:creator>
      <dc:date>2023-10-25T13:55:12Z</dc:date>
    </item>
    <item>
      <title>Re: Query with an additional condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666190#M228540</link>
      <description>&lt;P&gt;Assuming you are correlating by user id (as you don't appear to have the action id in your index), you could do something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=custom evt_id=1 OR evt_id=2 earliest=-7m latest=now
| stats latest(evt_id) as last_event latest(_time) as last_time by user_id
| where last_event=1 AND last_time &amp;lt; relative_time(now(), "-5m")&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 25 Oct 2023 15:58:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666190#M228540</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-10-25T15:58:01Z</dc:date>
    </item>
    <item>
      <title>Re: Query with an additional condition</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666208#M228545</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/228576"&gt;@ivan123357&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I'd try something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=custom (evt_id=1 OR evt_id=2) earliest=-5m latest=-7m
|  stats
   last(evt_id) AS evt_id
   earliest(_time) AS earliest
   latest(_time) AS latest
   BY user_id
| where evt_id=1 OR (latest-earliest&amp;gt;300)&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 17:10:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-with-an-additional-condition/m-p/666208#M228545</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-10-25T17:10:17Z</dc:date>
    </item>
  </channel>
</rss>

