Skip to main content

HTTP probe

HTTP probe allows you to specify a URL that the experiment uses to determine the health or service availability (or other custom conditions) that is a part of the entry or exit criteria. The status code received is mapped against an expected status. It supports HTTP GET and POST methods.

The HTTP GET method sends a GET request to the specified URL. The response code received is matched with the response code based on the given criteria (==, !=, oneOf).

HTTP POST method sends a POST request to the provided URL.

YAML only feature

In the case of a complex POST request in which the body spans multiple lines, the bodyPath attribute is used to specify the path to a file consisting of the same. This file is available to the experiment pod through a ConfigMap resource, wherein the ConfigMap name is defined in the chaos engine or the chaos experiment CR. The body and bodyPath attributes are mutually exclusive. Go to probe schema to learn more.

Defining the probe

You can define the probes at .spec.experiments[].spec.probe path inside the chaos engine.

kind: Workflow
apiVersion: argoproj.io/v1alpha1
spec:
templates:
- inputs:
artifacts:
- raw:
data: |
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
spec:
experiments:
- spec:
probe:
####################################
Probes are defined here
####################################

Schema

Listed below is the probe schema for HTTP Probe with common properties shared across all probes and properties unique to HTTP probe.

FieldDescriptionTypeRangeNotes
nameFlag to hold the name of the probeMandatoryN/A type: stringThe name holds the name of the probe. It can be set based on the usecase
typeFlag to hold the type of the probeMandatoryhttpProbe, k8sProbe, cmdProbe, promProbeThe type supports four types of probes. It can one of the httpProbe, k8sProbe, cmdProbe, promProbe
modeFlag to hold the mode of the probeMandatorySOT, EOT, Edge, Continuous, OnChaosThe mode supports five modes of probes. It can one of the SOT, EOT, Edge, Continuous, OnChaos
urlFlag to hold the URL for the httpProbeMandatoryN/A type: stringThe url contains the URL which the experiment uses to gauge health/service availability (or other custom conditions) as part of the entry/exit criteria.
insecureSkipVerifyFlag to hold the flag to skip certificate checks for the httpProbeOptionaltrue, falseThe insecureSkipVerify contains flag to skip certificate checks.
headersFlag to hold the http request headers for the httpProbeOptionalN/A type: map[string]stringThe headers contains flag to hold the http request headers.

Method

GET method properties

FieldDescriptionTypeRangeNotes
criteriaFlag to hold the criteria for the http get requestMandatory==, !=, oneOfThe criteria contains criteria to match the http get request's response code with the expected responseCode, which need to be fulfill as part of httpProbe run
responseCodeFlag to hold the expected response code for the get requestMandatoryHTTP_RESPONSE_CODEThe responseCode contains the expected response code for the http get request as part of httpProbe run

POST method properties

FieldDescriptionTypeRangeNotes
criteriaFlag to hold the criteria for the http post requestMandatory==, !=, oneOfThe criteria contains criteria to match the http post request's response code with the expected responseCode, which need to be fulfill as part of httpProbe run
responseCodeFlag to hold the expected response code for the post requestMandatoryHTTP_RESPONSE_CODEThe responseCode contains the expected response code for the http post request as part of httpProbe run
contentTypeFlag to hold the content type of the post requestMandatoryN/A type: stringThe contentType contains the content type of the http body data, which need to be passed for the http post request
bodyFlag to hold the body of the http post requestMandatoryN/A type: stringThe body contains the http body, which is required for the http post request. It is used for the simple http body. If the http body is complex then use bodyPath field.
bodyPathFlag to hold the path of the http body, required for the http post requestOptionalN/A type: stringThe bodyPath This field is used in case of complex POST request in which the body spans multiple lines, the bodyPath attribute can be used to provide the path to a file consisting of the same. This file can be made available to the experiment pod via a ConfigMap resource, with the ConfigMap name being defined in the ChaosEngine OR the ChaosExperiment CR.

Run properties

