Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/testing-guides/injecting-faults-with-xk6-disruptor/xk6-disruptor/faults/http.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/testing-guides/injecting-faults-with-xk6-disruptor/xk6-disruptor/faults/http/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
HTTP
A HTTP Fault describes the characteristics of the faults to be injected in the HTTP requests served by a target.
A HTTP fault is described by the following attributes:
| Attribute | Type | Description |
|---|---|---|
| averageDelay | string | average delay added to requests represented as a string (default 0) |
| delayVariation | string | variation in the injected delay (default 0) |
| errorBody | string | body to be returned when an error is injected |
| errorCode | number | error code to return |
| errorRate | number | rate of requests that will return an error, represented as a float in the range 0.0 to 1.0 (default 0.0) |
| exclude | string | comma-separated list of urls to be excluded from disruption (e.g. /health) |
| port | number | port on which the requests will be intercepted |
Note
averageDelayanddelayVariationare applied to all requests affected by the fault, regardless of the value oferrorRate.errorCodeis returned only to a fraction of requests defined byerrorRate.
Example
This example defines a HTTP fault that introduces a delay of 50ms in all requests and returns an error code 500 in 10% of the requests.
const fault = {
averageDelay: '50ms',
errorCde: 500,
errorRate: 0.1,
};Was this page helpful?
Related resources from Grafana Labs

