<?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: cant figure this out in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437820#M124672</link>
    <description>&lt;P&gt;@kjonesdba_lm &lt;BR /&gt;
I have converted my comment into an answer, please accept the answer if it significantly helped resolve your query for the benefit of other forum members, who might run into a similar issue.&lt;/P&gt;</description>
    <pubDate>Mon, 12 Aug 2019 14:49:18 GMT</pubDate>
    <dc:creator>Sukisen1981</dc:creator>
    <dc:date>2019-08-12T14:49:18Z</dc:date>
    <item>
      <title>cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437812#M124664</link>
      <description>&lt;P&gt;I have this query below .. I need to report on the last successful backup 'over' 24 hours.. which this does... however what I cant figure out how to do is report when all backups have failed for 30 days.  (no successful backups ever). _time is the time the backup ran and the log information written to splunk.  &lt;/P&gt;

&lt;P&gt;For instance if I remove the 'where' statement on the query it brings back 2 rows (1 success, 1 failed) on those backups that had both.  it will bring 1 row back where there has been no successful backup (all failed)&lt;/P&gt;

&lt;P&gt;I cannot figure out how to code the where to handle both conditions&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="storage" sourcetype="rubrik:prod"  ndc="MSSQL_DB*"  status=Failure OR status=Success
| rex field=_raw "from [\'](?[^\']\w+-\w+)"
| rex field=_raw "backup for (?\w+-\w+)\."
| rex field=_raw "eventSeriesId=(?.*?)\ objectId="
| rex field=_raw "objectName=(?.*?)\ eventId"
| rex field=_raw "Microsoft SQL Server Database \'(?.+)\' from"
| search SERVER_NAME="VMPIT-G4FDB003"
| search DATABASE_NAME="FBI"
| search NOT [ | inputlookup Servers_Pending_Deletion.csv | fields SERVER_NAME ] 
| table SERVER_NAME _time _raw status DATABASE_NAME| stats max(_time) as TopTime  by SERVER_NAME, DATABASE_NAME,status | sort by  SERVER_NAME,DATABASE_NAME,  _time desc 
| where ((TopTime &amp;lt;= relative_time(now(),"-24h") and TopTime &amp;gt; relative_time(now(),"-30d") and status="Success" ))
| eval lm_24_ago=strftime(relative_time(now()-14400,"-24h"),"%m-%d-%y %H:%M:%S")
| eval lm_report_date=strftime(now()-14400,"%m-%d-%y %H:%M:%S")
| eval lm_7d_ago=strftime(relative_time(now()-14400,"-7d"),"%m-%d-%y %H:%M:%S")
| eval lm_last_backup=strftime(TopTime-14400, "%m-%d-%y %H:%M:%S") | sort by lm_last_backup desc
| eval lm_ci=SERVER_NAME
| eval lm_database=DATABASE_NAME
| eval lm_status=status
| eval lm_rows=rct
| table lm*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Aug 2019 20:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437812#M124664</guid>
      <dc:creator>kjonesdba_lm</dc:creator>
      <dc:date>2019-08-09T20:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437813#M124665</link>
      <description>&lt;P&gt;&lt;EM&gt;"report when all backups have failed for 30 days"&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Isn't below condition returns the result you expect? &lt;/P&gt;

&lt;P&gt;If below condition didn't return any events,  I believe it meant all backups failed for last 30 days, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | where ((TopTime &amp;lt;= relative_time(now(),"-24h") and TopTime &amp;gt; relative_time(now(),"-30d") and status="Success" ))
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Aug 2019 12:50:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437813#M124665</guid>
      <dc:creator>jawaharas</dc:creator>
      <dc:date>2019-08-11T12:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437814#M124666</link>
      <description>&lt;P&gt;how do you alert on that "if the condition didn't return any events"?  that's the issue.. we use splunk to create problem tickets.. one wont be created for no results which is what occurs if backups fail on a database for 30days straight.&lt;BR /&gt;&lt;BR /&gt;
I am stumped&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2019 14:56:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437814#M124666</guid>
      <dc:creator>kjonesdba_lm</dc:creator>
      <dc:date>2019-08-11T14:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437815#M124667</link>
      <description>&lt;P&gt;something like this...?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="storage" sourcetype="rubrik:prod" ndc="MSSQL_DB*" status=Failure OR status=Success
