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

fix(parsers.prometheus): Histogram infinity bucket not being generated when using protobuf protocol #11486

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

mmolnar
Copy link
Contributor

@mmolnar mmolnar commented Jul 11, 2022

In some cases the infinity bucked is not being parsed or generated from text prometheus input by the library github.com/prometheus/common/expfmt

I have not found the specifics, but it must be related to the version of libc because the same telegraf binary works on ubuntu with libc6:amd64 2.27-3ubuntu1.6, but does not work on debian with 2.28-10.

Because the infinity bucket has the same value as histogram sample count we can just enforce creation of this bucket if it is missing. They are doing basically the same thing in the underlying library used to parse metrics when generating text format from metrics.

resolves #11490

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good to me. Thanks for the fix @mmolnar!

If you can create an issue that describes the issue in more detail and link it here that would be super awesome.

@srebhan srebhan self-assigned this Jul 11, 2022
@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 11, 2022
@srebhan
Copy link
Member

srebhan commented Jul 11, 2022

Oh and maybe a test case to make sure we don't fail in the future?!

@mmolnar
Copy link
Contributor Author

mmolnar commented Jul 11, 2022

If you can create an issue that describes the issue in more detail and link it here that would be super awesome.

There is not much more to say about this because I did not find the root cause, this is just an work-around for the varied behaviour of the underlying library prometheus/common/expfmt

and maybe a test case to make sure we don't fail in the future?!

I am not sure how would I do that because it seems the whole issue is environment dependent.
I have tried the exact same test case scenario on 2 different linux distributions (ubuntu vs debian) and one worked properly and one did not generate metric with the Infinity bucket.

Might have something to do with the fact that value of the "le" label is actually +Infinity value of golang type float64, sometimes it gets interpreted as NoN and dropped and sometimes it gets converted to string "+Inf".
The test case for presence of +Inf in histogram is already there, so it seems you just did not encounter this issue in your build environment.

@mmolnar
Copy link
Contributor Author

mmolnar commented Jul 11, 2022

I have tried to look deeper into the issue and found the core of the problem. Issue is NOT environment dependent, but depends on the protocol being used.

Some prometheus clients are capable of responding with protobuf protcol which telegraf requests by default. My test cases were different, on ubuntu i tried to simulate the response with nginx which was capable to respond only in text expostion format, but on debian I had a service responding in protobuf.

Seems the prometheus protobuf exposition format expects Inf bucket to be optional, but it is not optional in the text exposition format, my pull request will fix this.

There could be an test case done for this, here I have 2 questions:

  1. Is it necesary seeing as protobuf protocol is deprecated by Prometheus? Should telegraf just stop requesting and parsing protobuf protocol?
  2. To test it we need an protobuf message to parse, should this be an base64 encoded binary data string in the test file? Or should the test file create the message for the parser? This could probably done from JSON to Go Data Model and then to binary.

@srebhan
Copy link
Member

srebhan commented Jul 11, 2022

@mmolnar I would just test if the makeBuckets() function always returns the inf bucket, if given or not given, I don't think you need to do the whole loop.

Regarding the protobuf thingy, I'll bring up a discussion internally...

Anyway, it would be nice to copy this (maybe even as-is) into an issue so people that search for it will easily find it and make their way to this fix...

@MyaLongmire MyaLongmire removed the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 11, 2022
@mmolnar mmolnar requested a review from srebhan July 13, 2022 06:46
@mmolnar
Copy link
Contributor Author

mmolnar commented Jul 13, 2022

@srebhan I created an issue #11490 with the relevant findings and created an test case for this problem.

@mmolnar mmolnar changed the title Prometheus: Histogram infinity bucket not being generated in edge cases Prometheus: Histogram infinity bucket not being generated when using protobuf protocol Jul 13, 2022
@MyaLongmire MyaLongmire added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Jul 14, 2022
@srebhan
Copy link
Member

srebhan commented Jul 15, 2022

Hey @mmolnar, sorry for the late reply! We discussed deprecating on how to handle this issue in an internal meeting and we think deprecating the protobuf part should be done in 2.0 as this is a potential breaking change. So the target setting is to get this fix in and deprecate the root cause later. Does that sound good?

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thanks a bunch @mmolnar for hunting this down and submitting this fix!

@srebhan srebhan changed the title Prometheus: Histogram infinity bucket not being generated when using protobuf protocol fix(parsers.prometheus): Histogram infinity bucket not being generated when using protobuf protocol Jul 15, 2022
@srebhan srebhan added area/prometheus fix pr to fix corresponding bug plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins labels Jul 15, 2022
@mmolnar
Copy link
Contributor Author

mmolnar commented Jul 15, 2022

So the target setting is to get this fix in and deprecate the root cause later. Does that sound good?

Yes, thank you.

@powersj powersj merged commit 2ac311c into influxdata:master Jul 15, 2022
MyaLongmire pushed a commit that referenced this pull request Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/prometheus fix pr to fix corresponding bug plugin/parser 1. Request for new parser plugins 2. Issues/PRs that are related to parser plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

inputs.prometheus missing histogram infinity bucket when protobuf protocol is used
4 participants