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

Create a monitor

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.

For more details about monitors, refer to Monitors.


Via the dashboard

Set up the monitor

You can create a monitor within the load balancer workflow or in the Monitors section of the dashboard:

  1. Go to Traffic > Load Balancing.

  2. Click Manage Monitors.

  3. Click Create.

  4. Add the following information:

    • Type: The protocol to use for health checks (HTTP, HTTPS, or TCP)
    • Path: The endpoint path to run health checks against
    • Port: The destination port for health checks
  5. For additional settings, select Advanced health check settings:

    • Interval:
      • By increasing the default, you may increase load on your servers.
      • Minimum time in seconds is 60 (Pro), 10 (Business), and 5 (Enterprise).
    • Timeout and Retries:
      • The health check will return unhealthy if it exceeds the duration specified in Timeout (and exceeds this duration more times than the specified number of Retries).
    • Response Body:
      • Looks for a case-insensitive substring in the response body.
      • Make sure that the value is relatively static and within the first 100,000 KB of the HTML page.
    • Simulate Zone:
    • Follow Redirects:
      • Instead of reporting a 301 or 302 code as unhealthy, the health check follows redirects to the final endpoint.
    • Configure Request Header(s):
      • Useful if your servers are expecting specific incoming headers.
  6. Select Save.

Prepare your servers

Make sure that your firewall or web server does not block or rate limit your configured health checks.

Each health check has the HTTP user-agent of "Mozilla/5.0 (compatible; Cloudflare-Traffic-Manager/1.0; +https://www.cloudflare.com/traffic-manager/; pool-id: $poolid)", where the $poolid is the first 16 characters of the associated pool.

Attach the monitor to a pool

Once your monitor is created, you need to attach it to an origin pool:

  1. Go to Traffic > Load Balancing.

  2. Click Manage Pools.

  3. On a specific pool, click Edit.

  4. Update the following information:

    • Monitor: Select your monitor.
    • Health Check Regions: Specifies geographic regions from which Cloudflare should send health check requests. Because of how monitors check pool health, selecting multiple regions could increase the load on your servers.
    • Notification E-mail: Contains email addresses that receive notifications (individual, mailing list address, PagerDuty address).
  5. Click Save. The status of your health check will be unknown until the results of the first check are available.


Via the API

Set up the monitor

For a full list of monitor properties, refer to Create Monitor. If you need help with API authentication, refer to Cloudflare API Quickstart.

Request
curl -X POST \
-H "X-Auth-Email: user@cloudflare.com" \
-H "X-Auth-Key: REDACTED" \
"https://api.cloudflare.com/client/v4/accounts/:account_id/load-balancers/monitors" \
-H "Content-Type: application/json" \
-d '{
"type":"https",
"description":"Login page monitor",
"method":"GET",
"path":"/health",
"header": {
"Host":["example.com"],
"X-App-ID":["abc123"]
},
"port":8080,
"timeout":3,
"retries":0,
"interval":90,
"expected_body":"alive",
"expected_codes":"2xx",
"follow_redirects":true,
"allow_insecure":true,
"consecutive_up":3,
"consecutive_down":2,
"probe_zone":"example.com"
}'

The response contains the complete definition of the new monitor.

Response
{
"success": true,
"errors": [],
"messages": [],
"result": {
"id": ":monitor-id",
"created_on": "2021-01-01T05:20:00.12345Z",
"modified_on": "2021-01-01T05:20:00.12345Z",
"type": "https",
"description": "Login page monitor",
"method": "GET",
"path": "/health",
"header": {
"Host": [
"example.com"
],
"X-App-ID": [
"abc123"
]
},
"port": 8080,
"timeout": 3,
"retries": 0,
"interval": 90,
"expected_body": "alive",
"expected_codes": "2xx",
"follow_redirects": true,
"allow_insecure": true,
"consecutive_up": 3,
"consecutive_down": 2,
"probe_zone": "example.com"
}
}

Prepare your servers

Make sure that your firewall or web server does not block or rate limit your configured health checks.

Each health check has the HTTP user-agent of "Mozilla/5.0 (compatible; Cloudflare-Traffic-Manager/1.0; +https://www.cloudflare.com/traffic-manager/; pool-id: $poolid)", where the $poolid is the first 16 characters of the associated pool.

Attach the monitor to a pool

Once your monitor is created, save its id property. Include this value in the monitor parameter when creating your pool.