Skip to content
This repository has been archived by the owner on Mar 31, 2020. It is now read-only.

Prometheus exporter not working #38

Closed
lenalebt opened this issue Jan 20, 2020 · 2 comments
Closed

Prometheus exporter not working #38

lenalebt opened this issue Jan 20, 2020 · 2 comments

Comments

@lenalebt
Copy link

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.

@lenalebt
Copy link
Author

Okay, so I see this exact spot is part of kamon-coreand not this project, but it would be solved by injecting a period of less than 1 year, too, so I guess it would be fixed with #26 , too

@lenalebt
Copy link
Author

I found #36 now which fixed it. It's not too easy to see the latest released version of this artifact from github, though, that's why I overlooked it...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant