モニターの管理
A monitor issues health monitor requests at regular intervals to evaluate the health of each endpoint within a pool.
When a pool becomes unhealthy, your load balancer takes that pool out of the endpoint rotation.
モニターの詳細については、モニターを参照してください。
モニターの設定
You can create a monitor within the load balancer workflow or in the Monitors section of the dashboard:
-
Go to Traffic > Load Balancing.
-
Select Manage Monitors.
-
Select Create.
-
Add the following information:
- Type: The protocol to use for health monitors
- Non-enterprise customers: Choose HTTP, HTTPS, or TCP.
- Enterprise customers: Choose HTTP, HTTPS, TCP, UDP ICMP, ICMP Ping, or SMTP.
- Path: The endpoint path to run health monitor requests against
- Port: The destination port for health monitors
- Type: The protocol to use for health monitors
-
For additional settings, select Advanced health monitor settings:
- Interval:
- By increasing the default, you can improve failover time, but you may also increase load on your endpoints.
- Minimum time in seconds is 60 (Pro), 15 (Business), and 10 (Enterprise).
- Timeout and Retries:
- The health monitor request will return unhealthy if it exceeds the duration specified in Timeout (and exceeds this duration more times than the specified number of Retries).
- Expected Code(s): The expected HTTP response codes listed individually (
200,302) or as a range (for example, entering2xxwould cover all response codes in the200range). - 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 MB of the HTML page.
- Simulate Zone:
- Pushes a request from Cloudflare health monitors through the Cloudflare stack as if it were a real visitor request to help analyze behavior or validate a configuration using the zone specified.
- It is recommended to use the same zone in which the Load Balancer exists.
- Ensures health monitor requests are compatible with features like authenticated origin pulls and Argo Smart Routing.
- Follow Redirects:
- Instead of reporting a
301or302code as unhealthy, the health monitor request follows redirects to the final endpoint.
- Instead of reporting a
- Configure Request Header(s):
- Useful if your endpoints are expecting specific incoming headers.
- Header:
- The HTTP request headers to send in the health monitor. It is recommended that you set a Host header by default. The User-Agent header cannot be overridden. This parameter is only valid for HTTP and HTTPS monitors.
- Interval:
-
Select Save.
サーバーの準備
Make sure that your firewall or web server does not block or rate limit your configured health monitors or requests associated with Cloudflare IP addresses ↗.
Each health monitor 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.
プールにモニターを添付
モニターが作成されたら、プールに添付する必要があります:
-
トラフィック > ロードバランシングに移動します。
-
プールの管理を選択します。
-
特定のプールで、編集を選択します。
-
次の情報を更新します:
- モニター: モニターを選択します。
- ヘルスモニター地域: Cloudflareがヘルスモニターリクエストを送信する地理的地域を指定します。モニターがプールのヘルスをチェックする方法により、複数の地域を選択するとサーバーへの負荷が増加する可能性があります。
- 通知メール: 通知を受け取るメールアドレス(個人、メーリングリストアドレス、PagerDutyアドレス)を含みます。
-
保存を選択します。ヘルスモニターのステータスは、最初のチェックの結果が利用可能になるまで_不明_のままです。
モニターの設定
For a full list of monitor properties, refer to Create Monitor. If you need help with API authentication, refer to Cloudflare API documentation.
curl "https://api.cloudflare.com/client/v4/accounts/{account_id}/load_balancers/monitors" \--header "Authorization: Bearer <API_TOKEN>" \--header "Content-Type: application/json" \--data '{ "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.
{ "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" }}サーバーの準備
Make sure that your firewall or web server does not block or rate limit your configured health monitors or requests associated with Cloudflare IP addresses ↗.
Each health monitor 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.
プールにモニターを添付
モニターが作成されたら、そのidプロパティを保存します。この値をプールを作成する際のmonitorパラメータに含めます。
ダッシュボードでモニターを編集するには:
- トラフィック > ロードバランシングに移動します。
- モニターの管理を選択します。
- 特定のモニターで、編集を選択します。
- 必要に応じて設定を更新します。
- 保存を選択します。
APIでモニターを編集する場合、リクエストの種類はどれだけ編集したいかによって異なります。
全体の設定を再提出せずに特定の設定を更新するには、PATCHリクエストを使用します。より広範な変更には、PUTリクエストを使用します。
ダッシュボードでモニターを削除するには:
- トラフィック > ロードバランシングに移動します。
- モニターの管理を選択します。
- 特定のモニターで、削除を選択します。
APIを使用してモニターを削除するには、DELETEリクエストを送信します。