Deployment Architecture

Scale Bucket size for time series data

bondu
Explorer

I am trying to generate a chart where the x-axis scales over time. So the columns would be:
1 hour, 1 day, 1 week, 1 month, 3 months, 6 months, 1 year

Do I need to create each bucket individually, or can I do it with some sort of log scale? The columns don't need to be exactly the date ranges above.

0 Karma
1 Solution

martin_mueller
SplunkTrust
SplunkTrust

Assuming you want to look back from the end of the time range into the past, here's an idea:

  index=_internal | addinfo | eval diff = info_max_time - _time
| eval bucket = case(diff < 60, "1m", diff < 3600, "1h", diff < 86400, "1d") | chart count by bucket

I'm grabbing the end of the time range to calculate how "old" an event is, then I'm shoving the events into custom buckets and charting by that.

View solution in original post

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Assuming you want to look back from the end of the time range into the past, here's an idea:

  index=_internal | addinfo | eval diff = info_max_time - _time
| eval bucket = case(diff < 60, "1m", diff < 3600, "1h", diff < 86400, "1d") | chart count by bucket

I'm grabbing the end of the time range to calculate how "old" an event is, then I'm shoving the events into custom buckets and charting by that.

0 Karma

martin_mueller
SplunkTrust
SplunkTrust

Great... I'll mark this as solved?

0 Karma

bondu
Explorer

I was able to use this example with a few changes:

index=_internal | addinfo | eval diff = info_max_time - _time | eval bucket = case(diff <= 86400, "1 day", 86400 < diff AND diff <= 172800, "2 days", 172800 < diff AND diff <= 604800, "1 week", 604800 < diff AND diff <= 1209600, "2 weeks", 1209600 < diff AND diff <= 2628000, "1 month") | chart count by bucket
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

You can also (if you want) try something like:

... | addinfo | eval diff= info_max_time - _time | bucket span=1log10 diff | chart count by diff

You can experiment with different values for the span, e.g., 1log2 or 1.2log10. This will give you time differences in seconds. The number of seconds might be awkward to work with though, so the method above with case() would be better in that case.

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...