From 7d15e15d8adc36401d65f5fb1079cc8770f3bf53 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann Date: Sat, 17 Jul 2021 09:17:19 +0200 Subject: [PATCH] prometheus: Fix wrong format on ESP32, incorrect names in types When built for ESP32 the memory fragmentation metric was incorrectly terminated (likely a typo). The type information for "tasmota_global_humidity_percentage" didn't include the "_percentage" and "tasmota_sensors" wsa incorrect too. Signed-off-by: Michael Hanselmann --- tasmota/xsns_75_prometheus.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasmota/xsns_75_prometheus.ino b/tasmota/xsns_75_prometheus.ino index f15c569f6..2a560c743 100644 --- a/tasmota/xsns_75_prometheus.ino +++ b/tasmota/xsns_75_prometheus.ino @@ -113,7 +113,7 @@ void HandleMetrics(void) { } if (TasmotaGlobal.humidity != 0) { dtostrfd(TasmotaGlobal.humidity, Settings->flag2.humidity_resolution, parameter); - WSContentSend_P(PSTR("# TYPE tasmota_global_humidity gauge\ntasmota_global_humidity_percentage %s\n"), parameter); + WSContentSend_P(PSTR("# TYPE tasmota_global_humidity_percentage gauge\ntasmota_global_humidity_percentage %s\n"), parameter); } if (TasmotaGlobal.pressure_hpa != 0) { dtostrfd(TasmotaGlobal.pressure_hpa, Settings->flag2.pressure_resolution, parameter); @@ -124,7 +124,7 @@ void HandleMetrics(void) { #ifdef ESP32 int32_t freeMaxMem = 100 - (int32_t)(ESP_getMaxAllocHeap() * 100 / ESP_getFreeHeap()); WSContentSend_PD(PSTR("# TYPE tasmota_memory_bytes gauge\ntasmota_memory_bytes{memory=\"Ram\"} %d\n"), ESP_getFreeHeap()); - WSContentSend_PD(PSTR("# TYPE tasmota_memory_ratio gauge\ntasmota_memory_ratio{memory=\"Fragmentation\"} %d)"), freeMaxMem / 100); + WSContentSend_PD(PSTR("# TYPE tasmota_memory_ratio gauge\ntasmota_memory_ratio{memory=\"Fragmentation\"} %d\n"), freeMaxMem / 100); if (UsePSRAM()) { WSContentSend_P(PSTR("# TYPE tasmota_memory_bytes gauge\ntasmota_memory_bytes{memory=\"Psram\"} %d\n"), ESP.getFreePsram() ); } @@ -196,7 +196,7 @@ void HandleMetrics(void) { const char *value = value1.getStr(nullptr); String sensor = FormatMetricName(key1.getStr()); if (value != nullptr && isdigit(value[0] && strcmp(sensor.c_str(), "time") != 0)) { //remove false 'time' metric - WSContentSend_P(PSTR("# TYPE tasmota_sensors_%s gauge\ntasmota_sensors{sensor=\"%s\"} %s\n"), sensor.c_str(), sensor.c_str(), value); + WSContentSend_P(PSTR("# TYPE tasmota_sensors gauge\ntasmota_sensors{sensor=\"%s\"} %s\n"), sensor.c_str(), value); } } }