forked from hikhvar/mqtt2prometheus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support metrics from arithmetic expressions.
This change adds the new metric config option `expression` which can define a complex expression to calculate the final metric value. The expression is evaluated using github.com/antonmedv/expr as the engine, see expr-lang.org/docs/v1.9/Language-Definition for a language overview. In addition, some basic functions are available during evaluation: now, int, float, round, ceil, floor, abs, min, max. For each evaluation, the expression gets: - the current MQTT value - the last MQTT value - the result of the last evaluation - the elapsed time since the last evaluation Expressions allow more flexibility to derive metrics from sensor inputs which are very hard or even impossible to do in Prometheus, for example, integrate continuous values over time, filter extreme or zero values, or non-linear scaling. The last value, result, and timestamp are preserved even between restarts of mqtt2prometheus. This means that expressions can be used to produce continuous time series over a long time range. To make upstream integration easier, the code depends on the rather old v1.8.9 of github.com/antonmedv/expr, which is available in the main repo of all supported Debian versions.
- Loading branch information
Christian Schneider
committed
Dec 13, 2023
1 parent
5a21fb7
commit ab3a164
Showing
6 changed files
with
481 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.