Skip to content

Activity

Erik Hennerfors edited this page Oct 16, 2026 · 4 revisions

Read a monitor's history: its activity, the alerts sent about it, and the pings it received.

Getting a client

A monitor's history is read through the same IMonitorsClient as the monitor itself: CronitorClient.Monitors on the static class, injected after .ConfigureCronitor(), or created with new MonitorsClient("apiKey"). See Setup for each. The examples below use monitorsClient.

Methods

Each method has a sync and an async (…Async) version, takes the monitor's key, and throws when Cronitor answers with an error.

Method Returns Description
ActivitiesAsync(MonitorKey key) IEnumerable<Activity> The monitor's recent activity
AlertsAsync(MonitorKey key) IEnumerable<Alert> The alerts and recoveries sent about the monitor
PingsAsync(MonitorKey key) IEnumerable<Ping> The pings the monitor received, and its alerts

The models are in Cronitor.Models. Cronitor prunes old history, so these return recent entries only.

For a monitor's latest state rather than its history, get the monitor and read LatestEvent, LatestEvents and LatestIssue.

Activity

var activities = await monitorsClient.ActivitiesAsync("nightly-backup");

foreach (var activity in activities)
{
    Console.WriteLine($"{activity.CreatedAt} {activity.Event} {activity.Message}");
}
Property Description
Timestamp When it happened, as a Unix timestamp with decimals
CreatedAt When it happened, as text
MonitorKey, MonitorName The monitor
Description What kind of entry it is
Event The event
Message The message sent with the event
Status The result, for checks
Duration The duration
From Where the event came from
Host The host the event was sent from, if one was given
Count, ErrorCount The count and error_count metrics sent with the event, if any

Alerts

var alerts = await monitorsClient.AlertsAsync("nightly-backup");

foreach (var alert in alerts)
{
    Console.WriteLine($"{alert.CreatedAt} {alert.Type} via {alert.Channel} to {alert.Destination}");
}
Property Description
Type alert when the monitor started failing, recovery when it recovered
Channel How it was sent, e.g. slack or email
Destination Where it was sent, e.g. a Slack channel or an email address
Delivered Whether it was delivered
NotificationList The notification list it was sent through
Incident The incident it belongs to; an alert and its recovery share it
Monitor The monitor, as Key and Name
CreatedAt When it was sent
GroupByKey The key Cronitor grouped it by

Pings

var pings = await monitorsClient.PingsAsync("nightly-backup");

foreach (var ping in pings)
{
    Console.WriteLine($"{ping.CreatedAt} {ping.Description} {ping.Event} from {ping.From}");
}

A ping's properties depend on the monitor's type:

Property Jobs and heartbeats Checks Alerts
Description ping healthcheck alert
Event run, complete or fail failure or recovery
Message The message sent with the ping The check's description The failure
From The IP the ping came from The location Cronitor requested from
Status The result of the request
Duration The response time

Every ping also has Timestamp, CreatedAt, MonitorKey, MonitorName, and Host, Count and ErrorCount when they were sent.

Clone this wiki locally