Find a list of failed Sidekiq missions with their arguments

I use Sidekiq to manage jobs using the Rails APP. I would like to know how you get the arguments of failed jobs (identifiers, objects, error message, etc.)? In WebUI, all you get is nr failed jobs. And if I understand correctly, the default value is to add up all the time when this task failed. I deployed my application and it works on several workers. It is difficult to go through each employee and try to find out, especially if you have sidekiq.log that is many days old.

I am looking for an answer here and on the Internet. One of the closest was described on the following links.

How to find a list of failed jobs in sidekiq?

This allows you to find out how many unsuccessful tasks I have during a certain period of time. However, I still do not know how to find out how the work ended and why.

Basically, I would like to somehow collect job_ids ids and periodically check which ones were unsuccessful, or, if there is an easier way, just query Sidekiq / Redis and see what arguments and errors of unsuccessful jobs are.

I also visited this link: Get error message from Sidekiq job

Here is an example of the work that I use

class ClassificationJob < ActiveJob::Base queue_as :default def perform(entity) entity.preprocess! entity.classify! end end 

I tried to change this

 class ClassificationJob < ActiveJob::Base queue_as :default def perform(entity) entity.preprocess! entity.classify! store entity_id: entity.id.to_s entity_id = retrieve :entity_id end end 

But this leads to the following error:

 ArgumentError: You cannot include Sidekiq::Worker in an ActiveJob: ClassificationJob 

Thanks,

Yannik

+6
source share
2 answers

You are looking for repetitions. "Repeat" is Sidekiq's term for work that has failed and will be repeated in the future.

The web interface uses the Sidekiq API registered on the API wiki page to display repetitions on the Retries tab:

https://github.com/mperham/sidekiq/wiki/API#retries

 retries = Sidekiq::RetrySet.new retries.each do |job| p [job.klass, job.args, job.jid] end 
+4
source

I was just looking for a way to narrow down the various types of crashes in the console from a given queue.

After a little digging

To get a list of your employees:

 query = Sidekiq::Failures::FailureSet.new.map(&:item) query.map { |item| item['class'] }.uniq # Gives you a sense of what failed query.map { |item| item['wrapped'] }.uniq # Gives you the job original class query.map { |item| item['queue'] }.uniq # Gives you a name of each of the queues query.map { |item| item['args'] }.uniq # This would give you all the argument hashes for all failures. 

The args hash has the following keys:

 job_class job_id queue_name arguments locale 

I think you need to have this pearl for this: https://github.com/mhfs/sidekiq-failures

+1
source

All Articles