Splunk Search

"shifting" search buckets

Jebnor
Engager

I'm trying to search through my logs and extract sum(x) for a time of 7am to 7am. If I search for exactly one 24h period, from 7am-7am (-1d@d+7h,@d+7h), I get the expected answer. However, if I set the timeframe to 48h, (-2d@d+7h,@d+7h), I get the wrong answer.

Example: (-1d@d+7h,@d+7h) custom time frame

index=foo other-stuff-here | chart sum(saveSize) as TotalSize(KB)

I get the expected result of 123456KB

This works for 48h sum: (-2d@d+7h,@d+7h) custom time frame

index=foo other-stuff-here | chart sum(saveSize) as TotalSize(KB)

However, I want a chart of 2 - 24h periods in the specified 48h. I tried a couple things which failed.

  1. Gives me one sum for all 48h and doesn't 'split' by bins:
    index=foo other-stuff-here | bucket _time bins=2 | chart sum(saveSize) as TotalSize(KB) by _time
  2. Gives me 3 buckets, one for each 'day' the 48h spans.
    index=foo other-stuff-here | bucket _time span=24h | chart sum(saveSize) as TotalSize(KB) by _time

Any thoughts?

Tags (3)

Jebnor
Engager

I do believe I found the answer.


index=foo other-stuff-here | eval _time=(_time - 25200) | timechart sum(saveSize) as TotalSize(KB)

With my date set 7-7, this 'shifts' everything from midnight to 7am to the previous day by substracting 7h worth of seconds. There is an odd edge case on things at 7am; I don't know if splunk considers midnight yesterday or today, that is 2400h (yesterday) or 0000h (today).

Just need to be aware that is screws up interactive searches in the chart, so It should only be used for statistical purposes.

Get Updates on the Splunk Community!

SOC4Kafka - New Kafka Connector Powered by OpenTelemetry

The new SOC4Kafka connector, built on OpenTelemetry, enables the collection of Kafka messages and forwards ...

Your Voice Matters! Help Us Shape the New Splunk Lantern Experience

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Building Momentum: Splunk Developer Program at .conf25

At Splunk, developers are at the heart of innovation. That’s why this year at .conf25, we officially launched ...