Splunk Search

How to automate a search to compare the past 24hrs in test with the last 30 days in production?

natefly5
Explorer

    earliest=-30d@d latest=@m sourcetype=Apps  (sub_source!="'A'" AND sub_source!="'B'")
    AND 
    (((Hosted="TEST") AND (err_time > "'04/22/2015 01:00:00'"))
    OR 
    ((Hosted="PROD") AND (err_time < "'04/22/2015 01:00:00'")))

 
I need to find a way to automate this search so it will show the past 24hr from TEST with the past 30 days of PROD without having to manually change the date every time I want to run it. Any help would be greatly appreciated! Thanks 
Tags (2)
0 Karma
1 Solution

stephane_cyrill
Builder

Hi try something like this:

|multisearch [search earliest =- 24h
sourcetype= Apps (sub_source != "'A'"
AND sub_source != "'B'" )
AND
((( Hosted= "TEST" ) AND (err_time >
"'04/22/2015 01:00:00'" )) ]
[search earliest =- 30 d@d latest = @m
sourcetype= Apps (sub_source != "'A'"
AND sub_source != "'B'" )
AND
( (( Hosted ="PROD" ) AND (err_time <
"'04/22/2015 01:00:00'" ))) ] |continue_here

At the place of continue_here you can do what you want,an eval,table,chart............

View solution in original post

stephane_cyrill
Builder

Hi try something like this:

|multisearch [search earliest =- 24h
sourcetype= Apps (sub_source != "'A'"
AND sub_source != "'B'" )
AND
((( Hosted= "TEST" ) AND (err_time >
"'04/22/2015 01:00:00'" )) ]
[search earliest =- 30 d@d latest = @m
sourcetype= Apps (sub_source != "'A'"
AND sub_source != "'B'" )
AND
( (( Hosted ="PROD" ) AND (err_time <
"'04/22/2015 01:00:00'" ))) ] |continue_here

At the place of continue_here you can do what you want,an eval,table,chart............

natefly5
Explorer

Thank you!

0 Karma

juvetm
Communicator

pl can i have all the sample of you code pl

0 Karma
Get Updates on the Splunk Community!

Index This | When is October more than just the tenth month?

October 2025 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Observe and Secure All Apps with Splunk

  Join Us for Our Next Tech Talk: Observe and Secure All Apps with SplunkAs organizations continue to innovate ...

What’s New & Next in Splunk SOAR

 Security teams today are dealing with more alerts, more tools, and more pressure than ever.  Join us for an ...