Prometheus API: Only output the channels if they where read at least once
This commit is contained in:
parent
c67b3e3cbd
commit
4d18ccf01d
@ -65,7 +65,8 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
|
|||||||
stream->printf("opendtu_last_update{serial=\"%s\",unit=\"%d\",name=\"%s\"} %d\n",
|
stream->printf("opendtu_last_update{serial=\"%s\",unit=\"%d\",name=\"%s\"} %d\n",
|
||||||
serial.c_str(), i, name, inv->Statistics()->getLastUpdate() / 1000);
|
serial.c_str(), i, name, inv->Statistics()->getLastUpdate() / 1000);
|
||||||
|
|
||||||
// Loop all channels
|
// 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()) {
|
for (auto& t : inv->Statistics()->getChannelTypes()) {
|
||||||
for (auto& c : inv->Statistics()->getChannelsByType(t)) {
|
for (auto& c : inv->Statistics()->getChannelsByType(t)) {
|
||||||
addField(stream, serial, i, inv, t, c, FLD_PAC);
|
addField(stream, serial, i, inv, t, c, FLD_PAC);
|
||||||
@ -89,6 +90,7 @@ void WebApiPrometheusClass::onPrometheusMetricsGet(AsyncWebServerRequest* reques
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
stream->addHeader(F("Cache-Control"), F("no-cache"));
|
stream->addHeader(F("Cache-Control"), F("no-cache"));
|
||||||
request->send(stream);
|
request->send(stream);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user