-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Implement federated exemplar API #3846
Conversation
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Thanks for the great work! Looks perfect at the first glance. I will do some detailed review next week. Have you tested this manually with the WIP upstream branch? prometheus/prometheus#6635 |
Not yet 😅 . Will be doing it very soon. |
I fixed some existing problems in this pr and it is working now! Will add some detailed comments tomorrow. Feel free to check my commit here. If you want to experiment with this, feel free to try this tns app https://github.com/yeya24/tns/tree/thanos/production/docker-compose. I added Thanos sidecar and querier there. It works smoothly. Thanks @goku321! |
pkg/api/query/v1.go
Outdated
@@ -152,6 +158,8 @@ func (qapi *QueryAPI) Register(r *route.Router, tracer opentracing.Tracer, logge | |||
r.Get("/rules", instr("rules", NewRulesHandler(qapi.ruleGroups, qapi.enableRulePartialResponse))) | |||
|
|||
r.Get("/metadata", instr("metadata", NewMetricMetadataHandler(qapi.metadatas, qapi.enableMetricMetadataPartialResponse))) | |||
|
|||
r.Get("/exemplars", instr("exemplars", NewExemplarsHandler(qapi.exemplars, qapi.enableExemplarPartialResponse))) |
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.
Let's be consistent with the upstream PR https://github.com/prometheus/prometheus/pull/6635/files#diff-9bcb876da5d17ef1046ab5ea531bbaaf64d753a7beaa2cb11a3fe6dd94e16563R349.
The endpoint is query_exemplars
pkg/api/query/v1.go
Outdated
} | ||
|
||
return func(r *http.Request) (interface{}, []error, *api.ApiError) { | ||
typeParam := r.URL.Query().Get("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.
What's this param for?
Let's be consistent with the upstream pr.
The params we want to have are:
- `query=<string>`: Prometheus expression query string.
- `start=<rfc3339 | unix_timestamp>`: Start timestamp.
- `end=<rfc3339 | unix_timestamp>`: End timestamp.
string instance = 1 [(gogoproto.jsontag) = "instance"]; | ||
string job = 2 [(gogoproto.jsontag) = "job"]; | ||
string service = 3 [(gogoproto.jsontag) = "service"]; | ||
} |
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.
This seems not used. Let's remove it.
pkg/exemplars/exemplarspb/rpc.proto
Outdated
double value = 2 [(gogoproto.jsontag) = "value"]; | ||
google.protobuf.Timestamp ts = 3 [(gogoproto.jsontag) = "timestamp", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; | ||
bool hasts = 4 [(gogoproto.jsontag) = "hasTimestamp"]; | ||
} |
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.
Please add a new line.
pkg/exemplars/exemplarspb/rpc.proto
Outdated
message Exemplar { | ||
ZLabelSet labels = 1 [(gogoproto.jsontag) = "labels", (gogoproto.nullable) = false]; | ||
double value = 2 [(gogoproto.jsontag) = "value"]; | ||
google.protobuf.Timestamp ts = 3 [(gogoproto.jsontag) = "timestamp", (gogoproto.stdtime) = true, (gogoproto.nullable) = false ]; |
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.
Let's use int64 type here to be consistent with the TS type in prometheus https://github.com/prometheus/prometheus/pull/6635/files#diff-fba4b55f88ed50da9d6d2624ba745f9347cdc87a80bac431a090aee67a49c02fR23
pkg/promclient/promclient.go
Outdated
// NOTE: This method is tested in pkg/store/prometheus_test.go against Prometheus. | ||
func (c *Client) ExemplarsInGRPC(ctx context.Context, base *url.URL, typeExemplars string) ([]*exemplarspb.ExemplarData, error) { | ||
u := *base | ||
u.Path = path.Join(u.Path, "/api/v1/exemplars") |
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.
Ditto. Let's change the endpoint.
pkg/promclient/promclient.go
Outdated
// Prometheus does not support PartialResponseStrategy, and probably would never do. Make it Abort by default. | ||
for _, g := range m.Data { | ||
g.PartialResponseStrategy = storepb.PartialResponseStrategy_ABORT | ||
} |
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 guess we don't need to keep this PartialResponseStrategy
field in the proto. Let's remove it for now.
pkg/exemplars/exemplarspb/rpc.proto
Outdated
// message Label { | ||
// string name = 1 [(gogoproto.jsontag) = "name"]; | ||
// string value = 2 [(gogoproto.jsontag) = "value"]; | ||
// } |
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.
Let's remove this
|
||
warnings []error | ||
data []*exemplarspb.ExemplarData | ||
} |
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.
Let's add two additional methods for it yeya24@1b6abfc#diff-d09c4014e056aee5c67a76aca788de273aecb440edefc8a3b040bc77e27f2c38R39-R55, otherwise it will panic.
@goku321 Let me know your availability. If it is acceptable I can open a pr to your branch as I have a working version already yeya24@1b6abfc. |
Hi @yeya24 , I was a bit caught up, thanks for your patience. By all means. Please go ahead with the pr. I am glad to have your help on this. I really appreciate your time and effort on fixing this pr.
|
It is not urgent. Anyway, we need to wait for the upstream Prometheus pr first XD |
Sure, I'll try out the tns app to get a better understanding. |
Signed-off-by: Deepak <[email protected]>
pkg/exemplars/proxy.go
Outdated
) | ||
|
||
// Proxy implements exemplarspb.Exemplars gRPC that fanouts requests to | ||
// given exemplarspb.Exemplars and de-duplication on the way. |
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.
Let's update this comment. Currently, Proxy itself does not deduplicate. Instead, the it seems to be a responsibility of the caller of proxy.Exemplars to deduplication. Alternatively, we can make it so that the Proxy needs to deduplication.
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
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.
@goku321 Thanks for the great work! This is super close now, only some nits and testcases are left.
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
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.
Perfect work @goku321. One last thing, can you please update the changelog?
I think this pr is ready to merge. But it would be better to have another 👀 for a final look.
Note: There is no E2E API test for this feature now as we don't have an app instrumented with exemplars. We can move E2E part to another pr.
Signed-off-by: Deepak <[email protected]>
Signed-off-by: Deepak <[email protected]>
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.
Looks clean to me!
Signed-off-by: Deepak [email protected]
Fixes: #3435
This PR follows the PR #3350 and comment #3345 to implement the Prometheus exemplar API
Changes
Add federated exemplar api to query and sidecar.
Verification
testing in progress