Reputation: 7683
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
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:
Sidekiq::Stats.new.reset('failed')
Sidekiq::Stats.new.reset('failed', 'processed')
(Thanks https://stackoverflow.com/users/2475008/tmr08c for update)
Upvotes: 130
Reputation: 51
Sidekiq::RetrySet.new.clear
Sidekiq::ScheduledSet.new.clear
Sidekiq::Stats.new.reset
Sidekiq::DeadSet.new.clear
Font: https://gist.github.com/wbotelhos/fb865fba2b4f3518c8e533c7487d5354
Upvotes: 5
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
Reputation: 836
This will also reset the history and delete everything from the Redis queue completely
Sidekiq.redis {|c| c.flushdb }
Upvotes: -6
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
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
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