W

Webhook

Outputs & exporters available

POST run snapshots/summary as JSON to any HTTP endpoint.

Install
$ loadr plugin install webhook
examples/plugins/webhook.yaml
# Stream loadr's live metrics to any HTTP endpoint, driven by the
# `loadr-plugin-webhook` native OUTPUT plugin.
#
# An output plugin follows the same start / on_snapshot / finish lifecycle as
# the built-in exporters: loadr calls `start(config)` once, hands the plugin a
# metric snapshot roughly once a second during the run, then `finish(summary)`
# at the end. This plugin wraps each payload in a small JSON envelope and POSTs
# it to the configured `url`:
#
#   { "event": "snapshot", "run_id": "…", "snapshot": { … } }   # one per second
#   { "event": "summary",  "run_id": "…", "summary":  { … } }   # once at the end
#
# The transport is pure hyper + hyper-rustls — no SDK, no message broker — so
# nothing beyond an HTTP endpoint and outbound network access is required.
# `Content-Type: application/json` is always set; when `hmac_secret` is given,
# each request is signed with `HMAC-SHA256(secret, body)` in the
# `X-Loadr-Signature` header (hex) so the receiver can verify the payload.
#
# Build + install the plugin, then run:
#   cargo build -p loadr-plugin-webhook --release
#   mkdir -p dist && cp plugins/loadr-plugin-webhook/plugin.toml dist/ \
#     && cp target/release/libloadr_plugin_webhook.so dist/
#   loadr plugin install dist
#   WEBHOOK_TOKEN=xxxx WEBHOOK_HMAC=yyyy loadr run examples/plugins/webhook.yaml
name: webhook-export
description: POST live loadr metrics to an arbitrary HTTP endpoint

defaults:
  http:
    base_url: https://api.example.com

scenarios:
  browse:
    executor: ramping-vus
    stages:
      - { target: 20, duration: 30s }
      - { target: 20, duration: 2m }
      - { target: 0, duration: 30s }
    flow:
      - request: { name: list, url: /api/v1/items }
      - request:
          name: detail
          url: /api/v1/items/1
          checks: [ { type: status, equals: 200 } ]

outputs:
  # Resolve `webhook` by name from the plugins dir (after `loadr plugin install`).
  - type: plugin
    name: webhook
    config:
      # Required. Must be http(s)://…; a bad URL fails start() before the run.
      url: https://hooks.example.com/loadr
      # Static headers added to every request. Values interpolate (${env.…}), so
      # pull secrets from the environment — never hard-code them in a plan.
      headers:
        X-Source: loadr
        Authorization: "Bearer ${env.WEBHOOK_TOKEN}"
      # Optional payload signing. When set, each body is signed with
      # HMAC-SHA256 and the hex digest is sent as `X-Loadr-Signature`.
      hmac_secret: "${env.WEBHOOK_HMAC}"
      # Per-request timeout: a duration string ("5s", "500ms", "1m") or a bare
      # number of seconds. A slow endpoint is abandoned and counted as an error,
      # never stalling the load generator. Default 5s.
      timeout: 5s

thresholds:
  http_req_failed: [ "rate<0.02" ]
  http_req_duration: [ "p(95)<600" ]

A real run: install from the signed index, then watch the plugin work.

A runtime plugin, never in the binary

Installing pulls a per-platform driver from the signed index, verifies its SHA-256 and checks its ABI before it ever loads. Remove it any time with loadr plugin remove webhook.