Menu
Choose a product
Viewing: v1.7.x (latest)
Find another version
Scroll for more
Open source
Gauge
Gauge is an object for representing a custom metric holding only the latest value added. It’s one of the four metric types.
| Parameter | Type | Description |
|---|---|---|
name | string | The name of the custom metric. |
isTime | boolean | A boolean indicating whether the values added to the metric are time values or just untyped values. |
| Method | Description |
|---|---|
| Gauge.add(value, [tags]) | Add a value to the gauge metric. Only the latest value added will be kept. |
Gauge usage in Thresholds
When gauge is used in a threshold expression, the variable must be called value (lower case).
For example:
value < 200value > 1
Examples
JavaScript
JavaScript
import { Gauge } from 'k6/metrics';
const myGauge = new Gauge('my_gauge');
export default function () {
myGauge.add(3);
myGauge.add(1);
myGauge.add(2, { tag1: 'value', tag2: 'value2' });
}JavaScript
JavaScript
import http from 'k6/http';
import { sleep } from 'k6';
import { Gauge } from 'k6/metrics';
const GaugeContentSize = new Gauge('ContentSize');
export const options = {
thresholds: {
ContentSize: ['value<4000'],
},
};
export default function () {
const res = http.get('https://quickpizza.grafana.com');
GaugeContentSize.add(res.body.length);
sleep(1);
}Was this page helpful?
Related resources from Grafana Labs
Additional helpful documentation, links, and articles:
Video

Performance testing and observability in Grafana Cloud
Optimize user experiences with Grafana Cloud. Learn real-time insights, performance testing with k6, and continuous validation with Synthetic Monitoring.
Events

User-centered observability: load testing, real user monitoring, and synthetics
Learn how to use load testing, synthetic monitoring, and real user monitoring (RUM) to understand end users' experience of your apps. Watch on demand.