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
Metrics: Add push client to push metrics to endpoint #3762
Metrics: Add push client to push metrics to endpoint #3762
Conversation
depends on #3743 for the prometheus vendor dependencies |
pkg/metrics/pushclient/pushclient.go
Outdated
// Do is a custom written client to send data to the prometheus aggregate | ||
// gateway. It creates a new client and pushes the body that was passed to this function. | ||
// https://godoc.org/github.com/prometheus/client_golang/prometheus/push#HTTPDoer | ||
func (a *aggregationClient) Do(req *http.Request) (resp *http.Response, err error) { |
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.
We don't need this aggregation Client anymore as of weaveworks/prom-aggregation-gateway#31, right?
We think support for a custom Client will be a production requirement for authenticating to telemeter, so we should probably keep the ability to inject a custom client, but just inject the default (without overriding Do
)
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.
Shouldn't we create a custom round tripper inside the Do function? For now we don't need it so I'll default the Do function to call the http.Client Do function.
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.
Shouldn't we create a custom round tripper inside the Do function
@squat will providing a custom implementation of the Do
function be sufficient to allow authentication to telemeter? when we met with the observability group, it was said we need a "custom roundtripper" but I think this Do function was what was actually meant, because that is all the standard prometheus push client uses...
173976d
to
bf80da2
Compare
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.
rather than passing client and url in the push function, I would personally rather see that we initialize a push client which has fields for the url and client.
pkg/metrics/pushclient/pushclient.go
Outdated
// Do is a custom written client to send data to the prometheus aggregate | ||
// gateway. It creates a new client and pushes the body that was passed to this function. | ||
// https://godoc.org/github.com/prometheus/client_golang/prometheus/push#HTTPDoer | ||
func (a *aggregationClient) Do(req *http.Request) (resp *http.Response, err error) { |
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.
Shouldn't we create a custom round tripper inside the Do function
@squat will providing a custom implementation of the Do
function be sufficient to allow authentication to telemeter? when we met with the observability group, it was said we need a "custom roundtripper" but I think this Do function was what was actually meant, because that is all the standard prometheus push client uses...
0604264
to
6251876
Compare
8e74e01
to
ac6ba54
Compare
ac6ba54
to
71c6a0f
Compare
Looks like CI is failing because the pkgs are not vendored in. |
The other metrics PR has the vendor commits in place so I was thinking of waiting for that to merge and I'll use them instead of pushing fresh vendor files again. |
71c6a0f
to
61651ad
Compare
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.
left some nitpicky suggestions. I think the main thing is to rethink the test structure.
// Push takes care of the actual code that pushes to the prometheus | ||
// aggregation gateway. It takes a list of collectors and pushes all of them to the desired url. | ||
func (p *PushClient) Push(collectors ...prometheus.Collector) error { | ||
pushClient := push.New(p.URL, p.JobName).Client(p.Client).Format(expfmt.FmtText) |
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.
note: I'm not sure if we will want to stick with Format(expfmt.FmtText)
but it is good for right now and works with our testing. I am fine merging this and we can change later.
d961f16
to
c8e4921
Compare
Creates a push client that will be used to push metrics to Prometheus Aggregation Gateway. The client can be used for any type of Gateway and it takes in the URL and the HTTP Client that would have all the necessary information(authentication) required to push to the gateway. Configured to take in Prometheus Objects for pushing to gateway. https://github.com/prometheus/client_golang/tree/master/prometheus
Added additional prometheus push client dependencies that are required to push.
c8e4921
to
3dec684
Compare
/lgtm |
@abhinavdahiya still needs /approve |
/lgtm |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: abhinavdahiya The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest Please review the full test history for this PR and help us cut down flakes. |
11 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@rna-afk: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
/retest Please review the full test history for this PR and help us cut down flakes. |
One thing we missed in this PR was that the client will need the pull secret, and (probably) the cluster ID. we don't need them yet and that is fine, but it is almost certain we will need them. |
Creates a push client that will be used to push metrics to
Prometheus Aggregation Gateway. The client can be used for
any type of Gateway and it takes in the URL and the HTTP Client
that would have all the necessary information(authentication)
required to push to the gateway.
Configured to take in Prometheus Objects for pushing to gateway.
https://github.com/prometheus/client_golang/tree/master/prometheus