Dashboards & Visualizations

How to timechart by multiple time spans in a dashboard?

alchang
Explorer

I want two charts in a dashboard - the count of an event by week and by day. Currently I have two scheduled searches:
Daily: | timechart span=1d count
Weekly: | timechart span=1w count

Is there a way that I can use the output of the daily search to do the aggregation? Something like
|loadjob savedsearch="Daily Query"

Tags (3)
1 Solution

musskopf
Builder

Yes, you could... give a try creating your saved search, something like this:

index="bla" "your search" | bucket bin=1d _time | stats count by _time

Your saved search will endup with a stats by day. After that you could use the loadjob from that scheduled search use the timechart, like you mentioned:

| loadjob savedsearch="Daily Query" | timechart span=1w sum(count) as count

Just pay attention as you're already aggredating data in your first stats, the timechart function would be sum() for this example. The same would work if you use span=1d... and you still can keep the sum() as being the aggregating function.

Hope it helps...
Cheers,

View solution in original post

ppablo
Retired

Hi @alchang

Just following up with this post, but did @musskopf's answer and comment below fully answer your question? If yes, don't forget to resolve this post by clicking "Accept" directly below the answer. Thanks!

0 Karma

musskopf
Builder

Yes, you could... give a try creating your saved search, something like this:

index="bla" "your search" | bucket bin=1d _time | stats count by _time

Your saved search will endup with a stats by day. After that you could use the loadjob from that scheduled search use the timechart, like you mentioned:

| loadjob savedsearch="Daily Query" | timechart span=1w sum(count) as count

Just pay attention as you're already aggredating data in your first stats, the timechart function would be sum() for this example. The same would work if you use span=1d... and you still can keep the sum() as being the aggregating function.

Hope it helps...
Cheers,

alchang
Explorer

Thanks! A related feature I'd like to add is let's suppose that I have daily for the past 30 days, but I want to just add up the weekly for the past two weeks. I tried

| loadjob savedsearch="Daily Query" | timechart span=1w sum(count) as count | where _time>"2015-02-17" and that didn't do anything.

0 Karma

musskopf
Builder

Don't have any Splunk instance in front of me to test, but the "_time" is actually in seconds, Splunk only has a macro that converts to a readable format if the field name is "_time", so it should looks more like:

| loadjob savedsearch="Daily Query" | where _time>(strptime("2015-02-17", "%F")) | timechart span=1w sum(count) as count

The strptime converts a humam format to timestamp (epoch). Have a look here to see the formats it accepts: http://docs.splunk.com/Documentation/Splunk/6.2.2/SearchReference/Commontimeformatvariables

Get Updates on the Splunk Community!

Observability | Use Synthetic Monitoring for Website Metadata Verification

If you are on Splunk Observability Cloud, you may already have Synthetic Monitoringin your observability ...

More Ways To Control Your Costs With Archived Metrics | Register for Tech Talk

Tuesday, May 14, 2024  |  11AM PT / 2PM ET Register to Attend Join us for this Tech Talk and learn how to ...

.conf24 | Personalize your .conf experience with Learning Paths!

Personalize your .conf24 Experience Learning paths allow you to level up your skill sets and dive deeper ...