1. Integrations
  2. Prometheus

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

  1. In OnlineOrNot, go to Settings > Integrations > Prometheus
  2. Under Monitors to export, pick the projects to export, or leave them all unchecked to export every check and heartbeat
  3. Turn on Split check results by region if you want a region label on result counts and response times
  4. Choose when the token expires
  5. Click Create Prometheus token
  6. 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 any project_id or per_region parameters
  • 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

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.