Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event loop lag should be a summary, not a gauge #309

Open
dhet opened this issue Dec 28, 2019 · 7 comments
Open

Event loop lag should be a summary, not a gauge #309

dhet opened this issue Dec 28, 2019 · 7 comments

Comments

@dhet
Copy link

dhet commented Dec 28, 2019

Hi,
as stated in the title, I believe the event loop lag metric should be a summary, not a gauge. The reason is that event loop lag can fluctuate quite substantially in a very short time. Think of a web server: when a web server handles a request, and we take a lag sample at exactly that moment then the lag value is is probably high. If we take a sample in idle state on the other hand, lag should be close to zero. Now when we plot the gauge metric in a line chart we can see seemingly random lag spikes. The spike might be there or not depending on whether a sample was taken during a request or during idle time. A summary would produce much more meaningful results as it records not only a single point in time but also considers all previous samples.

Have a look at the official docs: monitorEventLoopDelay also uses a histogram.

I can open a PR if you want, otherwise #278 would be a good opportunity to make this change.

@dhet
Copy link
Author

dhet commented Dec 28, 2019

This is what it looks like currently:
image
Quite random I would say

Here's what I think it should look like (Ignore the .999 percentile. Those are outliers):
image

@sam-github
Copy link
Contributor

Shouldn't it be a histogram?

@siimon
Copy link
Owner

siimon commented Feb 3, 2020

Yeah, histogram is the way to go

@dhet
Copy link
Author

dhet commented Feb 3, 2020

Care to explain why? Isn't a summary just a histogram with percentiles as buckets?

@sam-github
Copy link
Contributor

Histograms have fixed buckets, with counts in them, so its possible to sum the histograms across all the instances (pods for example). Summaries the data is analyzed on the fly, each pod has different values for the percentiles, and they can't be summed. If you google around you'll find a bunch of info on this. Summaries look great until someone tries to aggregate into a dashboard, then it goes badly.

There is a case to be made that the user should be able to provide either a histogram or summary object to be used for the observation of the values (go does this with some metrics it collects), but I haven't seen the Node.js client do this, so if there is only one, it should be histogram.

@zbjornson zbjornson changed the title Event loop lag should be a summary, not a gauge Event loop lag should be a ~~summary~~ histogram, not a gauge Sep 19, 2021
@zbjornson zbjornson changed the title Event loop lag should be a ~~summary~~ histogram, not a gauge Event loop lag should be a <s>summary</s> histogram, not a gauge Sep 19, 2021
@zbjornson zbjornson changed the title Event loop lag should be a <s>summary</s> histogram, not a gauge Event loop lag should be a ~~summary~~ histogram, not a gauge Sep 19, 2021
@zbjornson zbjornson changed the title Event loop lag should be a ~~summary~~ histogram, not a gauge Event loop lag should be a summary, not a gauge Sep 19, 2021
@zbjornson
Copy link
Collaborator

The reason is that event loop lag can fluctuate quite substantially in a very short time. Think of a web server: when a web server handles a request, and we take a lag sample at exactly that moment then the lag value is is probably high. If we take a sample in idle state on the other hand, lag should be close to zero.

The advanced event loop monitoring added in v12.0.0 (#278) directly exposes the underlying histogram from Node.js v11.10.0+, which fixes this specific problem.

As far as the metric type, I don't think we can convert this into a Prometheus Histogram because the data we get from Node.js is the "processed histogram" -- i.e. "lag at Nth percentile" whereas we'd need "counts in bin LE=0.05". I think @dhet is correct to suggest a Summary for that reason, but @sam-github is correct about Summaries being a pain to work with and aggregate.

I'm inclined to leave this as-is unless someone suggests otherwise.

@anthonyalayo
Copy link

Maybe once native histograms are on the main branch, that would be the best solution?

https://github.com/prometheus/prometheus/milestone/10

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

No branches or pull requests

5 participants