| rex field=_raw "from [\'](?[^\']\w+-\w+)"
| rex field=_raw "backup for (?\w+-\w+)."
| rex field=_raw "eventSeriesId=(?.?)\ objectId="
| rex field=_raw "objectName=(?.?)\ eventId"
| rex field=_raw "Microsoft SQL Server Database \'(?.+)\' from"
| search SERVER_NAME="VMPIT-G4FDB003"
| search DATABASE_NAME="FBI"
| search NOT [ | inputlookup Servers_Pending_Deletion.csv | fields SERVER_NAME ] 
| table SERVER_NAME _time _raw status DATABASE_NAME| stats max(_time) as TopTime by SERVER_NAME, DATABASE_NAME,status | sort by SERVER_NAME,DATABASE_NAME, _time desc 
| where ((TopTime &amp;lt;= relative_time(now(),"-24h") and TopTime &amp;gt; relative_time(now(),"-30d") and status="Success" ))
| eval lm_24_ago=strftime(relative_time(now()-14400,"-24h"),"%m-%d-%y %H:%M:%S")
| eval lm_report_date=strftime(now()-14400,"%m-%d-%y %H:%M:%S")
| eval lm_7d_ago=strftime(relative_time(now()-14400,"-7d"),"%m-%d-%y %H:%M:%S")
| eval lm_last_backup=strftime(TopTime-14400, "%m-%d-%y %H:%M:%S") | sort by lm_last_backup desc
| eval lm_ci=SERVER_NAME
| eval lm_database=DATABASE_NAME
| eval lm_status=status
| eval lm_rows=rct
| table lm*|append [search index="storage" sourcetype="rubrik:prod" ndc="MSSQL_DB*" status=Failure OR status=Success
| rex field=_raw "from [\'](?[^\']\w+-\w+)"
| rex field=_raw "backup for (?\w+-\w+)."
| rex field=_raw "eventSeriesId=(?.?)\ objectId="
| rex field=_raw "objectName=(?.?)\ eventId"
| rex field=_raw "Microsoft SQL Server Database \'(?.+)\' from"
| search SERVER_NAME="VMPIT-G4FDB003"
| search DATABASE_NAME="FBI"
| search NOT [ | inputlookup Servers_Pending_Deletion.csv | fields SERVER_NAME ] 
| table SERVER_NAME _time _raw status DATABASE_NAME| stats max(_time) as TopTime by SERVER_NAME, DATABASE_NAME,status | sort by SERVER_NAME,DATABASE_NAME, _time desc 
| where ((TopTime &amp;lt;= relative_time(now(),"-24h") and TopTime &amp;gt; relative_time(now(),"-30d") and status="Success" ))
| stats count as countx|where countx=0|eval countx="no backups"]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Aug 2019 16:24:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437815#M124667</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-11T16:24:05Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437816#M124668</link>
      <description>&lt;P&gt;The biggest problem was &lt;CODE&gt;and&lt;/CODE&gt; instead of &lt;CODE&gt;AND&lt;/CODE&gt;.  Other things were inefficient.  Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | search SERVER_NAME="VMPIT-G4FDB003" AND DATABASE_NAME="FBI" AND NOT [ | inputlookup Servers_Pending_Deletion.csv | fields SERVER_NAME ] 
| eval Time = if(_time &amp;gt;= relative_time(now(),"-24h"), mvappend(Time, "Within_24_hours"), Time)
| eval Time = if(_time &amp;gt;= relative_time(now(),"-30d"), mvappend(Time, "Within_30_days"), Time)
| eval Time = coalesce(Time, "UNKNOWN")
| stats max(_time) AS _time BY SERVER_NAME DATABASE_NAME status Time
| eval {Time} = _time
| stats values(*) AS * BY SERVER_NAME DATABASE_NAME status
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;At this point, the logic should be easy.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2019 19:13:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437816#M124668</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-11T19:13:48Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437817#M124669</link>
      <description>&lt;P&gt;P.S. Your subject line is terrible; put some real effort into it next time.  I was tempted to respond with, &lt;CODE&gt;Can't figure out your question&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 11 Aug 2019 19:15:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437817#M124669</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-11T19:15:43Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437818#M124670</link>
      <description>&lt;P&gt;Thanks will do better next time&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 13:16:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437818#M124670</guid>
      <dc:creator>kjonesdba_lm</dc:creator>
      <dc:date>2019-08-12T13:16:13Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437819#M124671</link>
      <description>&lt;P&gt;That was very helpful.  Thanks for taking some time with this.. it is doing what I want and I understand what you did.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 13:17:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437819#M124671</guid>
      <dc:creator>kjonesdba_lm</dc:creator>
      <dc:date>2019-08-12T13:17:15Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437820#M124672</link>
      <description>&lt;P&gt;@kjonesdba_lm &lt;BR /&gt;
I have converted my comment into an answer, please accept the answer if it significantly helped resolve your query for the benefit of other forum members, who might run into a similar issue.&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 14:49:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437820#M124672</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-12T14:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437821#M124673</link>
      <description>&lt;P&gt;How would I do this 'without' passing in server_name and database_name ... to do this for all nodes and servers we have.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 01:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437821#M124673</guid>
      <dc:creator>kjonesdba_lm</dc:creator>
      <dc:date>2020-09-30T01:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437822#M124674</link>
      <description>&lt;P&gt;hi @kjonesdba_lm &lt;BR /&gt;
I am a bit confused now replace specific server or db names with * in the query?&lt;BR /&gt;
That should search for ALL server and db names, also as woodcock mentioned change your syntax of and to AND&lt;BR /&gt;
PS - woodock is a very knowledgeable and valuable member of the forum, he acts tough sometimes, but trust me , he is real good inside &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2019 16:37:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437822#M124674</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2019-08-12T16:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: cant figure this out</title>
      <link>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437823#M124675</link>
      <description>&lt;P&gt;Did the answer work for you?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 14:36:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/cant-figure-this-out/m-p/437823#M124675</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-08-13T14:36:09Z</dc:date>
    </item>
  </channel>
</rss>

