merbanan / rtl_433

Program to decode radio transmissions from devices on the ISM bands (and other frequencies)
GNU General Public License v2.0
6.19k stars 1.33k forks source link

prometheus export does not set content-type #3106

Closed Mindavi closed 21 hours ago

Mindavi commented 22 hours ago

I am running into an issue with the prometheus exporter since updating to prometheus 3.0. It appears they added some stricter checking of the Content-Type in https://github.com/prometheus/prometheus/pull/15136.

For now I'll try to set the fallback_scrape_protocol to work around this, but I think it would be good if rtl_433 advertises which protocol it supports by setting the Content-Type as Prometheus expects.

I might pick this up myself at some point, but I want to write this out already so it's documented.

rtl_433 version: 24.10 from nixpkgs.

The following error is logged by the Prometheus scraper:

Dec 02 22:25:19 aqua prometheus[791595]: time=2024-12-02T22:25:19.842+01:00 level=ERROR source=scrape.go:1585 msg="Failed to determine correct type of scrape target." component="scrape manager" scrape_pool=rtl_433 target=http://127.0.0.1:8433/metrics content_type="" fallback_media_type="" err="non-compliant scrape target sending blank Content-Type and no fallback_scrape_protocol specified for target"

Curl call to the rtl_433 endpoint:

# request the rtl_433 endpoint
$ curl -v http://127.0.0.1:8433/metrics
*   Trying 127.0.0.1:8433...
* Connected to 127.0.0.1 (127.0.0.1) port 8433
* using HTTP/1.x
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:8433
> User-Agent: curl/8.11.0
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Content-Length: 1277
< 
# TYPE uptime_seconds counter
# UNIT uptime_seconds seconds
# HELP uptime_seconds Program uptime.
uptime_seconds_total 87982.0
uptime_seconds_created 1733086848.0
# TYPE decoder_enabled gauge
# HELP decoder_enabled Number of enabled decoders.
decoder_enabled 230
# TYPE input_uptime_seconds counter
# UNIT input_uptime_seconds seconds
# HELP input_uptime_seconds SDR Receiver uptime.
input_uptime_seconds_total 87978.0
input_uptime_seconds_created 1733086848.0
# TYPE input_count_frames counter
# UNIT input_count_frames frames
# HELP input_count_frames Number of SDR frames received.
input_count_frames_total 167817
# TYPE input_squelch_frames counter
# UNIT input_squelch_frames frames
# HELP input_squelch_frames Number of SDR frames skipped by squelch.
input_squelch_frames_total 161825
# TYPE input_ook_frames counter
# UNIT input_ook_frames frames
# HELP input_ook_frames Number of SDR frames with OOK demodulation.
input_ook_frames_total 2677
# TYPE input_fsk_frames counter
# UNIT input_fsk_frames frames
# HELP input_fsk_frames Number of SDR frames with FSK demodulation.
input_fsk_frames_total 31
# TYPE input_event_frames counter
# UNIT input_event_frames frames
# HELP input_event_frames Number of SDR frames with decode events.
input_event_frames_total 2649
# EOF
* Connection #0 to host 127.0.0.1 left intact

Curl call to a (more) compliant endpoint:

# request a compliant endpoint (hydra_queue_runner)
$ curl -v http://127.0.0.1:9200/metrics
*   Trying 127.0.0.1:9200...
* Connected to 127.0.0.1 (127.0.0.1) port 9200
* using HTTP/1.x
> GET /metrics HTTP/1.1
> Host: 127.0.0.1:9200
> User-Agent: curl/8.11.0
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Content-Type: text/plain; version=0.0.4; charset=utf-8
< Date: Mon, 02 Dec 2024 21:27:05 GMT
< Transfer-Encoding: chunked
< 
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 2.2481e-05
go_gc_duration_seconds{quantile="0.25"} 4.3517e-05
go_gc_duration_seconds{quantile="0.5"} 7.5452e-05
go_gc_duration_seconds{quantile="0.75"} 0.000191393
go_gc_duration_seconds{quantile="1"} 0.007130977
go_gc_duration_seconds_sum 0.394173027
zuckschwerdt commented 21 hours ago

Thanks for the detailed report! I'll quickly add the header and attribute you in the commit.