Feature: Add current limit to prometheus output

Fixes #1617
This commit is contained in:
Thomas Basler 2024-01-13 11:33:58 +01:00
parent f013698471
commit 638f52a8da

View File

@ -81,6 +81,22 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
stream->printf("opendtu_last_update{serial=\"%s\",unit=\"%d\",name=\"%s\"} %d\n",
serial.c_str(), i, name, inv->Statistics()->getLastUpdate() / 1000);
if (i == 0) {
stream->print("# HELP opendtu_inverter_limit_relative current relative limit of the inverter\n");
stream->print("# TYPE opendtu_inverter_limit_relative gauge\n");
}
stream->printf("opendtu_inverter_limit_relative{serial=\"%s\",unit=\"%d\",name=\"%s\"} %f\n",
serial.c_str(), i, name, inv->SystemConfigPara()->getLimitPercent() / 100.0);
if (inv->DevInfo()->getMaxPower() > 0) {
if (i == 0) {
stream->print("# HELP opendtu_inverter_limit_absolute current relative limit of the inverter\n");
stream->print("# TYPE opendtu_inverter_limit_absolute gauge\n");
}
stream->printf("opendtu_inverter_limit_absolute{serial=\"%s\",unit=\"%d\",name=\"%s\"} %f\n",
serial.c_str(), i, name, inv->SystemConfigPara()->getLimitPercent() * inv->DevInfo()->getMaxPower() / 100.0);
}
// Loop all channels if Statistics have been updated at least once since DTU boot
if (inv->Statistics()->getLastUpdate() > 0) {
for (auto& t : inv->Statistics()->getChannelTypes()) {