mirror of
https://github.com/hikhvar/mqtt2prometheus.git
synced 2026-02-14 18:09:53 +00:00
scale as a multiplier
This commit is contained in:
@@ -96,7 +96,7 @@ func (p *Parser) parseMetric(metricPath string, deviceID string, value interface
|
||||
}
|
||||
|
||||
if cfg.MQTTValueScale != 0 {
|
||||
metricValue = metricValue / cfg.MQTTValueScale
|
||||
metricValue = metricValue * cfg.MQTTValueScale
|
||||
}
|
||||
|
||||
return Metric{
|
||||
|
||||
@@ -59,7 +59,7 @@ func TestParser_parseMetric(t *testing.T) {
|
||||
{
|
||||
PrometheusName: "temperature",
|
||||
ValueType: "gauge",
|
||||
MQTTValueScale: 100,
|
||||
MQTTValueScale: 0.01,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -129,7 +129,7 @@ func TestParser_parseMetric(t *testing.T) {
|
||||
{
|
||||
PrometheusName: "humidity",
|
||||
ValueType: "gauge",
|
||||
MQTTValueScale: 100,
|
||||
MQTTValueScale: 0.01,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -155,7 +155,7 @@ func TestParser_parseMetric(t *testing.T) {
|
||||
{
|
||||
PrometheusName: "humidity",
|
||||
ValueType: "gauge",
|
||||
MQTTValueScale: -0.5,
|
||||
MQTTValueScale: -2,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -206,7 +206,7 @@ func TestParser_parseMetric(t *testing.T) {
|
||||
{
|
||||
PrometheusName: "enabled",
|
||||
ValueType: "gauge",
|
||||
MQTTValueScale: 2,
|
||||
MQTTValueScale: 0.5,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user