How do we Monitor Hangfire?

We were looking for a way to make sure that Hangfire was running and it had servers active.

The response that comes from the URL /hangfire/stats could easily be setup to be polled against something like Pingdom that checks the response and looks for a given value in like “{“servers:count”:{“value”:“2”,“intValue”:0”

However the URL is not configurable to be publicly accessible.

How do you suggest we do this?

1 Like

I created a controller that did this:

public class MonitoringApiController : ApiController

        public HttpResponseMessage HangfireStatus()
            var monitor = Hangfire.JobStorage.Current.GetMonitoringApi();
            var message = new HttpResponseMessage();
            var response = Request.CreateResponse(HttpStatusCode.OK);
            var workers = monitor.Servers();
            response.Content = new StringContent($"{workers}");
            return response;

This at leasts lets me know my worker servers are up and running. No i can ping this with a monitoring service to confirm i’m seeing the expected # of hangfire servers.