Skip to content
HookPulse

Monitor Sidekiq scheduled jobs with HookPulse

The job checks in when it ends and reports the failure when it raises, before Sidekiq retries it.

Updated

1Create the monitor

Add a routine named sidekiq-job and set how often the job runs. Its page shows the check-in URL: use it in place of https://hookpulse.net/in/YOUR_ID.

2Check in from the job

Net::HTTP comes with Ruby, so the job needs no extra gem for the check-in.

# app/jobs/nightly_backup_job.rb
require "net/http"

class NightlyBackupJob
  include Sidekiq::Job

  def perform
    Backup.run!
    check_in
  rescue StandardError
    check_in("/fail")
    raise
  end

  private

  def check_in(path = "")
    Net::HTTP.get_response(URI("https://hookpulse.net/in/YOUR_ID#{path}"))
  end
end

3Schedule it

With the sidekiq-cron gem, add the job to config/schedule.yml.

# config/schedule.yml (sidekiq-cron)
nightly_backup:
  cron: "0 3 * * *"
  class: "NightlyBackupJob"

4Run it once

Run NightlyBackupJob.perform_async once from a console. The routine shows the first check-in. From then on, a missed or failed run sends the alert.