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

Add prometheus.receive_http component to allow receiving metrics over HTTP #3753

Merged
merged 12 commits into from
May 10, 2023

Conversation

thampiotr
Copy link
Contributor

@thampiotr thampiotr commented May 2, 2023

PR Description

Adds a new prometheus.receive_http component to allow receiving metrics over HTTP.

Which issue(s) this PR fixes

Fixes #2780

PR Checklist

  • Finish the draft
  • CHANGELOG updated
  • Documentation added
  • Tests updated

@thampiotr thampiotr force-pushed the thampiotr/flow-receive-metrics-over-http branch from 50086b9 to fa6739a Compare May 2, 2023 16:18
@thampiotr thampiotr requested a review from tpaschalis May 2, 2023 16:19
@thampiotr thampiotr force-pushed the thampiotr/flow-receive-metrics-over-http branch 6 times, most recently from ebf9540 to 733aa95 Compare May 5, 2023 13:34
@thampiotr thampiotr force-pushed the thampiotr/flow-receive-metrics-over-http branch from 936db14 to f01609a Compare May 5, 2023 13:44
Copy link
Contributor Author

@thampiotr thampiotr left a comment

Choose a reason for hiding this comment

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

PTAL - ready for review

go.mod Outdated
@@ -171,7 +171,7 @@ require (
golang.org/x/time v0.3.0
google.golang.org/api v0.109.0
google.golang.org/grpc v1.52.3
google.golang.org/protobuf v1.28.1
google.golang.org/protobuf v1.30.0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The update was needed so that I can use the protoadapt package in api_test.go - see comments in that file for more details.

return err
}

buf, err := proto.Marshal(protoadapt.MessageV2Of(req))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need to use protoadapt.MessageV2Of since the Agent repo uses the new V2 google.golang.org/protobuf library, while prometheus uses the V1 github.com/golang/protobuf library. Importing the V1 is a linter error.

In order to use the protoadapt, I had to upgrade the google.golang.org/protobuf to 1.30.0 - see go.mod.

I don't think it's a problem since it's a minor version and we would eventually want to update this dependency anyway.

component/prometheus/source/api/api.go Outdated Show resolved Hide resolved
@thampiotr thampiotr marked this pull request as ready for review May 5, 2023 14:10
Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

Nice progress, this is getting close! Comments are mainly around documentation and naming, looking forward to seeing this land!

component/prometheus/source/api/api.go Outdated Show resolved Hide resolved
component/prometheus/source/api/api.go Outdated Show resolved Hide resolved
component/prometheus/source/api/api.go Outdated Show resolved Hide resolved
@@ -0,0 +1,392 @@
package api
Copy link
Member

Choose a reason for hiding this comment

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

Nice and readable testing! :)

})
}

type Arguments struct {
Copy link
Member

Choose a reason for hiding this comment

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

(not a blocker, just putting some thoughts out, I'm on the fence on whether we should handle this or not)/

Right now, a user can pass a gRPC block (even if we don't explicitly call it out or document it). Should we provide an UnmarshalRiver method that validates against it and returns an error if it's being set? Should we create wrappers for http-only and grpc-only flavors of common/net? This is related to what you're proposing on #3780 and the two issues we've opened upstream so let's discuss this a bit more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That would make things more user-friendly, however, it seems like a temporary workaround and the GRPC server will still start anyway...

I think we would ideally want a server that can have HTTP/GRPC only and also separate squash-ed HTTP and GRPC blocks. That way, if someone provided GRPC config to this component, the river syntax check would give an error without any boilerplate code.

component/prometheus/source/api/api.go Outdated Show resolved Hide resolved
@thampiotr thampiotr changed the title Add prometheus.source.api component to allow receiving metrics over HTTP Add prometheus.receive_http component to allow receiving metrics over HTTP May 9, 2023
@tpaschalis tpaschalis self-requested a review May 10, 2023 09:10
Copy link
Member

@tpaschalis tpaschalis left a comment

Choose a reason for hiding this comment

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

LGTM, nice!

@tpaschalis tpaschalis merged commit b71ca82 into main May 10, 2023
@tpaschalis tpaschalis deleted the thampiotr/flow-receive-metrics-over-http branch May 10, 2023 12:02
@github-actions github-actions bot added the frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed. label Feb 26, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
frozen-due-to-age Locked due to a period of inactivity. Please open new issues or PRs if more discussion is needed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flow: allow receiving remote_write metrics over HTTP
3 participants