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

receive: Enable exemplars ingestion and querying #4292

Merged
merged 11 commits into from
Jun 17, 2021

Conversation

onprem
Copy link
Member

@onprem onprem commented Jun 1, 2021

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

  • Enable exemplar ingestion in Receive
  • Add exemplars API implementation for TSDB and MultiTSDB
  • Expose exemplars gRPC API from Receive

Fixes #4235

Verification

  • Local testing, modified some existing tests for ingestion. Need to add E2E tests.

Copy link
Member

@wiardvanrij wiardvanrij left a comment

Choose a reason for hiding this comment

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

I've done a review but it's not on the technical part but more 'usability' part :) Really looking forward to this feature 👍

pkg/exemplars/multitsdb.go Outdated Show resolved Hide resolved
pkg/exemplars/multitsdb.go Show resolved Hide resolved
@@ -104,6 +135,18 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR
level.Warn(r.logger).Log("msg", "Error on ingesting samples that are too old or are too far into the future", "numDropped", numOutOfBounds)
errs.Add(errors.Wrapf(storage.ErrOutOfBounds, "add %d samples", numOutOfBounds))
}
if numExemplarsOutOfOrder > 0 {
level.Warn(r.logger).Log("msg", "Error on ingesting out-of-order exemplars", "numDropped", numExemplarsOutOfOrder)
Copy link
Member

Choose a reason for hiding this comment

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

It's a level warn, but the logger msg says it's an error. I would make the message more generic and let log level handle the prefix, like: "warn: exemplars out of order" or something like that.

Copy link
Member Author

@onprem onprem Jun 1, 2021

Choose a reason for hiding this comment

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

I was following what we do for samples. I'd like other's opinion here as well to either switch to level.Error, remove Error from message, or keep it as it.

I think the message was there to indicate there is an error, but it's not fatal maybe?

Copy link
Member

Choose a reason for hiding this comment

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

I think we are not too strict here, so it's fine to say error if it's only a warning about the not serious error.

Copy link
Member

Choose a reason for hiding this comment

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

If we handle the returned error on upper levels (this could be logging as well), we don't need to log/handle it twice. I see that you've just followed the existing structure so it seems ok for now.

Copy link
Member

Choose a reason for hiding this comment

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

hm.. what I don't like is duplicate error handling. We both add error and warn error... Wonder if we could just handle that on caller side instead. 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is a bit icky but as Kemal noted I was just following the existing structure we use for sample. I think I can try refactoring this in a follow up PR if that's ok.

pkg/receive/writer.go Outdated Show resolved Hide resolved
pkg/receive/writer.go Outdated Show resolved Hide resolved
cmd/thanos/receive.go Outdated Show resolved Hide resolved
pkg/exemplars/multitsdb.go Show resolved Hide resolved
pkg/exemplars/tsdb.go Show resolved Hide resolved
@onprem onprem marked this pull request as ready for review June 2, 2021 12:14
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

I don't see the code of forwarding exemplars. I assume only timeserieses are forwarded. Do you want to include the exemplars part in this pr?

pkg/receive/handler.go Show resolved Hide resolved
pkg/exemplars/tsdb.go Outdated Show resolved Hide resolved
pkg/exemplars/tsdb.go Show resolved Hide resolved
pkg/receive/multitsdb.go Outdated Show resolved Hide resolved
pkg/exemplars/tsdb.go Show resolved Hide resolved
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Really awesome work! Thanks for your patience.

yeya24
yeya24 previously approved these changes Jun 7, 2021
Copy link
Contributor

@yeya24 yeya24 left a comment

Choose a reason for hiding this comment

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

Nice! LGTM

kakkoyun
kakkoyun previously approved these changes Jun 11, 2021
Copy link
Member

@kakkoyun kakkoyun left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@@ -104,6 +135,18 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR
level.Warn(r.logger).Log("msg", "Error on ingesting samples that are too old or are too far into the future", "numDropped", numOutOfBounds)
errs.Add(errors.Wrapf(storage.ErrOutOfBounds, "add %d samples", numOutOfBounds))
}
if numExemplarsOutOfOrder > 0 {
level.Warn(r.logger).Log("msg", "Error on ingesting out-of-order exemplars", "numDropped", numExemplarsOutOfOrder)
Copy link
Member

Choose a reason for hiding this comment

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

If we handle the returned error on upper levels (this could be logging as well), we don't need to log/handle it twice. I see that you've just followed the existing structure so it seems ok for now.

@kakkoyun kakkoyun requested review from bwplotka and yeya24 June 11, 2021 06:59
bwplotka
bwplotka previously approved these changes Jun 11, 2021
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

This is epic!!! LGTM 💪🏽

From when @onprem you are full-pledge backend engineer with so much skill for high quality work like this? 😱

@@ -104,6 +135,18 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR
level.Warn(r.logger).Log("msg", "Error on ingesting samples that are too old or are too far into the future", "numDropped", numOutOfBounds)
errs.Add(errors.Wrapf(storage.ErrOutOfBounds, "add %d samples", numOutOfBounds))
}
if numExemplarsOutOfOrder > 0 {
level.Warn(r.logger).Log("msg", "Error on ingesting out-of-order exemplars", "numDropped", numExemplarsOutOfOrder)
Copy link
Member

Choose a reason for hiding this comment

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

hm.. what I don't like is duplicate error handling. We both add error and warn error... Wonder if we could just handle that on caller side instead. 🤔

@kakkoyun
Copy link
Member

Let's rebase and merge this

onprem added 10 commits June 17, 2021 00:57
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
Signed-off-by: Prem Saraswat <prmsrswt@gmail.com>
@yeya24 yeya24 enabled auto-merge (squash) June 17, 2021 02:37
Copy link
Member

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

Solid work 😱

LGTM!

@yeya24 yeya24 merged commit 13ab756 into thanos-io:main Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Receiver can ingest exemplars via remote write
5 participants