Commit Graph

32 Commits

Author SHA1 Message Date
Michael Hanselmann 718f5fc9ab prometheus: Unify memory metrics
The "memory fragmentation" value named "memory_ratio" was always
truncated to an integer, so in all likelyhood 0. It didn't work anyway
until the incorrect line termination was fixed in an earlier commit.
Neither could the Psram metric be parsed correctly due to the the same
incorrect line termination.

With this change memory usage is reported in line with Prometheus'
upstream recommendations (https://prometheus.io/docs/practices/naming/).
Labels are no longer used to separate distinct dimensions. Total and
free memory as well as the maximum allocation size are reported as
separate metrics where available while labels are used to differenciate
the separate kinds of memory (heap on all, psram on ESP32).

Label values are now also lowercase on ESP32 to match ESP8266.

Metrics should report their base values, not the result of
a calculation. Therefore the already non-working "fragmentation" metric
is dropped. It can easily be calculated in PromQL instead.

The renaming of metrics and label values makes this a breaking change,
especially on ESP32. With the aforementioned formatting errors which
made them unusable that shouldn't be a problem.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-07-19 13:35:59 +02:00
Michael Hanselmann 1b96833d6a prometheus: Use utility functions to format metrics
Format strings for Prometheus metrics were written manually and the
`# TYPE` lines needed to be kept in sync with actual metrics. As
indicated by the previous commit it wasn't always as consistent as
desired. In addition there was a lot of repetition among the strings
which couldn't be reduced at build time.

With this change utility functions are introduced which eliminate the
need for specifying the same metric name more than once. At the same
time the proper escaping for label values, initially added in commit
16b5f2fe9, is now applied for all labels.

The size of the program shrinks slightly by 212 bytes on ESP8266 in the
"tasmota" configuration with Prometheus enabled and 412 bytes on ESP32
with the "tasmota32" configuration.

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-07-19 13:35:46 +02:00
Michael Hanselmann 7d15e15d8a 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 <public@hansmi.ch>
2021-07-19 13:35:27 +02:00
Stephan Hadinger 1682582bea Disable PSRAM on unsupported hardware
Either ESP32 rev1/2 that needs special fixes
`-DHAS_PSRAM_FIX -mfix-esp32-psram-cache-issue -lc-psram-workaround -lm-psram-workaround`
or ESP32-PICO-V3-02 that requires esp-idf 4.4
2021-07-18 19:43:33 +02:00
Michael Hanselmann 16b5f2fe92 prometheus: Expose device name as part of device info
The device name can be useful to identify a particular instance in
Prometheus.

Example:

```
tasmota_info{...,devicename="livingroom"} 1
```

Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-07-11 20:16:50 +02:00
Michael Hanselmann 9e441630f1 prometheus: Add comment with link to exposition format
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-07-11 20:16:37 +02:00
Michael Hanselmann 56ed94db42 prometheus: Fix typos in comments
Signed-off-by: Michael Hanselmann <public@hansmi.ch>
2021-07-11 20:16:37 +02:00
Theo Arends 5e805e0c4a Move Settings from DRAM to heap 2021-06-11 18:14:12 +02:00
Theo Arends aa64428c2f Prep mqtt_data from char to String (prt.1) 2021-06-06 16:08:01 +02:00
Theo Arends cea58d66c8 Prep virtual mqtt_data prt3 2021-05-24 16:52:59 +02:00
twollweber dae62f7866
Add Free Memory metric for Prometheus 2021-04-29 10:20:05 +02:00
twollweber 0558430f89
Fix #11933
Fix Align tasmotaglobal metrics for Prometheus to other metrics' syntax
2021-04-28 22:39:00 +02:00
twollweber 072302d821
Fix for issue #11930 2021-04-28 18:58:19 +02:00
Alex Brown f31bdfdfb3
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\\"```
2021-03-17 22:54:37 -04:00
Theo Arends ac054ea666 Refactor AddLog usage 2021-01-23 17:10:06 +01:00
Theo Arends dcbb3f1e0e Happy New Year 2021-01-01 13:44:04 +01:00
Theo Arends f3feb3ea6a Fix prometheus exception
Fix prometheus exception (#10221)
2020-12-24 12:37:59 +01:00
lucs7 d7e8614dbb
Update xsns_75_prometheus.ino
added comments
2020-12-16 23:58:11 +01:00
lucs7 732e3c7c2c
Update xsns_75_prometheus.ino 2020-12-16 23:51:02 +01:00
lucs7 3d6dd8ff87 sensor data to prometheus metrics 2020-12-16 23:39:33 +01:00
Alexander Kabakaev 056493740b show relay state in prometheus metrics 2020-12-12 12:18:00 +01:00
Theo Arends fa7fdbd51a Consolidate `AddLog_P`
Consolidate `AddLog_P` into `AddLog_P2` and rename to `AddLog_P`
2020-11-06 17:09:13 +01:00
Theo Arends af5082320d Use global struct 2020-10-30 12:29:48 +01:00
Theo Arends f1ac7b2d67 Use global struct 2020-10-28 19:03:39 +01:00
Theo Arends b93b719108 Use global struct 2020-10-28 17:32:07 +01:00
Stephan Hadinger 1af525619a Webserver->on() optimization phase 2 2020-10-20 18:56:18 +02:00
Patrick Fruh e41e4d4ca3
update prometheus metric names 2020-08-19 20:57:28 +02:00
Mark Hansen c9f3a2d563 Add tasmota_flash_writes_total to Prometheus
Follows prometheus naming best practices for unitless accumulating counts:
https://prometheus.io/docs/practices/naming/#metric-names

(cf http_requests_total).
2020-06-29 10:35:27 +10:00
Theo Arends 7dafeb280e Rename global temp and pressure
- Rename global temp and pressure (#8808, #8810)
- Fix SGP30 calculation (#8808)
2020-06-28 12:23:18 +02:00
Mark Hansen e9f88af959 Add WiFi metrics to prometheus exporter 2020-06-28 11:43:29 +10:00
Mark Hansen 76c61e85b3 Add tasmota_info prometheus psuedo-metric.
Exports version, image type, and build timestamp.

It's common to export something like this to show version numbers across the fleet.

For example, the golang exporter exposes version:
```
go_info{version="go1.14.4"} 1
```

And prometheus exposes:
```
prometheus_build_info{branch="HEAD",goversion="go1.14.4",revision="eba3fdcbf0d378b66600281903e3aab515732b39",version="2.19.1"} 1
```
2020-06-27 21:21:11 +10:00
Theo Arends 1866938cbd Integrate prometheus 2020-06-27 11:52:44 +02:00