Skip to content

fault_injection ​

fault_injection delays or fails a share of requests, to test how clients and other services cope with slow and failing dependencies.

yaml
server:
  http:
    middlewares:
      chaos:
        fault_injection:
          delay:
            duration: 2s
            jitter: 500ms
            percent: 10
          abort:
            status_code: 503
            percent: 5
          header: X-Fault-Inject
          paths:
            - /api
FieldDefaultDescription
delay.durationTime a delayed request waits before it continues.
delay.jitterRandom time up to this value added to duration.
delay.percentShare of requests delayed, 0 to 100.
abort.status_code503Status of aborted requests.
abort.percentShare of requests aborted, 0 to 100.
headerOnly requests with this header get faults.
pathsOnly these path prefixes get faults.

At least delay or abort is required. A request can be both delayed and then aborted.

With header, requests without the header or with false are not touched. A number between 0 and 100 sets the percent for that request, e.g. X-Fault-Inject: 100 always fails it. Any other value uses the configured percent.

Aborted responses carry X-Fault-Injected: abort.

WARNING

Do not leave fault_injection without header on production routes.