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

[Prometheus] Align on the algorithm used to transform Prometheus histograms into Elasticsearch histograms #36647

Conversation

tetianakravchenko
Copy link
Contributor

@tetianakravchenko tetianakravchenko commented Sep 21, 2023

Proposed commit message

Align on the algorithm used to transform Prometheus histograms into Elasticsearch histograms Elasticsearch histograms.

The original issue for those changes was - #26903 and related discussion - elastic/apm-agent-python#1165 (comment), in this commit are addressed:

  • Use the preceding bucket's value for +Inf 'le',
  • for the first bucket only: if it has a negative 'le', use the value as-is;

    Note: missing handling of negative buckets cause the error: [values] values must be in increasing order, got [-4.9E-324] but previous value was [0.0] for the kubernetes proxy metrics, as result the document that contains such a field will be dropped - related comment with the prometheus histogram sample

Additionally:

  • extend explanation on the counts calculation

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

…lasticsearch histograms: Use the preceding bucket's value for +Inf 'le', for the first bucket only: if it has a negative 'le', use the value as-is; add test for the negative buckets; extend explanation on the counts calculation

Signed-off-by: Tetiana Kravchenko <[email protected]>
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Sep 21, 2023
@botelastic
Copy link

botelastic bot commented Sep 21, 2023

This pull request doesn't have a Team:<team> label.

@mergify
Copy link
Contributor

mergify bot commented Sep 21, 2023

This pull request does not have a backport label.
If this is a bug or security fix, could you label this PR @tetianakravchenko? 🙏.
For such, you'll need to label your PR with:

  • The upcoming major version of the Elastic Stack
  • The upcoming minor version of the Elastic Stack (if you're not pushing a breaking change)

To fixup this pull request, you need to add the backport labels for the needed
branches, such as:

  • backport-v8./d.0 is the label to automatically backport to the 8./d branch. /d is the digit

@elasticmachine
Copy link
Collaborator

elasticmachine commented Sep 21, 2023

💚 Build Succeeded

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview preview

Expand to view the summary

Build stats

  • Start Time: 2023-10-11T08:21:47.997+0000

  • Duration: 51 min 38 sec

Test stats 🧪

Test Results
Failed 0
Passed 1790
Skipped 133
Total 1923

💚 Flaky test report

Tests succeeded.

🤖 GitHub comments

Expand to view the GitHub comments

To re-run your PR in the CI, just comment with:

  • /test : Re-trigger the build.

  • /package : Generate the packages and run the E2E tests.

  • /beats-tester : Run the installation tests with beats-tester.

  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

SampleSum: proto.Float64(20),
Bucket: []*p.Bucket{
{
UpperBound: proto.Float64(-100),
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!!

@@ -1016,7 +1016,7 @@ func TestGenerateEventsHistogramsDifferentLabels(t *testing.T) {
},
"http_request_bytes": mapstr.M{
"histogram": mapstr.M{
"values": []float64{float64(0.125), float64(0.375), float64(0.75)},
"values": []float64{float64(0.125), float64(0.375), float64(0.5)},
Copy link
Contributor

Choose a reason for hiding this comment

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

Trying to understand this change: Why we have now 0.5?

Is it due to // Report +Inf bucket as a point, use the preceding bucket's value, and we put the last bucket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, for the last bucket (+Inf 'le') is used the preceding bucket's value, instead of interpolation by adding half the difference between the previous two buckets to the second last bucket

@gizas
Copy link
Contributor

gizas commented Sep 29, 2023

I think this elastic/integrations#5042 can be closed when this is merged

Copy link
Member

@ChrsMark ChrsMark left a comment

Choose a reason for hiding this comment

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

Code changes themselves look good to me.

Didn't do any validation on the algorithm but I guess it's already discussed? On this, could you link in the description's main context the link to the issue that describes this decision and the motivation?

@tetianakravchenko
Copy link
Contributor Author

@ChrsMark

Didn't do any validation on the algorithm but I guess it's already discussed? On this, could you link in the description's main context the link to the issue that describes this decision and the motivation?

the original issue for those changes was - #26903 and related discussion - elastic/apm-agent-python#1165 (comment)

I've added it to the description and the link to the existing parsing issues

@tetianakravchenko
Copy link
Contributor Author

@gizas

I think this elastic/integrations#5042 can be closed when this is merged

I've left a comment that this PR covers only partially the scope of the mentioned issue - elastic/integrations#5042 (comment), do you think it can be closed anyway?

@tetianakravchenko tetianakravchenko merged commit 73303ae into elastic:main Oct 11, 2023
21 checks passed
bhapas pushed a commit to bhapas/beats that referenced this pull request Oct 12, 2023
…ograms into Elasticsearch histograms (elastic#36647)

* Align on the algorithm used to transform Prometheus histograms into Elasticsearch histograms: Use the preceding bucket's value for +Inf 'le', for the first bucket only: if it has a negative 'le', use the value as-is; add test for the negative buckets; extend explanation on the counts calculation

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix prometheus remote_write tests; regenerate istio expected documents; revert unrelated changes

Signed-off-by: Tetiana Kravchenko <[email protected]>

* add link to the design/motivation of the histogram transformation logic

Signed-off-by: Tetiana Kravchenko <[email protected]>

---------

Signed-off-by: Tetiana Kravchenko <[email protected]>
Scholar-Li pushed a commit to Scholar-Li/beats that referenced this pull request Feb 5, 2024
…ograms into Elasticsearch histograms (elastic#36647)

* Align on the algorithm used to transform Prometheus histograms into Elasticsearch histograms: Use the preceding bucket's value for +Inf 'le', for the first bucket only: if it has a negative 'le', use the value as-is; add test for the negative buckets; extend explanation on the counts calculation

Signed-off-by: Tetiana Kravchenko <[email protected]>

* fix prometheus remote_write tests; regenerate istio expected documents; revert unrelated changes

Signed-off-by: Tetiana Kravchenko <[email protected]>

* add link to the design/motivation of the histogram transformation logic

Signed-off-by: Tetiana Kravchenko <[email protected]>

---------

Signed-off-by: Tetiana Kravchenko <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
8.11-candidate needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants