Learn how to actively monitor your origin server with Cloudflare Health Checks
Overview
A health check actively monitors whether your origin server is online by sending specific requests at regular intervals.
Cloudflare offers two types of health checks:
- Standalone health checks (included with all paid plans)
- Load Balancing health checks (included as part of a Load Balancing subscription)
Step 1: Create a health check
To create a new health check:
To create a health check in the Cloudflare dashboard:
1. Navigate to Traffic > Health Checks.
2. Click Create.
3. Fill out the form, paying special attention to:
- The values for Interval and Check regions, because decreasing the Interval and increasing Check regions may increase the load on your origin server.
- Health change thresholds, which specify the number of consecutive passed or failed checks before an origin changes status.
4. When you fill out the form, do not set up Notifications.
5. Click Save and Deploy.
To create a health check using code:
- Use the Cloudflare API, but do not include the
notifications
parameter - Use the Cloudflare Go library, but disable notifications by including:
Notification: cloudflare.HealthcheckNotification{ Suspended: true, EmailAddresses: []string{}, }
- Use the Cloudflare Terraform library, specifying that
notification_suspended=true
Once you create a health check, you can create notifications and also monitor origin status using Health Check Analytics.
These health checks will periodically send requests to the specified origin server with a User Agent of Mozilla/5.0 (compatible; Cloudflare-Traffic-Manager/1.0; +https://www.cloudflare.com/traffic-manager/; healthcheck-id: <HEALTHCHECK_ID>
.
Step 2: Create a health check notification
Once you have created a health check, set up health check notifications:
To create a health check notification in the dashboard:
1. Navigate to Traffic > Health Checks.
2. Click Configure an alert.
3. Fill out the Notification name and Description and add a Notification email.
4. Click Next.
5. Add health checks to include in your alerts.
6. Choose the Notification trigger, which determines when you receive alerts.
7. Click Create.
To set up a health check notification with code:
- Use the Cloudflare API with the following parameters specified (beyond
name
,mechanism
, etc.:
"alert_type":"health_check_status_notification", "filters":{ "health_check_id":[""], "status":["Unhealthy"] }
- Use the Cloudflare Go library to create a notification policy with the following parameters specified (beyond
Name
,Mechanism
, etc.):
AlertType: "health_check_status_notification", Filters: map[string][]string{ // receive notifications when the status is unhealthy "status": {"Unhealthy"}, // id of previously created healthcheck "health_check_id": {healthcheckResponse.ID}, }
- Use the Cloudflare Terraform library to create a notification policy with the following parameters specified (beyond
name
,email_integration
, etc.)
alert_type = "health_check_status_notification" filters { status = ["Unhealthy"] health_check_id = [cloudflare_healthcheck.production.id] }
Use health check analytics
Once you have set up a standalone health check — likely including notification emails — use health check analytics to debug possible origin issues.
To access health check analytics, go to Traffic > Health Check Analytics. Once there, you can evaluate origin uptime and latency and specific event logs:
- Health Checks By Uptime: Shows the % of uptime for individual origins over time.
- Health Checks By Failure Reason: Shows a breakdown of failures by the specific reason.
- Health Checks By Latency: Shows average latency – measured in round trip time — for individual origins over time.
- Event Log: Shows individual health check data. Click each record for additional details on Round trip time, the Failure Reason, the Average Waterfall (showing chronological data about request stages), and more.
Notification migration
Background
Previously (and continuing until May 24, 2022), you could create health check notifications at the same time as you were creating a health check.
However, health check notifications are now migrating to the the Notifications dashboard. We have provided more details in the Cloudflare blog, but here's a summary of the timeline:
- For now, customers subscribed to legacy emails will continue to receive them unchanged, so any parsing infrastructure will still work. From within a Health Check, you will see two options for configuring notifications: the legacy format and a deep link to the Notifications dashboard.
- On May 24, 2022, we will disable the legacy method for the configuration of email notifications from the Health Checks dashboard.
- On June 28, 2022, we will stop sending legacy emails. Adding new emails at the
/healthchecks
endpoint will no longer send email notifications.
Next steps
We strongly encourage all our users to migrate existing Health Checks notifications to the Notifications dashboard within this timeframe to avoid lapses in alerts.
To locate existing notifications on your health checks:
To locate health checks with existing notifications in the dashboard:
- Log into the Cloudflare dashboard and select your account and domain.
- Go to Traffic > Health Checks.
- On a health check, click Edit.
- For Recipients, check if there is an email address present. If so, you will need to create a new notification.
- If using the Cloudflare API, check the
notifications
object for thesuspended
property. Health checks with enabled legacy notifications will have this property set tofalse
. - If using the Cloudflare Go Library, check the
HealthcheckNotification
structure for theSuspended
property. Health checks with enabled legacy notifications will have this property set tofalse
. - If using Cloudflare Terraform, check the
notification_suspended
parameter. Health checks with enabled legacy notifications will have this parameter set tofalse
.