HTTPChaos allows you to intercept and manipulate HTTP traffic to test how your application handles HTTP-level failures, delays, and data corruption.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/chaos-mesh/chaos-mesh/llms.txt
Use this file to discover all available pages before exploring further.
Supported Actions
HTTPChaos supports multiple HTTP manipulation actions:- abort: Abort HTTP connections
- delay: Add latency to HTTP requests or responses
- replace: Replace HTTP request/response content (path, method, status code, body, headers, queries)
- patch: Patch/append HTTP content (body, headers, queries)
Configuration
Basic Example
Spec Fields
Specifies the target pods for the chaos experiment. See PodChaos documentation for selector details.
Selection mode:
one, all, fixed, fixed-percent, or random-max-percentSpecifies whether to target requests or responses:
Request: Manipulate HTTP requestsResponse: Manipulate HTTP responses
Target port to proxy and inject chaos
URI path pattern to match. Supports wildcards (e.g.,
"/api/*", "*")HTTP method to match (e.g.,
GET, POST, PUT, DELETE)HTTP status code to match (only applicable when target is Response). Example:
200, 404, 500Request headers to match. Key-value pairs of header name and value.
Response headers to match. Key-value pairs of header name and value.
Duration of the chaos action. Format: “300ms”, “1.5h”, “2h45m”
Action Fields
If true, abort the HTTP connection
Delay to add to HTTP request/response. Format: “300ms”, “2s”. Valid units: ns, us, ms, s, m, h.
Replace HTTP request/response content
Patch/append HTTP request/response content
TLS configuration for HTTPS traffic
Remote cluster where chaos will be deployed
Examples
Patch Response Body
Replace JSON response with custom content:Add Response Delay
Add 2 second delay to all responses:Abort Connections
Abort HTTP connections to specific endpoint:Replace Status Code
Change successful responses to errors:Modify Request Headers
Add or replace request headers:Modify Query Parameters
Replace query parameters:Filter by Request Headers
Target only requests with specific headers:Use Cases
API Error Handling
Test how your application handles HTTP errors by replacing status codes or aborting connections.Latency Testing
Simulate slow API responses to test timeout handling and user experience under high latency.Data Corruption
Use patch or replace actions to inject malformed responses and test input validation.Authentication Testing
Modify authentication headers or tokens to test authorization and authentication error handling.Rate Limiting
Combine with delay to simulate rate-limited APIs and test backoff/retry logic.Best Practices
- Target Specificity: Use path, method, and header filters to target specific endpoints
- Start with Non-Critical Endpoints: Test on less critical API endpoints first
- Use Appropriate Target:
Requestfor testing client-side error handlingResponsefor testing server response processing
- Monitor Application Behavior: Watch for:
- Timeout errors
- Retry loops
- Circuit breaker activation
- Error logging
- TLS Configuration: For HTTPS services, properly configure TLS secrets
- Body Patching: When using JSON patch, ensure the patch is valid according to RFC 7396
- Header Format: Use arrays of arrays for patch operations to support multiple headers with same name
- Realistic Delays: Use delays that match real-world scenarios (100ms-2s for API calls)
- Test Error Propagation: Verify errors are properly propagated through your service mesh or API gateway
Notes
- HTTPChaos uses a transparent proxy (tproxy) to intercept HTTP traffic
- The chaos daemon runs a proxy process inside the target pod’s network namespace
- Only HTTP/1.x traffic is supported (HTTP/2 support may vary)
- TLS inspection requires proper certificate configuration via the
tlsfield - Path matching supports wildcards but not full regex
- Multiple HTTPChaos experiments on the same pod/port can conflict
- The proxy adds minimal overhead but may affect high-throughput services
- Body replacement happens in memory - very large bodies may impact performance
- Query parameter replacement replaces the entire query string, patch appends to it