Custom Metrics¶
You can define at configuration time your own metrics that can be updated using Lua.
The first step is to declare a new metric using declareMetric()
.
Then you can update those at runtime using the following functions, depending on the metric type:
- manipulate counters using
incMetric()
anddecMetric()
- update a gauge using
setMetric()
-
declareMetric
(name, type, description[, prometheusName]) → bool¶ New in version 1.8.0.
Return true if declaration was successful
Parameters: - name (str) – The name of the metric, lowercase alphanumerical characters and dashes (-) only
- type (str) – The desired type in
gauge
orcounter
- name – The description of the metric
- prometheusName (str) – The name to use in the prometheus metrics, if supplied. Otherwise the regular name will be used, prefixed with
dnsdist_
and-
replaced by_
.
-
incMetric
(name) → int¶ New in version 1.8.0.
Increment counter by one, will issue an error if the metric is not declared or not a
counter
Return the new valueParameters: name (str) – The name of the metric
-
decMetric
(name) → int¶ New in version 1.8.0.
Decrement counter by one, will issue an error if the metric is not declared or not a
counter
Return the new valueParameters: name (str) – The name of the metric
-
getMetric
(name) → double¶ New in version 1.8.0.
Get metric value
Parameters: name (str) – The name of the metric
-
setMetric
(name, value) → double¶ New in version 1.8.0.
Set the new value, will issue an error if the metric is not declared or not a
gauge
Return the new valueParameters: name (str) – The name of the metric