From ecfefc6041494f5ce6b2ef208ac4361f8ac9ec79 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Sat, 25 Mar 2023 20:23:01 +0100 Subject: [PATCH 1/6] Add uptime to Prometheus metrics --- src/web/web.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/web/web.h b/src/web/web.h index 46e5ccb7..7612b6b9 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -681,8 +681,13 @@ class Web { mApp->getVersion(), mConfig->sys.deviceName); metrics = String(type) + String(topic); - snprintf(topic,sizeof(topic),"# TYPE ahoy_solar_freeheap gauge\nahoy_solar_freeheap{devicename=\"%s\"} %u\n",mConfig->sys.deviceName,ESP.getFreeHeap()); - metrics += String(topic); + snprintf(type,sizeof(type),"# TYPE ahoy_solar_freeheap gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_freeheap{devicename=\"%s\"} %u\n",mConfig->sys.deviceName,ESP.getFreeHeap()); + metrics += String(type) + String(topic); + + snprintf(type,sizeof(type),"# TYPE ahoy_solar_uptime counter\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_uptime{devicename=\"%s\"} %u\n", mApp->getUptime()); + metrics += String(type) + String(topic); // NRF Statistics stat = mApp->getStatistics(); @@ -789,7 +794,7 @@ class Web { String radioStatistic(String statistic, uint32_t value) { char type[60], topic[80], val[25]; - snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s gauge",statistic.c_str()); + snprintf(type, sizeof(type), "# TYPE ahoy_solar_radio_%s counter",statistic.c_str()); snprintf(topic, sizeof(topic), "ahoy_solar_radio_%s",statistic.c_str()); snprintf(val, sizeof(val), "%d", value); return ( String(type) + "\n" + String(topic) + " " + String(val) + "\n"); From 380f86cda1b7ca85621a51dc02109d3bd11ef709 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Sat, 25 Mar 2023 20:42:22 +0100 Subject: [PATCH 2/6] Add missing argument for devicename --- src/web/web.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/web.h b/src/web/web.h index 7612b6b9..a7e455b3 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -686,7 +686,7 @@ class Web { metrics += String(type) + String(topic); snprintf(type,sizeof(type),"# TYPE ahoy_solar_uptime counter\n"); - snprintf(topic,sizeof(topic),"ahoy_solar_uptime{devicename=\"%s\"} %u\n", mApp->getUptime()); + snprintf(topic,sizeof(topic),"ahoy_solar_uptime{devicename=\"%s\"} %u\n", mConfig->sys.deviceName, mApp->getUptime()); metrics += String(type) + String(topic); // NRF Statistics From e2f8b7bea3f1f2b7cb769c580c9a59f4e84b19dd Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Sat, 25 Mar 2023 21:35:55 +0100 Subject: [PATCH 3/6] Also add RSSI metric --- src/web/web.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/web/web.h b/src/web/web.h index a7e455b3..0d780007 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -689,6 +689,10 @@ class Web { snprintf(topic,sizeof(topic),"ahoy_solar_uptime{devicename=\"%s\"} %u\n", mConfig->sys.deviceName, mApp->getUptime()); metrics += String(type) + String(topic); + snprintf(type,sizeof(type),"# TYPE ahoy_solar_wifi_rssi_db gauge\n"); + snprintf(topic,sizeof(topic),"ahoy_solar_wifi_rssi_db{devicename=\"%s\"} %d\n", mConfig->sys.deviceName, WiFi.RSSI()); + metrics += String(type) + String(topic); + // NRF Statistics stat = mApp->getStatistics(); metrics += radioStatistic(F("rx_success"), stat->rxSuccess); From 7c449b67d4e4793b33533059da04246b16dd4954 Mon Sep 17 00:00:00 2001 From: Tobias Wolf Date: Sat, 25 Mar 2023 23:33:17 +0100 Subject: [PATCH 4/6] Add description for new metrics --- doc/prometheus_ep_description.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/prometheus_ep_description.md b/doc/prometheus_ep_description.md index 9d274f1e..8fb9e002 100644 --- a/doc/prometheus_ep_description.md +++ b/doc/prometheus_ep_description.md @@ -18,6 +18,8 @@ Prometheus metrics provided at `/metrics`. | Metric name | Type | Description | Labels | |----------------------------------------|---------|--------------------------------------------------------|--------------| | `ahoy_solar_info` | Gauge | Information about the AhoyDTU device | version, image, devicename | +| `ahoy_solar_uptime` | Counter | Seconds since boot of the AhoyDTU device | devicename | +| `ahoy_solar_rssi_db` | Gauge | Quality of the Wifi STA connection | devicename | | `ahoy_solar_inverter_info` | Gauge | Information about the configured inverter(s) | name, serial | | `ahoy_solar_inverter_enabled` | Gauge | Is the inverter enabled? | inverter | | `ahoy_solar_inverter_is_available` | Gauge | is the inverter available? | inverter | From 081adeb140a4b74220990b16b935d1fc305fc61b Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 26 Mar 2023 01:03:59 +0100 Subject: [PATCH 5/6] 0.5.107 * fix: show save message * fix: removed serial newline for `enqueueCmd` --- src/CHANGES.md | 4 ++++ src/defines.h | 2 +- src/hm/hmInverter.h | 2 +- src/web/web.h | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 70b87e0f..d4ab8b79 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -2,6 +2,10 @@ (starting from release version `0.5.66`) +## 0.5.107 +* fix: show save message +* fix: removed serial newline for `enqueueCmd` + ## 0.5.106 * merged MI and debug message changes #804 * fixed MQTT autodiscover #794, #632 diff --git a/src/defines.h b/src/defines.h index d0c57264..05cbd23b 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 5 -#define VERSION_PATCH 106 +#define VERSION_PATCH 107 //------------------------------------- typedef struct { diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index e8c20423..d3efd9ac 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -144,7 +144,7 @@ class Inverter { void enqueCommand(uint8_t cmd) { _commandQueue.push(std::make_shared(cmd)); DPRINT_IVID(DBG_INFO, id); - DBGPRINTLN(F("enqueCommand: 0x")); + DBGPRINT(F("enqueCommand: 0x")); DBGHEXLN(cmd); } diff --git a/src/web/web.h b/src/web/web.h index 46e5ccb7..b83e06b5 100644 --- a/src/web/web.h +++ b/src/web/web.h @@ -593,7 +593,7 @@ class Web { mApp->saveSettings((request->arg("reboot") == "on")); - AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), system_html, save_html_len); + AsyncWebServerResponse *response = request->beginResponse_P(200, F("text/html; charset=UTF-8"), save_html, save_html_len); response->addHeader(F("Content-Encoding"), "gzip"); request->send(response); } From a95dce51c66350d970dc4c50b34143ad593c6ed7 Mon Sep 17 00:00:00 2001 From: lumapu Date: Sun, 26 Mar 2023 01:27:20 +0100 Subject: [PATCH 6/6] 0.5.107 --- src/CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/CHANGES.md b/src/CHANGES.md index d4ab8b79..7c58866a 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -5,6 +5,7 @@ ## 0.5.107 * fix: show save message * fix: removed serial newline for `enqueueCmd` +* Merged improved Prometheus #808 ## 0.5.106 * merged MI and debug message changes #804