<?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: Need Help with a Splunk query in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687203#M234386</link>
    <description>&lt;P&gt;I tried something like this&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=abc ("Aggregator * is Error" OR "Aggregator * is Up") NJ12GC102
| rex field=_raw "Aggregator\s(?&amp;lt;aggregator&amp;gt;[^\s]+)\sis\s(?&amp;lt;aggregator_status&amp;gt;\w+)\s"
| streamstats current=t global=f window=2 range(_time) as time_diff by aggregator,aggregator_status
| streamstats current=t global=f window=2 range(_time) as time_diff2 by aggregator
| table _time aggregator aggregator_status time_diff time_diff2
|&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;But the output is now what I needed. For that I would need to change the window=2, but it brings more issues.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="phularah_1-1715358409563.png" style="width: 555px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30773i545C40D23ABB2964/image-dimensions/555x287?v=v2" width="555" height="287" role="button" title="phularah_1-1715358409563.png" alt="phularah_1-1715358409563.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 10 May 2024 20:28:10 GMT</pubDate>
    <dc:creator>phularah</dc:creator>
    <dc:date>2024-05-10T20:28:10Z</dc:date>
    <item>
      <title>Need Help with a Splunk query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687194#M234382</link>
      <description>&lt;P&gt;So, I have data like this after I ran a query.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="phularah_1-1715356433010.png" style="width: 628px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30771i9C5F33183DD9D6A8/image-dimensions/628x157?v=v2" width="628" height="157" role="button" title="phularah_1-1715356433010.png" alt="phularah_1-1715356433010.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;For each aggregator, if the aggregator_status is &lt;STRONG&gt;Error&lt;/STRONG&gt; and before15 minutes, the aggregator_status becomes Up, alert should not run. But, if the aggregator_status is still &lt;STRONG&gt;Error&lt;/STRONG&gt; or no new event comes, alert should trigger. The &lt;STRONG&gt;Time&lt;/STRONG&gt; field is epoch time which I am thinking can be used to find difference in Up and Error status times.&lt;BR /&gt;&lt;BR /&gt;How do I create such a query for the alert? I am thinking of using foreach command or some sort of streamstats, but I am unable to resolve this issue. The alert needs to run once every 24 hours.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 15:59:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687194#M234382</guid>
      <dc:creator>phularah</dc:creator>
      <dc:date>2024-05-10T15:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with a Splunk query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687203#M234386</link>
      <description>&lt;P&gt;I tried something like this&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=abc ("Aggregator * is Error" OR "Aggregator * is Up") NJ12GC102
| rex field=_raw "Aggregator\s(?&amp;lt;aggregator&amp;gt;[^\s]+)\sis\s(?&amp;lt;aggregator_status&amp;gt;\w+)\s"
| streamstats current=t global=f window=2 range(_time) as time_diff by aggregator,aggregator_status
| streamstats current=t global=f window=2 range(_time) as time_diff2 by aggregator
| table _time aggregator aggregator_status time_diff time_diff2
|&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;But the output is now what I needed. For that I would need to change the window=2, but it brings more issues.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="phularah_1-1715358409563.png" style="width: 555px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/30773i545C40D23ABB2964/image-dimensions/555x287?v=v2" width="555" height="287" role="button" title="phularah_1-1715358409563.png" alt="phularah_1-1715358409563.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 20:28:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687203#M234386</guid>
      <dc:creator>phularah</dc:creator>
      <dc:date>2024-05-10T20:28:10Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with a Splunk query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687222#M234395</link>
      <description>&lt;P&gt;It might be doable with the transaction command but it's usually not a good idea (transaction is a relatively "heavy" command and has its limitations).&lt;/P&gt;&lt;P&gt;I'd go with streamstats and reset_before, reset_after and time_window options. (can't give you a ready-made answer at the moment since I'm away from my Splunk environment but that's the way I'd try)&lt;/P&gt;</description>
      <pubDate>Fri, 10 May 2024 19:52:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687222#M234395</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2024-05-10T19:52:16Z</dc:date>
    </item>
    <item>
      <title>Re: Need Help with a Splunk query</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687241#M234406</link>
      <description>&lt;P&gt;Try starting with something like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| streamstats values(aggregator_status) as previous_aggregator_status by aggregator window=1 current=f global=f
| eval changetime=if((aggregator_status="Up" and previous_aggregator_status="Error") or (aggregator_status="Error" and previous_aggregator_status="Up"),_time,null())
| where isnotnull(changetime)
| streamstats current=t global=f window=2 range(_time) as time_diff2 by aggregator
| where aggregator_status="Error"&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 11 May 2024 08:52:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-Help-with-a-Splunk-query/m-p/687241#M234406</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2024-05-11T08:52:43Z</dc:date>
    </item>
  </channel>
</rss>

