如何重置我的sidekiq计数器?

时间:2022-11-30 15:35:10

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

在我的sidekiq仪表板上,我看到左边有一个带有计数器的盒子

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

How do I reset them all to 0?

如何将它们重置为0?

6 个解决方案

#1


87  

To reset processed jobs:

重置处理工作:

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

and to reset failed jobs:

重置失败的工作:

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

#2


89  

To reset statistics:

重置统计:

Sidekiq::Stats.new.reset

Sidekiq:Stats.new.reset

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

ref:将reset stats添加到Web UI摘要框中,将方法添加到API中

#3


8  

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.

这是有用的,如果你有一个疯狂的工作产生和失败的次数比你平时多很多倍,你会得到一个历史图,其中有一个巨大的尖峰使你所有的历史值实际上是一条平行线。

#4


1  

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

#5


1  

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

为了补充所有好的答案,使用ruby交互模式重置计数器,并将其放入控制台:

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

#6


-4  

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

这还将重置历史并完全从Redis队列中删除所有内容

Sidekiq.redis {|c| c.flushdb }

#1


87  

To reset processed jobs:

重置处理工作:

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

and to reset failed jobs:

重置失败的工作:

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

#2


89  

To reset statistics:

重置统计:

Sidekiq::Stats.new.reset

Sidekiq:Stats.new.reset

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

ref:将reset stats添加到Web UI摘要框中,将方法添加到API中

#3


8  

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.

这是有用的,如果你有一个疯狂的工作产生和失败的次数比你平时多很多倍,你会得到一个历史图,其中有一个巨大的尖峰使你所有的历史值实际上是一条平行线。

#4


1  

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

#5


1  

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

为了补充所有好的答案,使用ruby交互模式重置计数器,并将其放入控制台:

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

#6


-4  

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

这还将重置历史并完全从Redis队列中删除所有内容

Sidekiq.redis {|c| c.flushdb }