Manage Probes
Probes enable you to get information about the health and readiness of assets that are starting up or running.
Codiac supports three probe types:
- Liveness: Is the asset running?
- Readiness: Is the asset ready to accept traffic?
- Startup: Monitors an asset when it is deployed. Reports back when the deployment is complete.
And four probe methods:
- Basic probes:
- Executable: An executable CLI command that treats a response code of zero as success and non-zero as failure.
- HTTP: An HTTP request that treats a response code between 200 and 400 as success and any other value as failure.
- Advanced probes:
- GRPC: A GRPC API request.
- Socket: A TCP socket request.
Usage and Options
Use codiac asset probe -h
to see all the available options:
Prerequisites
- Basic Codiac Prerequisites
- Existing Codiac asset, cluster, and cabinet.
- The script you want the probe to run.
Create a Probe
Usage and Options
codiac asset probe create [CMD]
declares the implementation of a health or readiness probe for an asset.
Codiac supports four probe methods:
- Basic probes:
- Executable: An executable CLI command which treats a response code of zero as success and non-zero as failure.
- HTTP: An HTTP request which treats a response code between 200 and 400 as success and any other value as failure.
- Advanced probes:
- GRPC: A GRPC API request.
- Socket: A TCP socket request.
Executable
Flag | Description |
---|---|
--exec | An executable CLI command which treats a response code of zero as success and non-zero as failure. |
Associated parameters:
Parameter | Example | Description |
---|---|---|
--execCommand=[COMMAND_TO_RUN] | --execCommand="cat /app/data/example-command.json" | The command you want the probe to run. |
Example
This command:
codiac probe create \
-p 15 \
--exec \
--execCommand="cat /app/data/example-command.json"
Tells Codiac to create a probe which:
- Every 15 seconds.
- As an executable CLI command which treats a response code of zero as success and non-zero as failure.
- Runs the specified command.
As a result, every 15 seconds this probe will run "cat /app/data/example-command.json"
. If the command returns zero, Codiac interprets it as a success. If the command returns any other value, Codiac interprets it as a failure.
This example was submitted by a customer who uses it to check an error file. If no errors have been logged, the error file is empty, and the probe returns a value of zero (success). If an error has been logged, the probe returns a non-zero value (failure). This is a "no news is good news" approach to heartbeat monitoring.
HTTP
Flag | Description |
---|---|
--http | An HTTP request which treats a response code between 200 and 400 as success and any other value as failure. |
Associated parameters:
Parameter | Example | Description |
---|---|---|
--h [HTTP_HEADER] | -h user-agent=MyUserAgent | A key/value pair to send as an HTTP header. |
--httpHost=[HOSTNAME] | --httpHost myapi.acme.com | The HTTP host. |
--httpPath=[PATH] | --httpPath /diag/heartbeat | The path to the target script on the HTTP host. |
--httpPort=[PORT_NUMBER] | --httpPort 443 | The port the probe uses. |
--httpScheme=[SCHEME] | --httpScheme https | The HTTP protocol. Options are http and https . |
Example
This command:
codiac probe create \
-n acme \
-a myapi \
-u readiness \
-p 15 \
--http \
--httpScheme https \
--httpHost myapi.acme.com \
--httpPort 443 \
--httpPath /diag/heartbeat \
-h Accept=application/json \
-h user-agent=MyUserAgent
Tells Codiac to create a probe which:
- On the
acme
enterprise. - The
myapi
asset. - A readiness probe.
- Every 15 seconds.
- As an HTTP request which treats a response code between 200 and 400 as success and any other value as failure.
- Using the HTTPS protocol.
- At
myapi.acme.com
. - On port 443.
- At the path
/diag/heartbeat
. - With the
Accept=application/json
anduser-agent=MyUserAgent
key/value pairs as HTTP headers.
As a result, every 15 seconds this probe will make an HTTP request to https://myapi.acme.com/diag/heartbeat on port 443, passing user-agent=MyUserAgent
as an HTTP header.
Advanced
GRPC
Flag | Description |
---|---|
--grpc | A GRPC API request. |
Associated parameters:
Parameter | Example | Description |
---|---|---|
--grpcHost=[HOSTNAME] | --grpcHost api.acme.com | The GRPC host. |
--grpcPort=[PORT_NUMBER] | --grpcPort 443 | The port the probe uses. |
Socket
Flag | Description |
---|---|
--socket | A TCP socket request. |
Associated parameters:
Method | Parameter | Example | Description |
---|---|---|---|
Socket | --socketHost=[HOSTNAME] | --socketHost host.acme.com | The TCP socket host. |
Socket | --socketPort=[PORT_NUMBER] | --socketPort 80 | The port the probe uses. |
Socket | --success-threshold=[THRESHOLD] | `--success-threshold 2 | The minimum number of consecutive successes for the probe to be considered successful after having failed. Defaults to 1. Must be 1 for liveness and startup Probes. Minimum value is 1. |
List Probes
Use codiac asset probe list
to list all existing probes.
Delete a Probe
Use codiac asset probe delete
to delete an asset probe definition.
This command does not remove running assets. You will need to redeploy an asset for the change to affect its runtime instances.