Package: prometheus-express
prometheus_expressAPrometheusSDK for CircuitPython/MicroPython boards, allowing sensor data to be integrated
into existing Prometheus/Grafana monitoring infrastructure.only depends onsocketruns on CircuitPython 4.x for embedded devicesruns on CPython 3.x for local testingAPI compatible with the officialprometheus/client_pythonbasic HTTP server with path/method routingnot terribly slow (wrkreports upwards of 10 rps with routing)For those unfamiliar with Prometheus, the examples expose an HTTP server on port:8080that reports metrics in a
plaintext format:# HELP prom_express_gas gas from the bme680 sensor
# TYPE prom_express_gas gauge
prom_express_gas 1060948
# HELP prom_express_humidity humidity from both sensors
# TYPE prom_express_humidity gauge
prom_express_humidity{sensor="None"} 0
prom_express_humidity{sensor="bme680"} 49.4062
prom_express_humidity{sensor="si7021"} 49.7976
# HELP prom_express_pressure pressure from the bme680 sensor
# TYPE prom_express_pressure gauge
prom_express_pressure 983.25
# HELP prom_express_temperature temperature from both sensors
# TYPE prom_express_temperature gauge
prom_express_temperature{sensor="None"} 0
prom_express_temperature{sensor="bme680"} 24.7359
prom_express_temperature{sensor="si7021"} 24.3325Contentsprometheus_expressContentsStatusReleasesSupported HardwareSupported FeaturesHTTPLabelsMetric TypesCounterGaugeSummaryRegistriesPlanned FeaturesKnown IssuesLoad Causes OSErrorStatusReleasesSupported HardwareThis library is developed for theAdafruit Feather M4 Expressrunning
MicroPython 4.1.0 or better, with anAdafruit Ethernet FeatherWingattached.Supported FeaturesHTTPThis module implements a very rudimentary HTTP server that likely violates some part of the spec. However, it works
with Chrome, curl, and Prometheus itself.LabelsLabels are stored and used to accumulate values. Missing labels are reported asNone.Metric TypesCounter,Gauge, andSummaryare implemented with labels.CounterIncremental values. Implementsinc(value)anddec(value).GaugeAbsolute values. Extendscounterwithset(value).SummaryIndividual values. Prints count and total ofobserve(value).RegistriesRegistries may be created with a namespace:CollectorRegistry(namespace='foo')Callregistry.render()to format metrics in Prometheus'plain text exposition format:# HELP prom_express_test_counter a test counter
# TYPE prom_express_test_counter counter
prom_express_test_counter 1588
# HELP prom_express_test_gauge a test gauge
# TYPE prom_express_test_gauge gauge
prom_express_test_gauge 3887Metrics may be registered with multiple registries.Planned Featurespush support:push_to_gatewayremaining metric types:Histogramtests for API compatibilityKnown IssuesLoad Causes OSErrorLoad testing the HTTP endpoint may cause one of a variety ofOSErrors, oftenerrno3, 4, or 7.Not sure what is causing the errors, but it is not predictable and may not appear immediately:>./wrk-c1-d60s-t1http://server:8080/
Running1mtest@http://server:8080/1threadsand1connectionsThreadStatsAvgStdevMax+/-StdevLatency8.64ms485.57us12.81ms97.75%Req/Sec111.605.21121.0071.00%2222requestsin20.61s,671.83KBreadSocketerrors:connect0,read1,write2743,timeout0Requests/sec:107.82
Transfer/sec:32.60KBSome are fatal:Connection from ('client', 8080)
Accepting...
Connection from ('client', 8080)
Accepting...
Error accepting request: [Errno 128] ENOTCONN
Binding: server:8080
Traceback (most recent call last):
  File "code.py", line 90, in <module>
  File "code.py", line 87, in main
  File "code.py", line 87, in main
  File "code.py", line 55, in bind
  File "/lib/prometheus_express/http.py", line 11, in start_http_server
OSError: 4Others require the socket to be rebound:Connection from ('client', 8080)
Accepting...
Error accepting request: 7
Binding: server:8080
Accepting...