Hi all,
so I'm new to a project using the prometheus exporter and have seen that it does not work properly. Behaviour is the metrics endpoint not returning any data anymore:
curl localhost:9095/metrics -v
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 9095 (#0)
> GET /metrics HTTP/1.1
> Host: localhost:9095
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/plain; version=0.0.4; charset=utf-8
< Date: Mon, 20 Jan 2020 11:52:29 GMT
< Connection: keep-alive
< Content-Length: 0
<
* Connection #0 to host localhost left intact
* Closing connection 0
Digging a bit I think it must have stopped working 2019-12-20T00:00:00Z
for all users of this lib, I'll try to elaborate and I hope I'm wrong :).
In class PrometheusReporter
I found
private val _snapshotAccumulator = PeriodSnapshot.accumulator(Duration.ofDays(365 * 5), Duration.ZERO)
Which sets a time frame of five years for some accumulation. Based on that accumulation time frame, a date gets calculated (_nextTick
, currently it's calculated as 2024-12-18T00:00:00Z
) which is used in various places. As far as I understand it, it's the max time frame that should be used for accumulation of data?
The function PeriodSnapshot.Accumulator.peek
, which gets called periodically to calculate the data to be written, uses that nextTick
to say until when it wants to read data. Before composing the data, it tries to tidy up (cleanStaleEntries
). That function calculates a cutoff date, until when it considers data to be valid:
val cutoff = currentInstant.minus(stalePeriod)
currentInstant
in that case is set to _nextTick
, 5 years in the future. I'm not 100% sure what the correct value would be there, but using _nextTick
currently calculates something 4 years into the future, which discards all data.
I'll prepare a short PR to fix it at least "a bit", but please have a look at what time would be the "right" there. I'd use from
instead, but if you know better please tell me.