mirror of
https://github.com/hikhvar/mqtt2prometheus.git
synced 2026-02-14 09:59:52 +00:00
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.
16 lines
409 B
Modula-2
16 lines
409 B
Modula-2
module github.com/hikhvar/mqtt2prometheus
|
|
|
|
go 1.14
|
|
|
|
require (
|
|
github.com/antonmedv/expr v1.8.9
|
|
github.com/eclipse/paho.mqtt.golang v1.3.5
|
|
github.com/go-kit/kit v0.10.0
|
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
|
github.com/prometheus/client_golang v1.11.1
|
|
github.com/prometheus/exporter-toolkit v0.7.3
|
|
github.com/thedevsaddam/gojsonq/v2 v2.5.2
|
|
go.uber.org/zap v1.16.0
|
|
gopkg.in/yaml.v2 v2.4.0
|
|
)
|