AgostinoX
AgostinoX

Reputation: 7683

How do I reset my sidekiq counters?

In my sidekiq dashboard, I see on the left a box with the counters

Processed 168
Failed 111
Busy 0
Scheduled 0
Retries 0
Enqueued 0

How do I reset them all to 0?

Upvotes: 64

Views: 25466

Answers (7)

Paul Keen
Paul Keen

Reputation: 1420

To reset statistics:

Sidekiq::Stats.new.reset

ref: Add reset stats to Web UI summary box and method to API

Also, you can now clear specific stats:

  • single stat by Sidekiq::Stats.new.reset('failed')
  • or multiple stats by Sidekiq::Stats.new.reset('failed', 'processed')

(Thanks https://stackoverflow.com/users/2475008/tmr08c for update)

Upvotes: 130

Victor Hugo
Victor Hugo

Reputation: 51

1. Clear retry set

Sidekiq::RetrySet.new.clear

2. Clear scheduled jobs

Sidekiq::ScheduledSet.new.clear

3. Clear 'Processed' and 'Failed' jobs

Sidekiq::Stats.new.reset

3. Clear 'Dead' jobs statistics

Sidekiq::DeadSet.new.clear

Font: https://gist.github.com/wbotelhos/fb865fba2b4f3518c8e533c7487d5354

Upvotes: 5

Paulo Victor
Paulo Victor

Reputation: 4122

Just to complement all good answers, reset counters using ruby interactive mode, doing this into console:

irb
irb(main):001:0> require 'sidekiq/api'
=> true
irb(main):002:0> Sidekiq.redis {|c| c.del('stat:processed') }
=> 1
irb(main):003:0> Sidekiq.redis {|c| c.del('stat:failed') }
=> 1

Upvotes: 7

user1320651
user1320651

Reputation: 836

This will also reset the history and delete everything from the Redis queue completely

Sidekiq.redis {|c| c.flushdb }

Upvotes: -6

Milovan Zogovic
Milovan Zogovic

Reputation: 1580

In case you want to delete the whole thing along with the history panel for specific dates, here is the helpful snippet:

from_date = Date.new(2016, 1, 1)
to_date = Date.today

Sidekiq.redis do |redis|
  redis.del("stat:processed")
  redis.del("stat:failed")

  (from_date..to_date).each do |date|
    redis.del("stat:processed:#{date}")
    redis.del("stat:failed:#{date}")
  end
end

Upvotes: 1

Mikel Lindsaar
Mikel Lindsaar

Reputation: 251

Also, to reset specific days in the history panel, you can do:

Sidekiq.redis {|c| c.del('stat:processed:2015-07-02') }
Sidekiq.redis {|c| c.del('stat:failed:2015-07-02') }

And repeat for each day you want to clear.

This is useful if you had a wild job spawning and failing many times more than your usual and you get a history graph with a massive spike in it that makes all your usual history values effectively a flat line.

Upvotes: 12

Roberto Barros
Roberto Barros

Reputation: 1500

To reset processed jobs:

Sidekiq.redis {|c| c.del('stat:processed') }

and to reset failed jobs:

Sidekiq.redis {|c| c.del('stat:failed') }

Upvotes: 114

Related Questions