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

Allow serving compresses responses via Prometheus plugin #4501

Closed
Lusitaniae opened this issue May 22, 2024 · 10 comments
Closed

Allow serving compresses responses via Prometheus plugin #4501

Lusitaniae opened this issue May 22, 2024 · 10 comments
Labels
enhancement Feature request or improve operations

Comments

@Lusitaniae
Copy link

Is your feature request related to a problem? Please describe.

I'm using Prometheus plugin to export metrics based on logs ingested by fluentd.

In some servers these metrics can amount to millions of lines, which reach payload sizes of 50/60Mb and either reach the scraping limit (set by vmagent), or they failed to be transitted within the timeout period (10s)

Compressing data would be a clear winner to solve this problem

Describe the solution you'd like

Allow prometheus plugin to send compressed responses

Describe alternatives you've considered

Bumping payload limits / timeouts

Additional context

$ curl -s http://node1:9106/metrics | wc -c
37420840
$ curl -s http://node1:9106/metrics | gzip -c | wc -c
1877477

Cross posted from fluent/fluent-plugin-prometheus#219 in case this is the right place to implement such feature

@daipom daipom added feature request *Deprecated Label* Use enhancement label in general and removed waiting-for-triage labels Jun 13, 2024
@Athishpranav2003
Copy link
Contributor

@Lusitaniae I have one query with this. I understand you want to expose it in compressed format but can you name few metrics collectors that scrape in compressed format and decompresses it?
I have worked with Telegraf and chronocollector and both don't support scraping metrics that are in compressed format

I guess if this is not the standard then not sure if its a genuine feature request

@Lusitaniae
Copy link
Author

Lusitaniae commented Jul 26, 2024

@Athishpranav2003
Copy link
Contributor

Athishpranav2003 commented Jul 26, 2024

I see
For now it seems only gzip format is supported
Maybe I can pick this up in the following week

@Lusitaniae
Copy link
Author

Much appreciated 🙏

@Athishpranav2003
Copy link
Contributor

@Lusitaniae This would require to contribute to https://github.com/prometheus/client_ruby/blob/main/lib/prometheus/client/formats/text.rb the official prometheus client for ruby. The hackaround for this is we break the abstractions in the Fluentd prometheus plugin to fetch the metrics info and compress and host directly. Not sure which is a better call because maybe first is overkill but I feel that's the write method

@Lusitaniae
Copy link
Author

Doesn't this solve it?

It's highly recommended to enable gzip compression for the metrics endpoint, for example by including the Rack::Deflater middleware.

https://github.com/prometheus/client_ruby?tab=readme-ov-file#rack-middleware

@Athishpranav2003
Copy link
Contributor

Oh yah
i missed this infact. Thanks for pointing it. I will try to check this in my free time.

@Athishpranav2003
Copy link
Contributor

Athishpranav2003 commented Jul 29, 2024

I was checking this @Lusitaniae. So for the Rack middleware to be used we need to have the app(http server) exposed and get overriden with the middleware. But i guess the code abstraction in fluentd has made use of a plugin helper so seems like its not as direct as we see. I am actively checking how to make use of it but incase if you also find something interesting please let me know

For now i am not using rack but trying to compress the data directly and put it in the response body

@kenhys kenhys added enhancement Feature request or improve operations and removed feature request *Deprecated Label* Use enhancement label in general labels Jul 31, 2024
@Athishpranav2003
Copy link
Contributor

Athishpranav2003 commented Jul 31, 2024

@kenhys the PR is done for this and reviewed by @ashie. I guess u can change the label to the appropriate one
fluent/fluent-plugin-prometheus#223

@Lusitaniae
Copy link
Author

Maybe can close this one, since it was implemented on the plugin itself, and I also filed an issue there

fluent/fluent-plugin-prometheus#219

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request or improve operations
Projects
None yet
Development

No branches or pull requests

4 participants