How do I reset my sidekiq counters?
Solution 1
To reset processed jobs:
Sidekiq.redis {|c| c.del('stat:processed') }
and to reset failed jobs:
Sidekiq.redis {|c| c.del('stat:failed') }
Solution 2
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)
Solution 3
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.
Solution 4
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
Solution 5
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
AgostinoX
The quality of the examples is very important. A collection of good examples can replace an incomplete documentation. But each example should be short, only in this way it will be eloquent. The reader is making an effort to understand a concept. Not to debug a procedure!
Updated on July 08, 2022Comments
-
AgostinoX almost 2 years
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?