On Professional and Business, Prometheus can scrape every monitor in your workspace from one endpoint, https://app.uptimecheck.com/api/v1/metrics, with an API key. You get each monitor’s state, response time and 24-hour uptime as metrics, ready for your own alert rules and for charts in Grafana through Prometheus.
Create an API key
- Open Settings in the sidebar and choose the API tab.
- Choose New API key, name it after where it is used, such as “Prometheus”, and pick Read only. Reading metrics needs nothing more.
- Choose Create key and copy it. This is the only time the key is shown.
Add a scrape job
Add a job to prometheus.yml, put your key in place of uc_your_api_key and reload Prometheus:
scrape_configs:
- job_name: uptimecheck
scrape_interval: 60s
scheme: https
metrics_path: /api/v1/metrics
authorization:
type: Bearer
credentials: uc_your_api_key
static_configs:
- targets: ["app.uptimecheck.com"]
Keep scrape_interval at 60 seconds or slower: the API allows 120 requests a minute per key, shared with anything else that uses the key. To keep the key out of the file, use credentials_file with the path to a file that holds it instead of credentials. The new target should show as up on Prometheus’s targets page within a minute.
What you get
uptimecheck_monitor_up: 1 when the last check passed, 0 when it failed. Paused monitors and monitors not checked yet are left out.uptimecheck_monitor_paused: 1 while the monitor is paused.uptimecheck_monitor_response_ms: the last check’s response time in milliseconds.uptimecheck_monitor_last_check_timestamp_seconds: when the monitor was last checked, as a Unix time.uptimecheck_monitor_uptime_ratio: the share of the last 24 hours the monitor was up, from 0 to 1.uptimecheck_open_incidents: incidents open right now in the workspace.
Every monitor metric is labelled with monitor_id, name, type and project, so you can filter by a client’s project or a monitor type.
Alert on it
A Prometheus rule that fires when a monitor has been down for two minutes:
groups:
- name: uptimecheck
rules:
- alert: UptimecheckMonitorDown
expr: uptimecheck_monitor_up == 0
for: 2m
labels:
severity: critical
annotations:
summary: "{{ $labels.name }} is down"
Uptimecheck still sends its own alerts to your alert channels, so rules like this are an addition, not a replacement. More on the Prometheus integration, API keys and the REST API.