Skip to content
This repository was archived by the owner on Aug 23, 2023. It is now read-only.

mt-gateway: support ingesting data into kafka #1608

Merged
merged 24 commits into from
Jan 23, 2020
Merged

mt-gateway: support ingesting data into kafka #1608

merged 24 commits into from
Jan 23, 2020

Conversation

fitzoh
Copy link
Contributor

@fitzoh fitzoh commented Jan 15, 2020

Initial portion of this PR was porting the github.com/raintank/tsdb-gw/publish package to this repository for use in a new HTTP proxy (see https://github.com/grafana/metrictank-ops/issues/542 if you have access).

The portion after this comment (specifically after the force push) pulls in the actual API endpoint and wires it up to Kafka.

A couple design decisions:

  • This is intended to be a simplified API, so rate limiting functionality has been removed.
  • As there is no concept of authentication/authorization within metrictank, the isAdmin=true path is always taken.

Once again, the latter portion of this PR is intended to be reviewed commit by commit.

Open questions:

  • Do we need to consider any licensing/attribution issues?
    • probably fine, could use a +1 from @woodsaj ✔️
  • Is there any dead code we can get rid of post-import?
    • removed ✔️
  • Should we maintain the instrumentation present in the original code?
    • leave it ✔️
  • Testing? Do we add this to a docker config? Which one?
    • toss it in docker-dev-custom-cfg-kafka alongside tsdb-gw for now

@fitzoh fitzoh requested a review from a team January 15, 2020 19:54
@replay
Copy link
Contributor

replay commented Jan 17, 2020

To be sure I understand this diff right, this doesn't change the Sarama version, it only adds another package right? I'm asking because when changing Sarama versions it's usually a good idea to do some benchmarks to verify that there are no regressions.

@replay
Copy link
Contributor

replay commented Jan 17, 2020

And currently none of this code which gets added is actually being used, right? That's all going to be used by your new http gateway?

@replay
Copy link
Contributor

replay commented Jan 17, 2020

By merging the dependencies of the mt-gateway into the MT repo separately before they actually get used, isn't there a risk that we accidentally copy more stuff from tsdb-gw than what's actually going to be used and this will then be left there as dead code, or are you sure that all of this is needed?

@robert-milan
Copy link
Contributor

To be sure I understand this diff right, this doesn't change the Sarama version, it only adds another package right? I'm asking because when changing Sarama versions it's usually a good idea to do some benchmarks to verify that there are no regressions.

Yes that is correct. I thought the same thing at first glance, but it only adds mocks.

I understand that breaking it up like this makes for smaller and easier to read PRs, but in this case it does seem a little bit awkward. I think this should be part of the PR that uses this code in the HTTP proxy. Since #1602 is already merged, can we just rename this PR and add the HTTP proxy changes here as well? It is easy enough to review commit by commit.

Do we need to consider any licensing/attribution issues?

We probably should take a look at everything

Are we able to omit any portion of this package?

That would be easier to determine once we see some of the implementation

Should we maintain the instrumentation present in the original?

I don't think we need to maintain the instrumentation unless there is a good reason for it.

@fitzoh
Copy link
Contributor Author

fitzoh commented Jan 17, 2020

To be sure I understand this diff right, this doesn't change the Sarama version, it only adds another package right? I'm asking because when changing Sarama versions it's usually a good idea to do some benchmarks to verify that there are no regressions.

Yes that is correct. I thought the same thing at first glance, but it only adds mocks.

Correct, @robert-milan

And currently none of this code which gets added is actually being used, right? That's all going to be used by your new http gateway?

yep

I understand that breaking it up like this makes for smaller and easier to read PRs, but in this case it does seem a little bit awkward. I think this should be part of the PR that uses this code in the HTTP proxy. Since #1602 is already merged, can we just rename this PR and add the HTTP proxy changes here as well? It is easy enough to review commit by commit.

Yeah, good call. This was mostly an attempt to unblock myself while #1602 was waiting on reviews... now that it's merged, I'll rebase and work on wiring things up wire things up

@fitzoh fitzoh changed the title Import publish package and dependencies from raintank/tsdb-gw Add kafka import endpoint + capabilities from raintank/tsdb-gw Jan 21, 2020
@fitzoh fitzoh removed the request for review from a team January 21, 2020 15:07
@fitzoh fitzoh requested a review from a team January 21, 2020 15:07
default:
log.Errorf("unable to read request body. %s", err)
ctx.JSON(500, err)
w.WriteHeader(500)
fmt.Fprintf(w, "unable to read request body. %s", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

there's a repeating pattern of writing a status code header, then writing a message on the following line, and in some cases also log a line with the same msg.
would it make sense to put these into a small helper like writeStatus(w, 499, "request cancelled", true) (the last param could determine whether to log).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that had crossed my mind.
Skipped the boolean and just always log @ error (successful ingestions take a different code path)

1abc592

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

Looks good, just a few minor comments

Copy link
Contributor

@replay replay left a comment

Choose a reason for hiding this comment

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

LGTM

@Dieterbe Dieterbe changed the title Add kafka import endpoint + capabilities from raintank/tsdb-gw mt-gateway: support ingesting data into kafka Jan 23, 2020
@Dieterbe Dieterbe merged commit 9450798 into master Jan 23, 2020
@Dieterbe Dieterbe deleted the kafka-publish branch January 23, 2020 14:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants