I am using the JobStorage.Current.GetMonitoringApi()
in Hangfire to get a count of all succeeded tasks. To do so I am using the following function:
var api = JobStorage.Current.GetMonitoringApi();
var succeededJobs = api.SucceededJobs(0, int.MaxValue);
However, this seems to only return the most recent days worth of Succeeded jobs. In my case it returns 95
but if you look at my dashboard I see much more.
Is there a way through the MonitoringApi to pull all historical job data?
The solution is to set the JobExpirationTimeout
property for each job to prevent it from being removed from the storage too early.
This can be done with an IApplyStateFilter
.
See : https://discuss.hangfire.io/t/how-to-configure-the-retention-time-of-job/34