FieldDescriptionTypeRangeNotes
probeTimeoutFlag to hold the timeout of the probeMandatoryN/A type: stringThe probeTimeout represents the time limit for the probe to execute the specified check and return the expected data
attemptFlag to hold the attempt of the probeMandatoryN/A type: integerThe attempt contains the number of times a check is run upon failure in the previous attempts before declaring the probe status as failed.
intervalFlag to hold the interval of the probeMandatoryN/A type: stringThe interval contains the interval for which probes waits between subsequent retries
probePollingIntervalFlag to hold the polling interval for the probes (applicable for all modes)OptionalN/A type: stringThe probePollingInterval contains the time interval for which continuous and onchaos probe should be sleep after each iteration
initialDelaySecondsFlag to hold the initial delay interval for the probesOptionalN/A type: integerThe initialDelaySeconds represents the initial waiting time interval for the probes.
stopOnFailureFlags to hold the stop or continue the experiment on probe failureOptionalN/A type: booleanThe stopOnFailure can be set to true/false to stop or continue the experiment execution after probe fails

Authentication

This establishes a fundamental authentication mechanism for the http endpoint. The username:password, encoded in base64 or bearer token should be placed either within the credentials field or as a file path in the credentialsFile field. It's important to note that credentials and credentialsFile are two options that cannot be used simultaneously.

FieldDescriptionTypeRangeNotes
typeFlag to hold the authentication typeOptionalstringThe type encompasses the authentication method, which includes support for both Basic and Bearer authentication types
credentialsFlag to hold the basic auth credentials or bearer tokenOptionalstringThe credentials consists of the basic authentication credentials, either as username:password encoded in base64 format or as a bearer token, depending on the authentication type
credentialsFileFlag to hold the basic auth credentials or bearer token file pathOptionalstringThe credentials consists of file path for basic authentication credentials or a bearer token, which are then attached to the experiment pod as volume secrets. These secret resources contain either the username:password encoded in base64 format or a bearer token, depending on the authentication type

TLS

It offers the mechanism to validate TLS certifications for the http endpoint. You can supply the cacert or the client certificate and client key, to perform the validation. Alternatively, you have the option to enable the insecureSkipVerify check to bypass certificate validation.

FieldDescriptionTypeRangeNotes
caFileFlag to hold the ca file pathOptionalstringThe caFile holds the file path of the CA certificates utilized for server TLS verification
certFileFlag to hold the client cert file pathOptionalstringThe certFile holds the file path of the client certificates utilized for TLS verification
keyFileFlag to hold the client key file pathOptionalstringThe keyFile holds the file path of the client key utilized for TLS verification
insecureSkipVerifyFlag to skip the tls certificates checksOptionalbooleanThe insecureSkipVerify skip the tls certificates checks

Definition

probe:
- name: "check-frontend-access-url"
type: "httpProbe"
httpProbe/inputs:
url: "https://google.com"
tlsConfig:
insecureSkipVerify: true
method:
get:
criteria: == # supports == & != and oneof operations
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

HTTP Get Request

The HTTP Get method involves sending an HTTP GET request to the provided URL and then assessing the response code against specified criteria (==, !=, oneOf). This can be accomplished by configuring the httpProbe/inputs.method.get field.

Use the following example to tune this:

# contains the http probes with get method and verify the response code
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
probe:
- name: "check-frontend-access-url"
type: "httpProbe"
httpProbe/inputs:
url: "frontend-service.default.svc.cluster.local"
method:
# call http get method and verify the response code
get:
# criteria which should be matched
criteria: == # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

HTTP Post Request(http body is a simple)

This section holds the HTTP body necessary for making an HTTP POST request, particularly suited for simple requests. The HTTP body content can be supplied in the 'body' field, and this can be initiated by configuring the httpProbe/inputs.method.post.body field.

Use the following example to tune this:

# contains the http probes with post method and verify the response code
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
probe:
- name: "send-data-to-backend"
type: "httpProbe"
httpProbe/inputs:
url: "backend.default.svc.cluster.local"
method:
# call http post method and verify the response code
post:
# value of the http body, used for the post request
body: "{\"name\":\"foo\",\"description\":\"bar\"}"
# http body content type
contentType: "application/json; charset=UTF-8"
# criteria which should be matched
criteria: "==" # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

HTTP Post Request(http body is a complex)

For complex POST requests with multi-line bodies, the 'bodyPath' attribute comes into play. It allows you to specify the path to a file containing the required body content. This file can be accessed by the experiment pod through a ConfigMap resource, with the ConfigMap name defined in either the ChaosEngine or the ChaosExperiment CR. To set this up, configure the httpProbe/inputs.method.post.body field.

