prometheus.Counter.create()
Creates a new counter metric with the specified name, description, and labels.
Syntax
Note:
In this syntax diagram, the square brackets ([ ]) are part of the syntax.
create(
name STRING,
description STRING,
[ labels ] )
RETURNS prometheus.Counter
- name is the name of the counter (no spaces allowed).
- description is a description of the purpose of the counter.
- 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 this method to create a new counter 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
DEFINE counter prometheus.Counter
DEFINE product DYNAMIC ARRAY OF RECORD
name STRING,
price MONEY(5, 2)
END RECORD
MAIN
-- Create a counter metric with one label for the actions
LET counter = prometheus.Counter.create("counter_dialog_use", "count dialog use",
["action"])
# ... program code
DISPLAY ARRAY product TO sr_p.* ATTRIBUTES(UNBUFFERED)
ON ACTION edit
OPEN FORM e FROM "edit"
DISPLAY FORM e
-- code to handle form actions
CLOSE FORM e
ON ACTION sql
-- Execute SQL query
ON ACTION cancel
EXIT DISPLAY
END DISPLAY
END MAIN