Integrations
Export metrics to Prometheus
Prometheus export needs a paid plan or trial.
OnlineOrNot publishes the state, result counts and response times of your checks, and the ping history and schedule of your heartbeats, in the Prometheus text format. Point Prometheus, Grafana Cloud, the Datadog Agent or another Prometheus-compatible scraper at it to chart OnlineOrNot data beside your own metrics.
The endpoint is:
https://api.onlineornot.com/v1/metrics/prometheus
Create a token and scrape configuration
- In OnlineOrNot, go to Settings > Integrations > Prometheus
- Under Monitors to export, pick the projects to export, or leave them all unchecked to export every check and heartbeat
- Turn on Split check results by region if you want a
regionlabel on result counts and response times - Choose when the token expires
- Click Create Prometheus token
- Copy the configuration. The token in it isn't shown again
The page also estimates how many series the export produces, since many metrics services charge per series.
To use a token you already have, give it READ access to Uptime, Browser, DNS & TCP Checks and Heartbeat Checks, and use Check an existing token to confirm what it exports.
Set up Prometheus
Add a scrape job to prometheus.yml. Keep the token in a file only Prometheus can read:
scrape_configs:
- job_name: onlineornot
scrape_interval: 60s
scrape_timeout: 10s
scheme: https
metrics_path: /v1/metrics/prometheus
authorization:
type: Bearer
credentials_file: /etc/prometheus/secrets/onlineornot-token
params:
per_region: ['true']
static_configs:
- targets: ['api.onlineornot.com']
params is optional. Add project_id to export only some projects, and use unassigned for monitors that aren't in a project.
Set up Grafana Cloud
In Grafana Cloud, go to Connections, add a Metrics Endpoint connection and enter:
- Scrape job URL:
https://api.onlineornot.com/v1/metrics/prometheus, with anyproject_idorper_regionparameters - Authentication: Bearer, with your API token
- Scrape interval: 60 seconds
Set up Datadog
Use the Datadog Agent's OpenMetrics check. Create conf.d/openmetrics.d/conf.yaml:
instances:
- openmetrics_endpoint: https://api.onlineornot.com/v1/metrics/prometheus
namespace: onlineornot
metrics:
- oon_.*
headers:
Authorization: Bearer <API token>
min_collection_interval: 60
Datadog counts these as custom metrics.
What's exported
| Metric | Type | Description |
|---|---|---|
oon_monitor_status |
gauge | 1 for the monitor's current state (UP, DOWN, PAUSED and others), else 0 |
oon_monitor_info |
gauge | Project of each monitor |
oon_monitor_last_result_timestamp_seconds |
gauge | Time of the latest check result or heartbeat ping |
oon_check_interval_seconds |
gauge | How often the check runs |
oon_check_results_total |
counter | Check results, by outcome="passing" or outcome="failing" |
oon_check_duration_seconds |
histogram | How long each check took |
oon_heartbeat_pings_total |
counter | Pings received |
oon_heartbeat_next_due_timestamp_seconds |
gauge | When the next ping is due |
oon_heartbeat_overdue |
gauge | 1 when the heartbeat is past its due time plus grace period |
oon_export_info |
gauge | Whether checks and heartbeats were included, based on the token |
Monitor metrics have monitor_id, check_type and name labels. The API reference lists every metric, label and response code.
Counters start when you turn on Prometheus export, and new results appear within about a minute. Each token can scrape up to 10 times a minute.
Example queries
Monitors that are down:
oon_monitor_status{state="DOWN"} == 1
Failure rate of each check over the last hour:
sum by (monitor_id, check_type, name) (increase(oon_check_results_total{outcome="failing"}[1h]))
/
sum by (monitor_id, check_type, name) (increase(oon_check_results_total[1h]))
95th percentile check duration over the last hour:
histogram_quantile(0.95, sum by (monitor_id, check_type, name, le) (rate(oon_check_duration_seconds_bucket[1h])))
Grafana dashboard and alert rules
- Download the starter Grafana dashboard and import it from Dashboards > New > Import
- Download the example alert rules and add the file to
rule_filesinprometheus.yml
Prometheus alerts fire later than OnlineOrNot's own alerts, because results take up to a minute to reach the export and scraping adds up to another minute. If you alert from both, you'll be notified twice for the same outage. To alert only from Prometheus, remove the alert recipients and integrations from those monitors in OnlineOrNot, but don't mute them. A muted monitor never changes to DOWN, so oon_monitor_status{state="DOWN"} and the example rules won't fire for it.