Monitor Hangfire Recurring Jobs with CronRabbit

C#

The Problem

Hangfire manages retries internally, but after all retries fail, the job moves to 'Failed' state without external notification.

The Solution

Add CronRabbit pings in your Hangfire job methods. The external heartbeat catches both job failures and Hangfire infrastructure issues.

Integration

Add pings inside the method registered with RecurringJob.AddOrUpdate(). Each recurring job gets its own monitor.

Code Examples

Hangfire recurring job with monitoring

C#
public class ReportService
{
    private readonly HttpClient _http;
    private const string Ping = "https://ping.cronrabbit.com/your-id";

    public ReportService(IHttpClientFactory factory)
    {
        _http = factory.CreateClient();
    }

    public async Task GenerateDailyReport()
    {
        await _http.GetAsync($"{Ping}/start");
        try
        {
            await BuildReport();
            await SendEmails();
            await _http.GetAsync(Ping);
        }
        catch
        {
            await _http.GetAsync($"{Ping}/fail");
            throw;
        }
    }
}

// Registration
RecurringJob.AddOrUpdate<ReportService>(
    "daily-report",
    x => x.GenerateDailyReport(),
    "0 6 * * *");

Ready to Monitor Your Cron Jobs?

Create your free account and add your first monitor in under 5 minutes. No credit card required.