C
CloudWatch
Observability collectors availablePutMetricData to AWS CloudWatch, and pull metrics back to correlate.
$ loadr plugin install cloudwatch
# Stream loadr's live metrics into Amazon CloudWatch, driven by the
# `loadr-plugin-cloudwatch` 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 converts each snapshot's series into CloudWatch metric
# data and ships it straight to the regional monitoring endpoint with a single
# SigV4-signed `PutMetricData` POST — no per-second buffering, no CloudWatch
# agent, no StatsD hop. The transport is pure hyper + hyper-rustls plus a
# pure-Rust SigV4 signer, so nothing beyond AWS credentials and outbound HTTPS
# is required.
#
# Metrics arrive under the configured namespace (default `loadr`), e.g.
# `http_reqs` (Count), `vus` (gauge), `checks` (rate pass fraction) and
# `http_req_duration.p95` (gauge), each carrying the series' tags plus the
# global `dimensions` below and the run's `run_id` as dimensions.
#
# Credentials come from the standard AWS environment chain
# (AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY / AWS_SESSION_TOKEN); grant them
# `cloudwatch:PutMetricData` and keep them out of the plan file.
#
# Build + install the plugin, then run:
# cargo build -p loadr-plugin-cloudwatch --release
# mkdir -p dist && cp plugins/loadr-plugin-cloudwatch/plugin.toml dist/ \
# && cp target/release/libloadr_plugin_cloudwatch.so dist/
# loadr plugin install dist
# AWS_ACCESS_KEY_ID=... AWS_SECRET_ACCESS_KEY=... AWS_REGION=eu-west-2 \
# loadr run examples/plugins/cloudwatch.yaml
name: cloudwatch-export
description: Export live loadr metrics to Amazon CloudWatch via PutMetricData
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 `cloudwatch` by name from the plugins dir (after `loadr plugin install`).
- type: plugin
name: cloudwatch
config:
# CloudWatch namespace every metric is published under.
namespace: loadr/checkout
# AWS region whose monitoring endpoint receives the data. Falls back to the
# AWS_REGION environment variable when omitted; one of the two is required.
region: eu-west-2
# Extra dimensions attached to every metric, merged with each series' tags
# and the run's run_id.
dimensions:
env: staging
service: checkout
# Max metric data points per PutMetricData call (CloudWatch caps this at
# 1000); a snapshot with more series is split across several requests.
batch_size: 1000
# Optional endpoint override for an S3-compatible / VPC endpoint or a local
# LocalStack. Defaults to https://monitoring.<region>.amazonaws.com/.
# endpoint: http://localhost:4566
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 cloudwatch.