Splunk Enterprise

How can I compare the last week vs 3 hours of data?

uagraw01
Motivator

Hello Splunkers!!

Can you help me understand that how can I compare the last week vs 3 hours of data in Splunk. 
Previously I have compared the current week and previous week of data by using the timewrap command but last week vs 3 hours in creating confusion for me. Please provide me the solution and suggestion.

Below screenshot belongs to Newrelic.

Capturenewrelic.PNG

Tags (1)
0 Karma
1 Solution

ITWhisperer
SplunkTrust
SplunkTrust
index=your_index ((earliest=@m-3h latest=@m) OR (earliest=@m-3w-3h latest=@m-3w))
| eval time=date_hour.":".date_minute
| chart count by time date_mday

View solution in original post

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
index=your_index ((earliest=@m-3h latest=@m) OR (earliest=@m-3w-3h latest=@m-3w))
| eval time=date_hour.":".date_minute
| chart count by time date_mday
0 Karma

uagraw01
Motivator

@ITWhisperer  I am confusing with this timeframe " 

((earliest=@m-3h latest=@m) OR (earliest=@m-1w-3h latest=@m-3w)) "

Can you please help me explain this ? 

And other than this can we use the time wrap command approach ?

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Your initial search (the line that starts with index=) will normally be over a timeframe defined by the earliest and latest options either in the dashboard or timepicker if in search app.

This can be overridden by defining earliest and latest values as part of the search.

What this part is doing is overriding the timeframe with two timeframe so events will be kept if they fall into either timeframe.

This has the advantage over using the append approach that you used because append is using a subsearch and is therefore limited to the number of events it can process.

0 Karma

uagraw01
Motivator

@ITWhisperer Can we use " (earliest=@m-1w-3h latest=@m-1w)) in place of below you have suggested

(earliest=@m-3w-3h latest=@m-3w))

 

I have chnaged 3W to 1W

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Yes, that should work (assuming your index retains data for that period)

uagraw01
Motivator

@ITWhisperer Let me explore as suggested. I will let you know if any issue.

 

Thanks for your great help!!

0 Karma

uagraw01
Motivator

@ITWhisperer Thanks for your reply on this. But that is not giving me the correct result.

Can we use this SPL ?

<my search> earliest=-7d@d latest=now
| multikv | eval ReportKey1="1 week before"
| append
[search <my search> earliest=-3h@h latest=now
| multikv | eval ReportKey2="3 hours"]
| timechart count(ReportKey1) count(ReportKey2) span=30m

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

Not really - with your search, your x-axis will be the time in epoch format i.e. full date and time, so your two lines will not overlap as you would like.

0 Karma

uagraw01
Motivator

@ITWhisperer 

You search giving this kind of visualization. Can you please to make more corrective on this.

IMG_20220526_142410__01.jpg

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

What would you like to change about it?

0 Karma

uagraw01
Motivator

@ITWhisperer Like the span in the x-axis would be like 30 mins if we the graph of the NewRelic which i have attached in my first screenshot.

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

The graphic you shared doesn't use a span of 30 minutes as there are multiple points within each 30 minute period across your 3 hour graph.

Do you want a point for each 30 minute period (span=30m) or a point for each minute?

0 Karma

uagraw01
Motivator

@ITWhisperer  I have used your suggested query. But here you can see the yellow highlighted one which is showing 26 day of data as well as 5 day of the data. Here I want last 7 days of the data with comparison of last 3 hours of data. I think we need to modify some changes here "(earliest=@m-3w-3h latest=@m-3w)". Please help me to fix this.

 

uagraw01_0-1653571137808.png

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

26 is 26th of the month - 5 is the 5th of the month - these are 3 weeks apart.

I am not sure what you are trying to compare - do you want the last 3 hours and the same time of day for a day 3 weeks ago or something else?

0 Karma

uagraw01
Motivator

@ITWhisperer  I want the last 3 hours and the same time for a day 1 week ago.

 

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust
((earliest=@m-3h latest=@m) OR (earliest=@m-1w-3h latest=@m-1w))
0 Karma

uagraw01
Motivator

@ITWhisperer Here I just want to compare a trend for last three hours with complete 1 week ago. 

 

Que : do you want the last 3 hours and the same time of day for a day 3 weeks ago  :?

Ans : No

0 Karma

ITWhisperer
SplunkTrust
SplunkTrust

So what do you expect to be measured by the x-axis?

0 Karma
Get Updates on the Splunk Community!

Splunk at Cisco Live 2025: Learning, Innovation, and a Little Bit of Mr. Brightside

Pack your bags (and maybe your dancing shoes)—Cisco Live is heading to San Diego, June 8–12, 2025, and Splunk ...

Splunk App Dev Community Updates – What’s New and What’s Next

Welcome to your go-to roundup of everything happening in the Splunk App Dev Community! Whether you're building ...

The Latest Cisco Integrations With Splunk Platform!

Join us for an exciting tech talk where we’ll explore the latest integrations in Cisco &#43; Splunk! We’ve ...