<?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 determine if event is in list of outages? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618193#M214849</link>
    <description>&lt;P&gt;Time based lookup may work. Few questions:&lt;/P&gt;&lt;P&gt;Can outages overlap, e.g. multiple outages.&lt;/P&gt;&lt;P&gt;Can we put a constraint around the max length of outages, e.g. all outages are resolved in x time?&lt;/P&gt;</description>
    <pubDate>Mon, 24 Oct 2022 23:57:33 GMT</pubDate>
    <dc:creator>johnhuang</dc:creator>
    <dc:date>2022-10-24T23:57:33Z</dc:date>
    <item>
      <title>How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618191#M214848</link>
      <description>&lt;P&gt;I have a seemingly simple request: &lt;STRONG&gt;list the events and indicate if it occurred during an outage.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;I have been trying for ages and I cannot get it to work, can anyone please help?&lt;/P&gt;
&lt;P&gt;Base search for events:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;index=api_calls&lt;/PRE&gt;
&lt;P&gt;CSV lookup to record the outage windows, called 'outages.csv' (UK style dates):&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;DateFrom&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;DateTo&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Reason&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;01/09/2022 09:00:00&amp;nbsp;&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;30/09/2022 23:00:00&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Testing 1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="33.333333333333336%"&gt;01/10/2022 09:00:00&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;31/10/2022 09:00:00&lt;/TD&gt;
&lt;TD width="33.333333333333336%"&gt;Testing 2&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This produces the correct outage row:&lt;/P&gt;
&lt;PRE&gt;| inputlookup outages.csv &lt;BR /&gt;| eval t=now()&lt;BR /&gt;| eval DateFromEpoch=strptime(DateFrom, "%d/%m/%Y %H:%M:%S") &lt;BR /&gt;| eval DateToEpoch=strptime(DateTo, "%d/%m/%Y %H:%M:%S")&lt;BR /&gt;| where DateFromEpoch &amp;lt;= t and DateToEpoch &amp;gt;= t&lt;BR /&gt;| table Reason&lt;/PRE&gt;
&lt;P&gt;Output is: Testing 2&lt;/P&gt;
&lt;P&gt;I would have expected this to add the Reason field to the base results:&lt;/P&gt;
&lt;PRE&gt;index=api_calls&lt;BR /&gt;| append &lt;BR /&gt;  [ inputlookup outages.csv &lt;BR /&gt;  | eval t=_time&lt;BR /&gt;  | eval DateFromEpoch=strptime(DateFrom, "%d/%m/%Y %H:%M:%S") &lt;BR /&gt;  | eval DateToEpoch=strptime(DateTo, "%d/%m/%Y %H:%M:%S")&lt;BR /&gt;  | where DateFromEpoch &amp;lt;= t and DateToEpoch &amp;gt;= t&lt;BR /&gt;  | table Reason ] &lt;BR /&gt;| table _time Reason *&lt;/PRE&gt;
&lt;P&gt;But for some reason I cannot get anything to add to the search, not even&lt;/P&gt;
&lt;PRE&gt;index=api_calls&lt;BR /&gt;| append [ | makeresults&lt;BR /&gt;&amp;nbsp; | eval Reason="hello" | table Reason&amp;nbsp;]&lt;BR /&gt;| table _time Reason *&lt;/PRE&gt;
&lt;P&gt;Ideally, I would like this to be as a macro so I can re-use it easily:&lt;/P&gt;
&lt;PRE&gt;index=api_calls&lt;BR /&gt;| `is_outage(_time)`&lt;BR /&gt;| table _time Reason *&lt;/PRE&gt;
&lt;P&gt;I'm doing something wrong, any help appreciated.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 23:55:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618191#M214848</guid>
      <dc:creator>apps_inpaytech</dc:creator>
      <dc:date>2022-10-24T23:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618193#M214849</link>
      <description>&lt;P&gt;Time based lookup may work. Few questions:&lt;/P&gt;&lt;P&gt;Can outages overlap, e.g. multiple outages.&lt;/P&gt;&lt;P&gt;Can we put a constraint around the max length of outages, e.g. all outages are resolved in x time?&lt;/P&gt;</description>
      <pubDate>Mon, 24 Oct 2022 23:57:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618193#M214849</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-24T23:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618194#M214850</link>
      <description>&lt;P&gt;It would help to see a sample expected output, but it looks like you've omitted a key step.&lt;/P&gt;&lt;P&gt;The &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; command runs a search and puts the results after the result obtained up to that point.&amp;nbsp; Think of the results as rows in a spreadsheet - &lt;FONT face="courier new,courier"&gt;append&lt;/FONT&gt; adds rows on the bottom.&amp;nbsp; So the example queries may produce many rows of events from the api_calls index followed by a single row with "Reason 2" at the bottom.&lt;/P&gt;&lt;P&gt;The trick is to get the Reason value at the bottom distributed to all of the rows above.&amp;nbsp; Here's one way.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=api_calls
