consul.check module¶
- class consul.check.Check[source]¶
Bases:
objectThere are three different kinds of checks: script, http and ttl
- classmethod script(args, interval, deregister=None)[source]¶
Run the script args every interval (e.g. “10s”) to peform health check
- classmethod http(url, interval, timeout=None, deregister=None, header=None)[source]¶
Peform a HTTP GET against url every interval (e.g. “10s”) to peform health check with an optional timeout and optional deregister after which a failing service will be automatically deregistered. Optional parameter header specifies headers sent in HTTP request. header paramater is in form of map of lists of strings, e.g. {“x-foo”: [“bar”, “baz”]}.
- classmethod tcp(host, port, interval, timeout=None, deregister=None)[source]¶
Attempt to establish a tcp connection to the specified host and port at a specified interval with optional timeout and optional deregister after which a failing service will be automatically deregistered.
- classmethod grpc(url, interval, use_tls=None, tls_skip_verify=None, timeout=None, deregister=None)[source]¶
Configures a gRPC health check that periodically assesses a service’s health status.
This check performs a gRPC health check against the specified url at each interval (e.g., “10s”). An optional timeout sets the maximum duration for each check attempt. The deregister parameter specifies the time after which a consistently failing service is automatically deregistered from Consul.
- See also: consul grpc protocol
- classmethod ttl(ttl)[source]¶
Set check to be marked as critical after ttl (e.g. “10s”) unless the check is periodically marked as passing.
- classmethod docker(container_id, shell, script, interval, deregister=None)[source]¶
Invoke script packaged within a running docker container with container_id at a specified interval on the configured shell using the Docker Exec API. Optional register after which a failing service will be automatically deregistered.