mirror of
https://github.com/xoseperez/espurna.git
synced 2026-03-24 17:17:06 +01:00
web: prometheus metrics support (#2332)
- (experimental) provide generic way to read magnitude values
- expose /api/metrics with values formatted specifically for prometheus, with relay and sensor data
- small tweaks to sensor init
Example config:
```
scrape_configs:
- job_name: 'espurna'
metrics_path: '/api/metrics'
params:
apikey: ['apikeyapikey']
static_configs:
- targets: ['espurna-blabla.lan:80']
```
Where ESPurna side has
```
apiKey => "apikeyapikey"
apiEnabled => "1"
```
This commit is contained in:
@@ -469,10 +469,11 @@ void _onRequest(AsyncWebServerRequest *request){
|
||||
|
||||
if (!_onAPModeRequest(request)) return;
|
||||
|
||||
// Send request to subscribers
|
||||
for (unsigned char i = 0; i < _web_request_callbacks.size(); i++) {
|
||||
bool response = (_web_request_callbacks[i])(request);
|
||||
if (response) return;
|
||||
// Send request to subscribers, break when request is 'handled' by the callback
|
||||
for (auto& callback : _web_request_callbacks) {
|
||||
if (callback(request)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// No subscriber handled the request, return a 404 with implicit "Connection: close"
|
||||
|
||||
Reference in New Issue
Block a user