New outdoor sensor - has anyone added code to allow Prometheus scraping?

I’ve tried using WebServer library. It compiles, but doesn’t respond to Curl request. Any help appreciated.

I’d first trying pinging the local IP address of the sensor.

If it doesn’t respond, check network connection of the sensor.

If it does respond, curl at “localip:serverPort” again.

If it fails to curl again, double check the port number for your WebServer in your sketch and push the data from your /metrics message to the serial monitor to ensure data is being written.

If it looks okay, double check server.send(), server.on(), and ESPWebServer server(port) to ensure those are declared correctly and in scope.

If you’d like, you could share your sketch here and I could take a look over it.

It responds to pings - no problem. Plus, it reports data to the Air Gradient website. It does not respond to CURL commands, so I think my use of WebServer.h isn’t working. I will try ESPWebServer as you recommended.
Bartman

It appears that ESPWebServer is actually the same ESP8266WebServer, which doesn’t support the ESP32 which is used on the outdoor sensor. Some have suggested using WiFiServer for the ESP32. Do you have any recommendations?

Thanks. It is working now. Part of the problem is that the ESP32 is much slower in responding to HTTP requests than the ESP8266. This documented in WebServer.handleClient() longer time execution on ESP32-C3 compares to ESP8266 (930 us vs 10us) · Issue #7708 · espressif/arduino-esp32 · GitHub. I implemented their recommended solution and now the sensor is responding fairly quickly to a Curl request (although the outdoor sensor won’t respond in the loop until it deals with multiple sensor tries)

Bartman

Hi bartman,

Would you be willing to share the code you’re using for this? Just scooped up an outdoor kit myself and am interested in scraping metrics locally as well

If you want to get your metrics into a database, you may consider influxdb - it allows metrics to be pushed into - so, no web server needed.

I found Monitoring my home's air quality (CO2, PM2.5, Temp/Humidity) with AirGradient's DIY sensor | Jeff Geerling

Looks like they made firmware that can directly expose an prom exporter from the device itself, pretty neat: