Correlation & extraction
Traffic modellingThe bread and butter of stateful load tests: extract a value (JSONPath / regex / header) from a response and reuse it downstream — login → token → authorised call.
Browse all 52 demos 12 categories
No demos match.
$ loadr run examples/06-correlation.yaml
# Correlation: extract values from earlier responses (regex, CSS selector,
# JSONPath, headers, boundary) and reuse them in later requests.
name: correlation
description: extract CSRF + session values and chain requests
defaults:
http:
base_url: https://shop.example.com
scenarios:
checkout:
executor: constant-vus
vus: 3
duration: 1m
flow:
- request:
name: form page
url: /checkout/start
extract:
# CSRF token hidden in the HTML form
- { type: css, name: csrf, expression: "input[name=csrf]", attribute: value }
# The same, JMeter-boundary style (first match wins; default if absent)
- { type: boundary, name: trace_id, left: 'data-trace="', right: '"', default: none }
# A response header
- { type: header, name: request_id, header: X-Request-Id }
- request:
name: submit
method: POST
url: /checkout/submit
headers:
X-Parent-Request: ${request_id}
body:
form:
csrf: ${csrf}
trace: ${trace_id}
extract:
- { type: jsonpath, name: order_id, expression: "$.order.id" }
assert:
- { type: status, equals: 200 }
- request:
name: order status
url: /orders/${order_id}
checks:
- { type: jsonpath, name: order is pending, expression: "$.status", equals: pending }View raw: examples/06-correlation.yaml
What it shows
- ▸
extractwith JSONPath / regex / header - ▸Reuse via
${var}in later requests - ▸Per-VU variable scope