prometheus.Counter.inc()
Increases the counter by one for the specified label values.
Syntax
Note:
In this syntax diagram, the square brackets ([ ]) are part of the syntax.
inc( [ labels ] )
- labels is a comma-separated list of label values inside
square brackets, one for each label name declared when the metric was created, in the same order.
Where the metric declares no label names, use empty brackets
[].
Usage
Use the prometheus.Counter.inc() method to increment the value of a
counter metric by one. Counters can only increase. The label values change from one call to the
next. For example, with the label name ["action"] declared,
inc(["edit"]) counts an edit and inc(["sql"]) counts a query.
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 display 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
CALL counter.inc(["edit"])
CLOSE FORM e
ON ACTION sql
-- Execute SQL query
CALL counter.inc(["sql"])
ON ACTION cancel
EXIT DISPLAY
END DISPLAY
END MAIN