# Monitors ## List Monitors `load_balancers.monitors.list(MonitorListParams**kwargs) -> SyncSinglePage[Monitor]` **get** `/accounts/{account_id}/load_balancers/monitors` List configured monitors for an account. ### Parameters - `account_id: str` Identifier. ### Returns - `class Monitor: …` - `id: Optional[str]` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `created_on: Optional[str]` - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, List[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `modified_on: Optional[str]` - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.load_balancers.monitors.list( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "id": "f1aba936b94213e5b8dca0c0dbf1f9cc", "allow_insecure": true, "consecutive_down": 0, "consecutive_up": 0, "created_on": "2014-01-01T05:20:00.12345Z", "description": "Login page monitor", "expected_body": "alive", "expected_codes": "2xx", "follow_redirects": true, "header": { "Host": [ "example.com" ], "X-App-ID": [ "abc123" ] }, "interval": 0, "method": "GET", "modified_on": "2014-01-01T05:20:00.12345Z", "path": "/health", "port": 0, "probe_zone": "example.com", "retries": 0, "timeout": 0, "type": "https" } ], "success": true, "result_info": { "count": 20, "page": 1, "per_page": 20, "total_count": 2000, "total_pages": 100 } } ``` ## Monitor Details `load_balancers.monitors.get(strmonitor_id, MonitorGetParams**kwargs) -> Monitor` **get** `/accounts/{account_id}/load_balancers/monitors/{monitor_id}` List a single configured monitor for an account. ### Parameters - `account_id: str` Identifier. - `monitor_id: str` ### Returns - `class Monitor: …` - `id: Optional[str]` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `created_on: Optional[str]` - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, List[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `modified_on: Optional[str]` - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) monitor = client.load_balancers.monitors.get( monitor_id="f1aba936b94213e5b8dca0c0dbf1f9cc", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(monitor.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f1aba936b94213e5b8dca0c0dbf1f9cc", "allow_insecure": true, "consecutive_down": 0, "consecutive_up": 0, "created_on": "2014-01-01T05:20:00.12345Z", "description": "Login page monitor", "expected_body": "alive", "expected_codes": "2xx", "follow_redirects": true, "header": { "Host": [ "example.com" ], "X-App-ID": [ "abc123" ] }, "interval": 0, "method": "GET", "modified_on": "2014-01-01T05:20:00.12345Z", "path": "/health", "port": 0, "probe_zone": "example.com", "retries": 0, "timeout": 0, "type": "https" }, "success": true } ``` ## Create Monitor `load_balancers.monitors.create(MonitorCreateParams**kwargs) -> Monitor` **post** `/accounts/{account_id}/load_balancers/monitors` Create a configured monitor. ### Parameters - `account_id: str` Identifier. - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, SequenceNotStr[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `load_balancer_monitor_timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Returns - `class Monitor: …` - `id: Optional[str]` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `created_on: Optional[str]` - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, List[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `modified_on: Optional[str]` - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) monitor = client.load_balancers.monitors.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(monitor.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f1aba936b94213e5b8dca0c0dbf1f9cc", "allow_insecure": true, "consecutive_down": 0, "consecutive_up": 0, "created_on": "2014-01-01T05:20:00.12345Z", "description": "Login page monitor", "expected_body": "alive", "expected_codes": "2xx", "follow_redirects": true, "header": { "Host": [ "example.com" ], "X-App-ID": [ "abc123" ] }, "interval": 0, "method": "GET", "modified_on": "2014-01-01T05:20:00.12345Z", "path": "/health", "port": 0, "probe_zone": "example.com", "retries": 0, "timeout": 0, "type": "https" }, "success": true } ``` ## Update Monitor `load_balancers.monitors.update(strmonitor_id, MonitorUpdateParams**kwargs) -> Monitor` **put** `/accounts/{account_id}/load_balancers/monitors/{monitor_id}` Modify a configured monitor. ### Parameters - `account_id: str` Identifier. - `monitor_id: str` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, SequenceNotStr[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `load_balancer_monitor_timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Returns - `class Monitor: …` - `id: Optional[str]` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `created_on: Optional[str]` - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, List[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `modified_on: Optional[str]` - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) monitor = client.load_balancers.monitors.update( monitor_id="f1aba936b94213e5b8dca0c0dbf1f9cc", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(monitor.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f1aba936b94213e5b8dca0c0dbf1f9cc", "allow_insecure": true, "consecutive_down": 0, "consecutive_up": 0, "created_on": "2014-01-01T05:20:00.12345Z", "description": "Login page monitor", "expected_body": "alive", "expected_codes": "2xx", "follow_redirects": true, "header": { "Host": [ "example.com" ], "X-App-ID": [ "abc123" ] }, "interval": 0, "method": "GET", "modified_on": "2014-01-01T05:20:00.12345Z", "path": "/health", "port": 0, "probe_zone": "example.com", "retries": 0, "timeout": 0, "type": "https" }, "success": true } ``` ## Patch Monitor `load_balancers.monitors.edit(strmonitor_id, MonitorEditParams**kwargs) -> Monitor` **patch** `/accounts/{account_id}/load_balancers/monitors/{monitor_id}` Apply changes to an existing monitor, overwriting the supplied properties. ### Parameters - `account_id: str` Identifier. - `monitor_id: str` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, SequenceNotStr[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `load_balancer_monitor_timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Returns - `class Monitor: …` - `id: Optional[str]` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `created_on: Optional[str]` - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, List[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `modified_on: Optional[str]` - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) monitor = client.load_balancers.monitors.edit( monitor_id="f1aba936b94213e5b8dca0c0dbf1f9cc", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(monitor.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f1aba936b94213e5b8dca0c0dbf1f9cc", "allow_insecure": true, "consecutive_down": 0, "consecutive_up": 0, "created_on": "2014-01-01T05:20:00.12345Z", "description": "Login page monitor", "expected_body": "alive", "expected_codes": "2xx", "follow_redirects": true, "header": { "Host": [ "example.com" ], "X-App-ID": [ "abc123" ] }, "interval": 0, "method": "GET", "modified_on": "2014-01-01T05:20:00.12345Z", "path": "/health", "port": 0, "probe_zone": "example.com", "retries": 0, "timeout": 0, "type": "https" }, "success": true } ``` ## Delete Monitor `load_balancers.monitors.delete(strmonitor_id, MonitorDeleteParams**kwargs) -> MonitorDeleteResponse` **delete** `/accounts/{account_id}/load_balancers/monitors/{monitor_id}` Delete a configured monitor. ### Parameters - `account_id: str` Identifier. - `monitor_id: str` ### Returns - `class MonitorDeleteResponse: …` - `id: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) monitor = client.load_balancers.monitors.delete( monitor_id="f1aba936b94213e5b8dca0c0dbf1f9cc", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(monitor.id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "id": "f1aba936b94213e5b8dca0c0dbf1f9cc" }, "success": true } ``` ## Domain Types ### Monitor - `class Monitor: …` - `id: Optional[str]` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `created_on: Optional[str]` - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, List[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `modified_on: Optional[str]` - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Monitor Delete Response - `class MonitorDeleteResponse: …` - `id: Optional[str]` # Previews ## Preview Monitor `load_balancers.monitors.previews.create(strmonitor_id, PreviewCreateParams**kwargs) -> PreviewCreateResponse` **post** `/accounts/{account_id}/load_balancers/monitors/{monitor_id}/preview` Preview pools using the specified monitor with provided monitor details. The returned preview_id can be used in the preview endpoint to retrieve the results. ### Parameters - `account_id: str` Identifier. - `monitor_id: str` - `allow_insecure: Optional[bool]` Do not validate the certificate when monitor use HTTPS. This parameter is currently only valid for HTTP and HTTPS monitors. - `consecutive_down: Optional[int]` To be marked unhealthy the monitored origin must fail this healthcheck N consecutive times. - `consecutive_up: Optional[int]` To be marked healthy the monitored origin must pass this healthcheck N consecutive times. - `description: Optional[str]` Object description. - `expected_body: Optional[str]` A case-insensitive sub-string to look for in the response body. If this string is not found, the origin will be marked as unhealthy. This parameter is only valid for HTTP and HTTPS monitors. - `expected_codes: Optional[str]` The expected HTTP response code or code range of the health check. This parameter is only valid for HTTP and HTTPS monitors. - `follow_redirects: Optional[bool]` Follow redirects if returned by the origin. This parameter is only valid for HTTP and HTTPS monitors. - `header: Optional[Dict[str, SequenceNotStr[str]]]` The HTTP request headers to send in the health check. It is recommended 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: Optional[int]` The interval between each health check. Shorter intervals may improve failover time, but will increase load on the origins as we check from multiple locations. - `method: Optional[str]` The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS based checks and 'connection_established' for TCP based health checks. - `path: Optional[str]` The endpoint path you want to conduct a health check against. This parameter is only valid for HTTP and HTTPS monitors. - `port: Optional[int]` The port number to connect to for the health check. Required for TCP, UDP, and SMTP checks. HTTP and HTTPS checks should only define the port when using a non-standard port (HTTP: default 80, HTTPS: default 443). - `probe_zone: Optional[str]` Assign this monitor to emulate the specified zone while probing. This parameter is only valid for HTTP and HTTPS monitors. - `retries: Optional[int]` The number of retries to attempt in case of a timeout before marking the origin as unhealthy. Retries are attempted immediately. - `load_balancer_monitor_timeout: Optional[int]` The timeout (in seconds) before marking the health check as failed. - `type: Optional[Literal["http", "https", "tcp", 3 more]]` The protocol to use for the health check. Currently supported protocols are 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - `"http"` - `"https"` - `"tcp"` - `"udp_icmp"` - `"icmp_ping"` - `"smtp"` ### Returns - `class PreviewCreateResponse: …` - `pools: Optional[Dict[str, str]]` Monitored pool IDs mapped to their respective names. - `preview_id: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) preview = client.load_balancers.monitors.previews.create( monitor_id="f1aba936b94213e5b8dca0c0dbf1f9cc", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) print(preview.preview_id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "pools": { "abwlnp5jbqn45ecgxd03erbgtxtqai0d": "WNAM Datacenter", "ve8h9lrcip5n5bbga9yqmdws28ay5d0l": "EEU Datacenter" }, "preview_id": "f1aba936b94213e5b8dca0c0dbf1f9cc" }, "success": true } ``` ## Domain Types ### Preview Create Response - `class PreviewCreateResponse: …` - `pools: Optional[Dict[str, str]]` Monitored pool IDs mapped to their respective names. - `preview_id: Optional[str]` # References ## List Monitor References `load_balancers.monitors.references.get(strmonitor_id, ReferenceGetParams**kwargs) -> SyncSinglePage[ReferenceGetResponse]` **get** `/accounts/{account_id}/load_balancers/monitors/{monitor_id}/references` Get the list of resources that reference the provided monitor. ### Parameters - `account_id: str` Identifier. - `monitor_id: str` ### Returns - `class ReferenceGetResponse: …` - `reference_type: Optional[Literal["*", "referral", "referrer"]]` - `"*"` - `"referral"` - `"referrer"` - `resource_id: Optional[str]` - `resource_name: Optional[str]` - `resource_type: Optional[str]` ### Example ```python import os from cloudflare import Cloudflare client = Cloudflare( api_token=os.environ.get("CLOUDFLARE_API_TOKEN"), # This is the default and can be omitted ) page = client.load_balancers.monitors.references.get( monitor_id="f1aba936b94213e5b8dca0c0dbf1f9cc", account_id="023e105f4ecef8ad9ca31a8372d0c353", ) page = page.result[0] print(page.resource_id) ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "reference_type": "referrer", "resource_id": "17b5962d775c646f3f9725cbc7a53df4", "resource_name": "primary-dc-1", "resource_type": "pool" } ], "success": true } ``` ## Domain Types ### Reference Get Response - `class ReferenceGetResponse: …` - `reference_type: Optional[Literal["*", "referral", "referrer"]]` - `"*"` - `"referral"` - `"referrer"` - `resource_id: Optional[str]` - `resource_name: Optional[str]` - `resource_type: Optional[str]`