-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Openmetrics support using textparser #27269
Openmetrics support using textparser #27269
Conversation
This pull request is now in conflicts. Could you fix it? 🙏
|
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
💚 Flaky test reportTests succeeded. 🤖 GitHub commentsTo re-run your PR in the CI, just comment with:
|
This pull request is now in conflicts. Could you fix it? 🙏
|
This pull request is now in conflicts. Could you fix it? 🙏
|
This pull request is now in conflicts. Could you fix it? 🙏
|
Pinging @elastic/integrations (Team:Integrations) |
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank for this PR @premendrasingh , it is going into the right direction I think!
I left some comments inline, mostly about minors, but overall the patch looks good. My two main concenrs are:
- I see a lot of code duplication between between this module and prometheus module around helper functionalities. Wondering if we could handle it better by introducing one common library?
- I see we add new types with PR. Maybe this needs evaluation product-wise.
@exekias @jsoriano your feedback is more than welcome here :).
return m.skipFamilyName(*family.Name) | ||
} | ||
|
||
func (m *MetricSet) skipFamilyName(family string) bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see/expect some replication of code between the 2 modules (prometheus and openmetircs) so maybe we can move those methods to a utility library when we refactor prometheus module too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will be better to have a separate PR for refactoring this into a utility library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeap, doing this when we change prometheus module to use textparser or in a different follow-up sounds good.
) | ||
|
||
const ( | ||
openMetricsTestSamples = `# TYPE first_metric gauge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add a case with exemplar
s?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review comments.
- name: type | ||
type: keyword | ||
description: > | ||
metric type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to Metric
if m.skipFamily(family) { | ||
continue | ||
} | ||
promEvents := m.promEventsGen.GenerateOpenMetricsEvents(family) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. Changed to openMetricsEvents
eventList[promEvent.Type][labelsHash]["exemplar"] = promEvent.Exemplars | ||
} | ||
// Accumulate metrics in the event | ||
eventList[promEvent.Type][labelsHash].DeepUpdate(promEvent.Data) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked into the details of how each metric type is handled, but overall this is looking good.
go.mod
Outdated
) | ||
|
||
replace ( | ||
github.com/Azure/go-autorest => github.com/Azure/go-autorest v12.2.0+incompatible | ||
github.com/Azure/go-autorest => github.com/Azure/go-autorest v14.2.0+incompatible | ||
github.com/Microsoft/go-winio => github.com/bi-zone/go-winio v0.4.15 | ||
github.com/Shopify/sarama => github.com/elastic/sarama v1.19.1-0.20210120173147-5c8cb347d877 | ||
github.com/cucumber/godog => github.com/cucumber/godog v0.8.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many changes here seem unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream rebase removed it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Umnm, there are still many other changes in go.sum that look unrelated (for google could, oracle, azure...).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleaned up go.mod, go.sum. Please guide me if it is still not right.
This pull request is now in conflicts. Could you fix it? 🙏
|
/test |
/test |
/test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for contributing this one!
This pull request does not have a backport label. Could you fix it @premendrasingh? 🙏
NOTE: |
Thanks a lot @ChrsMark |
Happy to see this merged 🙂 Thanks @premendrasingh and @ChrsMark! |
Enhancement - Added openmetrics module to use Openmetrics parser.
What does this PR do?
This PR updated metricset in Openmetrics module. It handles metrics endpoints returning data with
Content-Type: application/openmetrics-text
Why is it important?
Many of our customers have data exposed in OpenMetrics format, but existing module piggy backs on Prometheus module which processes metrics only in expfmt, Openmetrics data is not handled properly. Hence the need for Openmetrics support also.
Checklist
CHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.How to test this PR locally
Unit tests in openmetrics/collector can be used to test the metrics locally.
Setup a http server to serve Openmetrics data with HTTP header
Content-Type: application/openmetrics-text
Change metricset in metricbeat.yml to use openmetrics/collector as shown below