Skip to content

HTTP Probe

The http probe allows developers to specify a URL which the experiment uses to gauge health/service availability (or other custom conditions) as part of the entry/exit criteria. The received status code is mapped against an expected status. It supports http Get and Post methods. It can be executed by setting type as httpProbe inside .spec.experiments[].spec.probe.

View the http probe schema

Field .name
Description Flag to hold the name of the probe
Type Mandatory
Range n/a (type: string)
Notes The .name holds the name of the probe. It can be set based on the usecase

Field .type
Description Flag to hold the type of the probe
Type Mandatory
Range httpProbe, k8sProbe, cmdProbe, promProbe
Notes The .type supports four type of probes. It can one of the httpProbe, k8sProbe, cmdProbe, promProbe

Field .mode
Description Flag to hold the mode of the probe
Type Mandatory
Range SOT, EOT, Edge, Continuous, OnChaos
Notes The .mode supports five modes of probes. It can one of the SOT, EOT, Edge, Continuous, OnChaos

Field .httpProbe/inputs.url
Description Flag to hold the URL for the httpProbe
Type Mandatory
Range n/a {type: string}
Notes The .httpProbe/inputs.url contains the URL which the experiment uses to gauge health/service availability (or other custom conditions) as part of the entry/exit criteria.

Field .httpProbe/inputs.insecureSkipVerify
Description Flag to hold the flag to skip certificate checks for the httpProbe
Type Optional
Range true, false
Notes The .httpProbe/inputs.insecureSkipVerify contains flag to skip certificate checks.

Field .httpProbe/inputs.responseTimeout
Description Flag to hold the flag to response timeout for the httpProbe
Type Optional
Range n/a {type: integer}
Notes The .httpProbe/inputs.responseTimeout contains flag to provide the response timeout for the http Get/Post request.

Field .httpProbe/inputs.method.get.criteria
Description Flag to hold the criteria for the http get request
Type Mandatory
Range ==, !=, oneOf
Notes The .httpProbe/inputs.method.get.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

Field .httpProbe/inputs.method.get.responseCode
Description Flag to hold the expected response code for the get request
Type Mandatory
Range HTTP_RESPONSE_CODE
Notes The .httpProbe/inputs.method.get.responseCode contains the expected response code for the http get request as part of httpProbe run

Field .httpProbe/inputs.method.post.contentType
Description Flag to hold the content type of the post request
Type Mandatory
Range n/a {type: string}
Notes The .httpProbe/inputs.method.post.contentType contains the content type of the http body data, which need to be passed for the http post request

Field .httpProbe/inputs.method.post.body
Description Flag to hold the body of the http post request
Type Mandatory
Range n/a {type: string}
Notes The .httpProbe/inputs.method.post.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 .httpProbe/inputs.method.post.bodyPath field.

Field .httpProbe/inputs.method.post.bodyPath
Description Flag to hold the path of the http body, required for the http post request
Type Optional
Range n/a {type: string}
Notes The .httpProbe/inputs.method.post.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.

Field .httpProbe/inputs.method.post.criteria
Description Flag to hold the criteria for the http post request
Type Mandatory
Range ==, !=, oneOf
Notes The .httpProbe/inputs.method.post.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

Field .httpProbe/inputs.method.post.responseCode
Description Flag to hold the expected response code for the post request
Type Mandatory
Range HTTP_RESPONSE_CODE
Notes The .httpProbe/inputs.method.post.responseCode contains the expected response code for the http post request as part of httpProbe run

Field .runProperties.probeTimeout
Description Flag to hold the timeout for the probes
Type Mandatory
Range n/a {type: integer}
Notes The .runProperties.probeTimeout represents the time limit for the probe to execute the specified check and return the expected data

Field .runProperties.retry
Description Flag to hold the retry count for the probes
Type Mandatory
Range n/a {type: integer}
Notes The .runProperties.retry contains the number of times a check is re-run upon failure in the first attempt before declaring the probe status as failed.

Field .runProperties.interval
Description Flag to hold the interval for the probes
Type Mandatory
Range n/a {type: integer}
Notes The .runProperties.interval contains the interval for which probes waits between subsequent retries

Field .runProperties.probePollingInterval
Description Flag to hold the polling interval for the probes(applicable for Continuous mode only)
Type Optional
Range n/a {type: integer}
Notes The .runProperties.probePollingInterval contains the time interval for which continuous probe should be sleep after each iteration

