How thresholds work
Thresholds evaluate metrics against specified conditions. Common examples include:- Less than 1% of requests return errors
- 95% of requests complete within 200ms
- 99% of requests complete within 400ms
- Specific endpoints always respond within 300ms
Basic example
This test defines two thresholds:Threshold syntax
Thresholds use this format:Threshold expressions
A threshold expression has three parts:avg < 200- Average duration must be less than 200mscount >= 500- Count must be at least 500p(90) < 300- 90th percentile must be below 300ms
Aggregation methods by metric type
Different metric types support different aggregation methods:- Counter
- Gauge
- Rate
- Trend
Common threshold examples
Error rate threshold
Ensure error rate stays below 1%:Response time threshold
Ensure 90% of requests complete within 400ms:Multiple thresholds on one metric
Define different requirements for different percentiles:Thresholds with custom metrics
You can set thresholds on custom metrics:Thresholds on tagged metrics
Set thresholds for specific tagged requests:Thresholds on groups
Set thresholds for specific groups:Abort test when threshold fails
Stop the test immediately when a threshold fails:The
delayAbortEval property prevents premature test abortion by waiting for enough samples to be collected.Fail test using checks
Combine checks with thresholds to fail tests based on check results:Thresholds on specific checks
Use tags to set thresholds for specific checks:Complete example
Here’s a comprehensive example combining multiple threshold patterns:Best practices
Start with SLOs
Base thresholds on your Service Level Objectives, not arbitrary numbers.
Use multiple percentiles
Don’t rely on averages alone. Check p95, p99, and max values.
Tag for granularity
Use tags to set different thresholds for different request types.
Delay abort evaluation
Use delayAbortEval to prevent premature test abortion.