From f31bdfdfb34edb36bc7c1498d6fbc4f4001cde7b Mon Sep 17 00:00:00 2001 From: Alex Brown <100519+alexpbrown@users.noreply.github.com> Date: Wed, 17 Mar 2021 22:26:24 -0400 Subject: [PATCH] Add period char replacement for prometheus This was a problem for me when trying to get output from an SDS011 Nova PM sensor. When parsed by the pometheus code it returns labels / metrics like: ```# TYPE tasmota_sensors_pm2.5_ gauge tasmota_sensors_pm2.5_{sensor="sds0x1"} 2.2``` The error from prometheus was: ```"append failed" err="invalid metric type \\"5_ gauge\\"``` --- tasmota/xsns_75_prometheus.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/tasmota/xsns_75_prometheus.ino b/tasmota/xsns_75_prometheus.ino index bbdb303c5..0b0251229 100644 --- a/tasmota/xsns_75_prometheus.ino +++ b/tasmota/xsns_75_prometheus.ino @@ -57,6 +57,7 @@ String FormatMetricName(const char *metric) { // cleanup spaces and uppercases String formatted = metric; formatted.toLowerCase(); formatted.replace(" ", "_"); + formatted.replace(".", "_"); return formatted; }