Change metric names slightly
This commit is contained in:
parent
174609ea93
commit
213d2e05b5
|
@ -31,6 +31,6 @@ This uses the Arduino IDE.
|
||||||
|
|
||||||
| Metric | Description | Unit |
|
| Metric | Description | Unit |
|
||||||
| - | - | - |
|
| - | - | - |
|
||||||
| iot_humidity_percent | Air humidity. | `%` |
|
| iot_air_humidity_percent | Air humidity. | `%` |
|
||||||
| iot_temperature_celsius | Air temperature. | `°C` |
|
| iot_air_temperature_celsius | Air temperature. | `°C` |
|
||||||
| iot_heat_index_celsius | Apparent air temperature, based on temperature and humidity. | `°C` |
|
| iot_air_heat_index_celsius | Apparent air temperature, based on temperature and humidity. | `°C` |
|
||||||
|
|
33
src/src.ino
33
src/src.ino
|
@ -43,8 +43,8 @@ void setup_dht_sensor() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup_wifi() {
|
void setup_wifi() {
|
||||||
char message[100];
|
char message[128];
|
||||||
snprintf(message, 100, "Using Wi-Fi SSID \"%s\".", WIFI_SSID);
|
snprintf(message, 128, "Wi-Fi SSID: %s", WIFI_SSID);
|
||||||
log(message);
|
log(message);
|
||||||
log("Wi-Fi connecting ...");
|
log("Wi-Fi connecting ...");
|
||||||
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
|
||||||
|
@ -54,7 +54,7 @@ void setup_wifi() {
|
||||||
}
|
}
|
||||||
const IPAddress &ipaddr = WiFi.localIP();
|
const IPAddress &ipaddr = WiFi.localIP();
|
||||||
log("Wi-Fi connected.");
|
log("Wi-Fi connected.");
|
||||||
snprintf(message, 100, "IPv4 address: %d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
|
snprintf(message, 128, "IPv4 address: %d.%d.%d.%d", ipaddr[0], ipaddr[1], ipaddr[2], ipaddr[3]);
|
||||||
log(message);
|
log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +63,9 @@ void setup_http_server() {
|
||||||
http_server.on(HTTP_METRICS_ENDPOINT, HTTPMethod::HTTP_GET, handle_http_metrics_client);
|
http_server.on(HTTP_METRICS_ENDPOINT, HTTPMethod::HTTP_GET, handle_http_metrics_client);
|
||||||
http_server.begin();
|
http_server.begin();
|
||||||
log("HTTP server started.");
|
log("HTTP server started.");
|
||||||
|
char message[128];
|
||||||
|
snprintf(message, 128, "Metrics endpoint: %s", HTTP_METRICS_ENDPOINT);
|
||||||
|
log(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(void) {
|
void loop(void) {
|
||||||
|
@ -85,18 +88,18 @@ void handle_http_home_client() {
|
||||||
void handle_http_metrics_client() {
|
void handle_http_metrics_client() {
|
||||||
static size_t const BUFSIZE = 1024;
|
static size_t const BUFSIZE = 1024;
|
||||||
static char const *response_template =
|
static char const *response_template =
|
||||||
"# HELP iot_humidity_percent Air humidity.\n"
|
"# HELP iot_air_humidity_percent Air humidity.\n"
|
||||||
"# TYPE iot_humidity_percent gauge\n"
|
"# TYPE iot_air_humidity_percent gauge\n"
|
||||||
"# UNIT iot_humidity_percent %%\n"
|
"# UNIT iot_air_humidity_percent %%\n"
|
||||||
"iot_humidity_percent %f\n"
|
"iot_air_humidity_percent %f\n"
|
||||||
"# HELP iot_temperature_celsius Air temperature.\n"
|
"# HELP iot_air_temperature_celsius Air temperature.\n"
|
||||||
"# TYPE iot_temperature_celsius gauge\n"
|
"# TYPE iot_air_temperature_celsius gauge\n"
|
||||||
"# UNIT iot_temperature_celsius \u00B0C\n"
|
"# UNIT iot_air_temperature_celsius \u00B0C\n"
|
||||||
"iot_temperature_celsius %f\n"
|
"iot_air_temperature_celsius %f\n"
|
||||||
"# HELP iot_heat_index_celsius Apparent air temperature, based on temperature and humidity.\n"
|
"# HELP iot_air_heat_index_celsius Apparent air temperature, based on temperature and humidity.\n"
|
||||||
"# TYPE iot_heat_index_celsius gauge\n"
|
"# TYPE iot_air_heat_index_celsius gauge\n"
|
||||||
"# UNIT iot_heat_index_celsius \u00B0C\n"
|
"# UNIT iot_air_heat_index_celsius \u00B0C\n"
|
||||||
"iot_heat_index_celsius %f\n";
|
"iot_air_heat_index_celsius %f\n";
|
||||||
|
|
||||||
read_sensors();
|
read_sensors();
|
||||||
if (isnan(humidity) || isnan(temperature) || isnan(heat_index)) {
|
if (isnan(humidity) || isnan(temperature) || isnan(heat_index)) {
|
||||||
|
|
Loading…
Reference in New Issue