Please note that it is mutually exclusive with the 'body' field. If 'body' is specified, it will be used for the POST request; otherwise, 'bodyPath' will be used.

Use the following example to tune this:

# contains the http probes with post method and verify the response code
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
probe:
- name: "send-data-to-backend"
type: "httpProbe"
httpProbe/inputs:
url: "backend.default.svc.cluster.local"
method:
# call http post method and verify the response code
post:
# the configMap should be mounted to the experiment which contains http body
# use the mounted path here
bodyPath: "/mnt/body.yml"
# http body content type
contentType: "application/json; charset=UTF-8"
# criteria which should be matched
criteria: "==" # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

Authentication

This establishes a fundamental authentication mechanism for the http endpoint. The username:password, encoded in base64 or bearer token should be placed either within the credentials field or as a file path in the credentialsFile field.

It's important to note that credentials and credentialsFile are two options that cannot be used simultaneously.

Use the following example to tune this:

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
probe:
- name: "send-data-to-backend"
type: "httpProbe"
httpProbe/inputs:
url: "backend.default.svc.cluster.local"
auth:
type: Basic
credentials: "dXNlcm5hbWU6cGFzc3dvcmQ="
method:
# call http post method and verify the response code
post:
# the configMap should be mounted to the experiment which contains http body
# use the mounted path here
bodyPath: "/mnt/body.yml"
# http body content type
contentType: "application/json; charset=UTF-8"
# criteria which should be matched
criteria: "==" # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

Headers

Headers for HTTP requests can be specified in a map format within the headers path.

Use the following example to tune this:

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
probe:
- name: "send-data-to-backend"
type: "httpProbe"
httpProbe/inputs:
url: "backend.default.svc.cluster.local"
headers:
Content-Type: application/json
auth:
type: Basic
credentials: "dXNlcm5hbWU6cGFzc3dvcmQ="
method:
# call http post method and verify the response code
post:
# the configMap should be mounted to the experiment which contains http body
# use the mounted path here
bodyPath: "/mnt/body.yml"
# http body content type
contentType: "application/json; charset=UTF-8"
# criteria which should be matched
criteria: "==" # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

TLS With Custom Certificates

It offers the mechanism to validate TLS certifications for the http endpoint. You can supply the cacert or the client certificate and client key, to perform the validation.

Please take note that the CA certificate file must be incorporated into the experiment pod as either a configMap or secret. The volume name (configMap or secret) and mountPath should be specified within the chaosengine at the spec.components.secrets path.

Use the following example to tune this:

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
components:
secrets:
- name: ca-cert
mountPath: /mnt
probe:
- name: "send-data-to-backend"
type: "httpProbe"
httpProbe/inputs:
url: "backend.default.svc.cluster.local"
tlsConfig:
caFile: "/mnt/ca.crt"
method:
# call http post method and verify the response code
post:
# the configMap should be mounted to the experiment which contains http body
# use the mounted path here
bodyPath: "/mnt/body.yml"
# http body content type
contentType: "application/json; charset=UTF-8"
# criteria which should be matched
criteria: "==" # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s

TLS Skip Certificate Verification

You can bypass the tls certificate checks by enabling the insecureSkipVerify option.

Use the following example to tune this:

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
name: engine-nginx
spec:
engineState: "active"
appinfo:
appns: "default"
applabel: "app=nginx"
appkind: "deployment"
chaosServiceAccount: litmus-admin
experiments:
- name: pod-delete
spec:
probe:
- name: "send-data-to-backend"
type: "httpProbe"
httpProbe/inputs:
url: "backend.default.svc.cluster.local"
tlsConfig:
insecureSkipVerify: true
method:
# call http post method and verify the response code
post:
# the configMap should be mounted to the experiment which contains http body
# use the mounted path here
bodyPath: "/mnt/body.yml"
# http body content type
contentType: "application/json; charset=UTF-8"
# criteria which should be matched
criteria: "==" # ==, !=, oneof
# exepected response code for the http request, which should follow the specified criteria
responseCode: "200"
mode: "Continuous"
runProperties:
probeTimeout: 5s
interval: 2s
attempt: 1
probePollingInterval: 2s