Skip to content
Load Balancing
Visit Load Balancing on GitHub
Set theme to dark (⇧+D)

Monitors

A monitor issues health checks at regular intervals to evaluate the health of an origin pool. When a pool becomes unhealthy, your load balancer takes that pool out of the server rotation.

Dynamic load balancing involves pools, origins, monitors, and health checks

Health checks that result in a status change for an origin server are recorded as events in the Load Balancing event logs.


Important notes

  • Availability monitoring checks the health of origin servers at the specified interval. It reports results via email notifications and the Cloudflare API. Shorter intervals will improve failover time, but may increase the load on your origin servers.
  • The default retry rate is 5 retries/second and is completely configurable. We do not recommend increasing the retry rate significantly. Retries use exponential backoff (1, 2, 4, 8, 16 seconds by default).
  • You can configure monitoring for specific URLs by sending periodic HTTP requests to the load balancer, taking advantage of customizable intervals, timeouts, and status codes. Once an origin server is marked unhealthy, multi-region failover reroutes traffic to the next available server in failover order.
  • Load Balancing monitors use the following HTTP user-agent: "Mozilla/5.0 (compatible; Cloudflare-Traffic-Manager/1.0; +https://www.cloudflare.com/traffic-manager/; pool-id: $poolid)". The $poolid contains the first 16 characters of the Load Balancing pool that is the target of the health check.
  • To increase confidence in pool status, increase the consecutive_up and consecutive_down fields when creating a monitor with the API. To become healthy or unhealthy, monitored origins must pass this health check the consecutive number of times specified in these parameters.
  • To prevent health checks from failing, and to secure user infrastructure against spoofed checks from bad actors, we recommend the following:
    • Only accept connections to hosts listed in the Cloudflare IP ranges in your firewall or web-server.
    • Use Cloudflare's user agent (see above) to reject HTTP requests that don't come from these ranges.
    • Ensure that your firewall or web server does not block or rate limit Cloudflare health checks.

Properties

For an up-to-date list of monitor properties, refer to Monitor properties in our API documentation.


Override HTTP Host headers

When your application needs specialized routing (CNAME setup or custom hosts like Heroku), change the Host header used in health checks.

You can set these headers on a specific origin or a monitor. Headers set on an origin override headers set on a monitor.

Host header prioritization

When a load balancer runs health checks, headers set on an origin override headers set on a monitor.

For example, you might have a load balancer for www.example.com with the following setup:

  • Origin Pools:

    • Pool 1:

      • Origin 1 (Host header set to lb-app-a.example.com)
      • Origin 2
    • Pool 2:

      • Origin 3
      • Origin 4 (Host header set to lb-app-b.example.com)
  • Monitor (Host header set to www.example.com)

In this scenario, health checks for Origin 1 would use lb-app-a.example.com, health checks for Origin 4 would use lb-app-b.example.com, and all other health checks would default to www.example.com. For more information on updating your custom host configuration to be compatible with Cloudflare, see Configure Cloudflare and Heroku over HTTPS.

For a list of origins that override a monitor's Host header:

  1. On a monitor, select Edit.
  2. Select Advanced health check settings.
  3. If you have origin overrides, you will see Origin host header overrides.

List of origin host header overrides


Create monitors

For step-by-step guidance, refer to Create monitors.


API commands

The Cloudflare API supports the following commands for monitors. Examples are given for user-level endpoint but apply to the account-level endpoint as well.

Command
Method
Endpoint
Create MonitorPOSTuser/load_balancers/monitors
Delete MonitorDELETEuser/load_balancers/monitors
List MonitorsGETuser/load_balancers/monitors
Monitor DetailsGETuser/load_balancers/monitors/:identifier
Update MonitorPUTuser/load_balancers/monitors
Preview MonitorPOSTuser/load_balancers/monitors/:identifier/preview