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!

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 ...

Splunk Decoded: Business Transactions vs Business IQ

It’s the morning of Black Friday, and your e-commerce site is handling 10x normal traffic. Orders are flowing, ...

Fastest way to demo Observability

I’ve been having a lot of fun learning about Kubernetes and Observability. I set myself an interesting ...