Skip to content


Subversion checkout URL

You can clone with
Download ZIP


[DOC] How to count events in last (n) minutes? #4

inactivist opened this Issue · 3 comments

2 participants


For example, I'd like to calculate the sum of events over the last five minutes.

I'm using Timeseries in 'count_only' mode because I never care about discrete event data.


KEY_PREFIX = 'timedata:things'

client = redis.Redis('localhost', 6379)
minute_count = Timeseries(client, {
            'step':60,              # 60 seconds
            'steps':15,             # last 15 minutes
            'count_only' : True,    # store counts only.
    }, key_prefix=KEY_PREFIX)

def hit(event_id):
    minute_count.insert(event_id, 1)

When events arrive, I call:


Now, I'd like to know the sum of all events recorded in the last 5 minutes (not just the event count in each bucket.)

I think I should be able to sum the items by calling minute_count.series('some-event', 'minute', steps=5, condensed=True) -- is that correct? (I've tried that but I'm having no luck. See issue #3.)

What's the best/recommended way to do this?


What you're describing is how I expect it to be used. I'll look into this.


It looks like commit d463f93 fixes this one too. I'll report back ASAP.

@inactivist inactivist closed this

Thanks for checking on that. The beta-refactor significantly cleans up the implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.