| append 
  [ inputlookup outages.csv 
  | eval t=_time
  | eval DateFromEpoch=strptime(DateFrom, "%d/%m/%Y %H:%M:%S") 
  | eval DateToEpoch=strptime(DateTo, "%d/%m/%Y %H:%M:%S")
  | where DateFromEpoch &amp;lt;= t and DateToEpoch &amp;gt;= t
  | eval deleteme=1
  | table Reason ] 
```Put the outage at the top```
| reverse
```Spread the reason to the other events```
| filldown Reason
```Restore the original order```
| reverse
```Remove the outage event```
| where NOT deleteme=1
| table _time Reason *&lt;/LI-CODE&gt;&lt;P&gt;See my BSides 22 talk on append and appendcols (&lt;A href="https://www.youtube.com/watch?v=m8YLT8eM1k4" target="_blank"&gt;https://www.youtube.com/watch?v=m8YLT8eM1k4&lt;/A&gt;) for more information.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 00:12:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618194#M214850</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2022-10-25T00:12:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618195#M214851</link>
      <description>&lt;P&gt;I can ensure outages do not overlap if it's easier.&lt;/P&gt;&lt;P&gt;Max length would be unknown, could be for days or minutes.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 00:45:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618195#M214851</guid>
      <dc:creator>apps_inpaytech</dc:creator>
      <dc:date>2022-10-25T00:45:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618196#M214852</link>
      <description>&lt;P&gt;The expected output would be something like:&lt;/P&gt;&lt;TABLE border="1" width="100%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="20%"&gt;Date&lt;/TD&gt;&lt;TD width="20%"&gt;Outage Reason&lt;/TD&gt;&lt;TD width="20%"&gt;Client&lt;/TD&gt;&lt;TD width="20%"&gt;Duration(ms)&lt;/TD&gt;&lt;TD width="20%"&gt;Parameters&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;20/08/2022&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;Company A&lt;/TD&gt;&lt;TD width="20%"&gt;100&lt;/TD&gt;&lt;TD width="20%"&gt;blah&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;20/09/2022&lt;/TD&gt;&lt;TD width="20%"&gt;Testing 1&lt;/TD&gt;&lt;TD width="20%"&gt;Company A&lt;/TD&gt;&lt;TD width="20%"&gt;60000&lt;/TD&gt;&lt;TD width="20%"&gt;fred&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;20/10/2022&lt;/TD&gt;&lt;TD width="20%"&gt;Testing 2&lt;/TD&gt;&lt;TD width="20%"&gt;Company B&lt;/TD&gt;&lt;TD width="20%"&gt;60000&lt;/TD&gt;&lt;TD width="20%"&gt;foo&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="20%"&gt;20/11/2022&lt;/TD&gt;&lt;TD width="20%"&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD width="20%"&gt;Company A&lt;/TD&gt;&lt;TD width="20%"&gt;150&lt;/TD&gt;&lt;TD width="20%"&gt;goldfish&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With Date, Client, Duration, Parameters coming from index api_calls&lt;/P&gt;&lt;P&gt;With this data I can filter and produce the reports the business needs.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 00:51:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618196#M214852</guid>
      <dc:creator>apps_inpaytech</dc:creator>
      <dc:date>2022-10-25T00:51:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618197#M214853</link>
      <description>&lt;P&gt;This is how you could configure a time based lookup which should be magnitudes faster than using append.&lt;/P&gt;&lt;P&gt;1. Create outages_time_lookup.csv from your original lookup:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| inputlookup outages.csv
| eval DateFromEpoch=strptime(DateFrom, "%d/%m/%Y %H:%M:%S")
| eval DateToEpoch=strptime(DateTo, "%d/%m/%Y %H:%M:%S")
| eval lookup_value=1
| table lookup_value DateFromEpoch DateToEpoch Reason
| outputlookup outages_time_lookup.csv&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;Configure a new lookup definition (use default value for anything not defined below):&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Name: outages_time_lookup&lt;BR /&gt;Lookup file: outages_time_lookup.csv&lt;BR /&gt;Name of time field: DateFromEpoch&lt;BR /&gt;Minimum offset: 0&lt;BR /&gt;Advanced Options -&amp;gt; Maximum matches: 1&lt;/P&gt;&lt;P&gt;3. Sample query using the time based lookup&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=api_calls
| eval lookup_value=1
| lookup outages_time_lookup lookup_value OUTPUT DateToEpoch Reason
| eval is_outage=IF(_time&amp;lt;DateToEpoch, "Y", "N")
| eval outage_reason=IF(_time&amp;lt;DateToEpoch, Reason, "")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 00:53:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618197#M214853</guid>
      <dc:creator>johnhuang</dc:creator>
      <dc:date>2022-10-25T00:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine if event is in list of outages?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618198#M214854</link>
      <description>&lt;P&gt;Genius!!&lt;/P&gt;&lt;P&gt;Thankyou, that worked a treat&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face:"&gt;😀&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Oct 2022 02:46:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-determine-if-event-is-in-list-of-outages/m-p/618198#M214854</guid>
      <dc:creator>apps_inpaytech</dc:creator>
      <dc:date>2022-10-25T02:46:16Z</dc:date>
    </item>
  </channel>
</rss>

