prometheus.Gauge.create()
Creates a new gauge metric with the specified name, description, and labels.
Syntax
In this syntax diagram, the square brackets ([ ]) are part of the syntax.
prometheus.Gauge.create(
name STRING,
description STRING,
[ labels ] )
RETURNS prometheus.Gauge
- name: The name of the gauge (no spaces allowed).
- description: A description of the purpose of the gauge.
- labels is a comma-separated list of label names inside square
brackets that define the metric's dimensions. A label name cannot be empty. For example, a metric
created with
["method","endpoint"]has two dimensions. Where the metric needs no dimensions, use empty brackets[].
Usage
Use the prometheus.Gauge.create() method to create a new gauge metric. The
labels parameter defines the dimensions for the metric, such as endpoints or
resources to track.
Choose label names whose values come from a small set you can name in advance, such as a category, a status, or an outcome. Avoid a label name whose values are unbounded, such as an order number or a user name. Each combination of label values creates its own series, so such a label produces one series per order or per user, which cannot be aggregated into anything useful. The metric also grows until it exhausts the Prometheus server.
Example
IMPORT prometheus
-- Import the Prometheus API
-- Define the gauge variable
DEFINE gauge prometheus.Gauge
-- Create a gauge metric with one label
LET gauge = prometheus.Gauge.create("gauge_basket_items", "items in the basket",
["category"])