k6/metrics module provides classes for creating custom metrics.
Metric Types
Counter
A metric that cumulatively sums added values.string
Metric name (must be unique)
boolean
Whether the metric represents time values
add(value, [tags])
Adds a value to the counter.number
Value to add
object
Custom tags for this data point
Gauge
A metric that stores the latest value added to it.string
Metric name (must be unique)
boolean
Whether the metric represents time values
add(value, [tags])
Sets the gauge to the specified value.Rate
A metric that tracks the percentage of added values that are non-zero.string
Metric name (must be unique)
boolean
Whether the metric represents time values
add(value, [tags])
Adds a boolean or numeric value to the rate.Trend
A metric that calculates statistics (min, max, avg, percentiles) on added values.string
Metric name (must be unique)
boolean
Whether the metric represents time values (enables time-based formatting)