Field .runProperties.initialDelaySeconds
Description Flag to hold the initial delay interval for the probes
Type Optional
Range n/a {type: integer}
Notes The .runProperties.initialDelaySeconds represents the initial waiting time interval for the probes.

Field .runProperties.stopOnFailure
Description Flags to hold the stop or continue the experiment on probe failure
Type Optional
Range false {type: boolean}
Notes The .runProperties.stopOnFailure can be set to true/false to stop or continue the experiment execution after probe fails

Common Probe Tunables

Refer the common attributes to tune the common tunables for all the probes.

HTTP Get Request

In HTTP Get method, it sends an http GET request to the provided URL and matches the response code based on the given criteria(==, !=, oneOf). It can be executed by setting 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: pod-delete-sa
  experiments:
  - name: pod-delete
    spec:
      probe:
      - name: "check-frontend-access-url"
        type: "httpProbe"
        httpProbe/inputs:
          url: "<url>"
          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: "<response code>"
        mode: "Continuous"
        runProperties:
          probeTimeout: 5 
          interval: 2 
          retry: 1
          probePollingInterval: 2

HTTP Post Request(http body is a simple)

It contains the http body, which is required for the http post request. It is used for the simple http body. The http body can be provided in the body field. It can be executed by setting 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: pod-delete-sa
  experiments:
  - name: pod-delete
    spec:
      probe:
      - name: "check-frontend-access-url"
        type: "httpProbe"
        httpProbe/inputs:
          url: "<url>"
          method:
            # call http post method and verify the response code
            post: 
              # value of the http body, used for the post request
              body: "<http-body>"
              # 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: 5 
          interval: 2 
          retry: 1
          probePollingInterval: 2

HTTP Post Request(http body is a complex)

In the case of a 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. It can be executed by setting httpProbe/inputs.method.post.body field.

NOTE: It is mutually exclusive with the body field. If body is set then it will use the body field for the post request otherwise, it will use the bodyPath 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: pod-delete-sa
  experiments:
  - name: pod-delete
    spec:
      probe:
      - name: "check-frontend-access-url"
        type: "httpProbe"
        httpProbe/inputs:
          url: "<url>"
          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: 5 
          interval: 2 
          retry: 1
          probePollingInterval: 2

Response Timout

It contains a flag to provide the response timeout for the http Get/Post request. It can be tuned via .httpProbe/inputs.responseTimeout field. It is an optional field and its unit is milliseconds.

Use the following example to tune this:

# defines the response timeout for the http probe
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
  name: engine-nginx
spec:
  engineState: "active"
  appinfo:
    appns: "default"
    applabel: "app=nginx"
    appkind: "deployment"
  chaosServiceAccount: pod-delete-sa
  experiments:
  - name: pod-delete
    spec:
      probe:
      - name: "check-frontend-access-url"
        type: "httpProbe"
        httpProbe/inputs:
          url: "<url>"
          # timeout for the http requests
          responseTimeout: 100 #in ms
          method:
            get: 
              criteria: == # ==, !=, oneof
              responseCode: "<response code>"
        mode: "Continuous"
        runProperties:
          probeTimeout: 5 
          interval: 2 
          retry: 1
          probePollingInterval: 2

Skip Certification Check

It contains flag to skip certificate checks. It can bed tuned via .httpProbe/inputs.insecureSkipVerify field. It supports boolean values. Provide it to true to skip the certificate checks. Its default value is false.

Use the following example to tune this:

# skip the certificate checks for the httpProbe
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
  name: engine-nginx
spec:
  engineState: "active"
  appinfo:
    appns: "default"
    applabel: "app=nginx"
    appkind: "deployment"
  chaosServiceAccount: pod-delete-sa
  experiments:
  - name: pod-delete
    spec:
      probe:
      - name: "check-frontend-access-url"
        type: "httpProbe"
        httpProbe/inputs:
          url: "<url>"
          # skip certificate checks for the httpProbe
          # supports: true, false. default: false
          insecureSkipVerify: "true"
          method:
            get: 
              criteria: == 
              responseCode: "<response code>"
        mode: "Continuous"
        runProperties:
          probeTimeout: 5 
          interval: 2 
          retry: 1
          probePollingInterval: 2