Prometheus Metrics compile issue for Linux Versions with older libmicrohttpd-dev
System Info with the observed compile issue:
libmicrohttpd-dev/focal 0.9.66-1
Ubuntu 20.04.6 LTS (Focal Fossa) with
C compiler for the host machine: cc (gcc 9.4.0 "cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0")
C linker for the host machine: cc ld.bfd 2.34
Investigation:
MHD_Result
and potentially other Enumerations (see below MHD_USE_AUTO_INTERNAL_THREAD
) are not defined in earlier versions of libmicrohttpd-dev
. A warning for using earlier versions of libmicrohttpd-dev
could help users verify the version they need. The Prometheus exporter could work with this version by switching to int return type instead of MHD_Result
.
For libmicrohttpd-dev/focal 0.9.66-1
the compile error seen was:
../tools/prometheus-exporter.c:445:13: error: ISO C forbids forward references to ‘enum’ types [-Wpedantic]
445 | static enum MHD_Result rist_prometheus_httpd_handler(void *cls, struct MHD_Connection *connection,
| ^~~~~~~~~~
Need to validate the version of libmicrohttpd that has this issue but I believe on CentOS7 with **libmicrohttpd-0.9.33-2.el7.x86_64.rpm**
MHD_USE_AUTO_INTERNAL_THREAD
is not defined. Some work could be done by meson to set the usage of older int flags
values based on the version of libmicrohttpd that is detected.
Additional Observations
Additionally, Prometheus provides an error on the Target http endpoint when scrapping: Using Prometheus Container Image configured to scrape ristsender/ristreceiver (bitnami/prometheus:latest was IMAGE ID 81edb620ff30)
Error in Prometheus->Status->Targets:
Data does not end with # EOF
I suspect the issue is related to the HTTP response header. When produces=text/plain"
was added to the HTTP response header the error was no longer reported.
// Change made in /tools/prometheus-exporter.c:469
MHD_add_response_header(response, "Content-Type", "application/openmetrics-text; version=1.0.0; charset=utf-8; produces=text/plain");
Small additional change
The following stats can be updated to ratio instead of seconds
PROMETHEUS_GAUGE_PRINT_CLIENT(rist_client_flow_quality, "Current connection quality percentage", "ratio");
PROMETHEUS_GAUGE_PRINT_SENDER_PEER(rist_sender_peer_quality, "Current connection quality percentage", "ratio");