Make the importer utilities rely on TSDB-GW for authentication and org-association#1335
Make the importer utilities rely on TSDB-GW for authentication and org-association#1335
Conversation
e20989d to
b9ecb6a
Compare
| uriPath = flag.String("uri-path", "/chunks", "the URI on which we expect chunks to get posted") | ||
| numPartitions = flag.Int("num-partitions", 1, "Number of Partitions") | ||
| logLevel = flag.String("log-level", "info", "log level. panic|fatal|error|warning|info|debug") | ||
| orgId = flag.Int("org-id", -1, "the id of the org we import to") |
There was a problem hiding this comment.
I think we should set the default to '0', which should mean dont do org-id check.
25f1457 to
20ffe51
Compare
|
I pushed quite a different implementation, as discussed in #1334 |
|
Just like last time, Once this is accepted I'll create a PR to raintank/schema for those changes and once it's merged there I'll update the vendored raintank/schema here. |
61673e0 to
f8743a2
Compare
| listenPort = flag.Int("listen-port", 8080, "The port to listen on") | ||
| ttlsStr = flag.String("ttls", "35d", "list of ttl strings used by MT separated by ','") | ||
| partitionScheme = flag.String("partition-scheme", "bySeries", "method used for partitioning metrics. This should match the settings of tsdb-gw. (byOrg|bySeries)") | ||
| uriPath = flag.String("uri-path", "/chunks", "the URI on which we expect chunks to get posted") |
There was a problem hiding this comment.
uriPath needs updating to "/metrics/import"
| return ChunkWriteRequest{ChunkWriteRequestPayload{ttl, t0, data, ts}, callback, key} | ||
| } | ||
|
|
||
| // ChunkWriteRequestWithoutOrg is used by the importer utility to send cwrs over the network |
There was a problem hiding this comment.
if you need to document a structure in mdata that it's [only] used by a specific tool, then we should just move that structure to a package for that tool.
e.g. create a package importer and create a ChunkWriteRequest type in there?
There was a problem hiding this comment.
all of cmd/mt-whisper-importer-reader/conversion.go should go into an importer package as well, cmd is meant for the main program code.
There was a problem hiding this comment.
good idea. where would you suggest i put that importer package? should that live in mdata since it is all kind of related to data handling & conversion?
There was a problem hiding this comment.
sounds good, if you don't run into circular import problems
| exitOnError = flag.Bool("exit-on-error", false, "Exit with a message when there's an error") | ||
| httpEndpoint = flag.String("http-endpoint", "127.0.0.1:8080", "The http endpoint to listen on") | ||
| listenAddress = flag.String("listen-address", "127.0.0.1", "The address to listen on") | ||
| listenPort = flag.Int("listen-port", 8080, "The port to listen on") |
There was a problem hiding this comment.
why are you changing this? the commit message "importer transfers cwrs without org" doesn't give any clues..
why not keep this consistent with http.listen? (the config option used for MT to establish its listen address and port)
There was a problem hiding this comment.
right, i think this temporarily made sense during some older revision, but now not anymore. changing it back
|
|
||
| // SerializableChunkWriteRequest is used by the importer utility to send cwrs over the network | ||
| // It does not contain the org id because this is assumed to be defined by the auth mechanism | ||
| type SerializableChunkWriteRequest struct { |
There was a problem hiding this comment.
"serializable" is not helpful because pretty much all datastructures are serializable .
I would just stick with the name ChunkWriteRequest, the fact that this is in the importer package already gives a solid clue that this CWR type is specific to the importer.
You can see the same pattern in stdlib, for example https://golang.org/pkg/html/template/#Template and https://golang.org/pkg/text/template/#Template
There was a problem hiding this comment.
For example the .Callback property of the mdata.ChunkWriteRequest is not serializable because that's a memory address. But I'm fine either way, I'll rename it back to ChunkWriteRequest
c43e9fe to
ebf5284
Compare
|
I've moved all the importer-related logic into the importer package, please take another look |
0053fd1 to
8b99e7f
Compare
|
FYI I've done another test import with the latest version of the writer & reader, once into BigTable and once into Cassandra, and they both look as expected. |
|
these two changes were in reaction to PR comments
also move all the related tests keep incResolution() and decResolution() as stand-alone functions because that way they're way more testable than if they were an integrated method of the conversion type
the instantiation of the ArchiveRequest struct should be located together with the struct definition, this moves it there
|
sorry about that, fixed the docs |
Dieterbe
left a comment
There was a problem hiding this comment.
LGTM. i didn't look very thoroughly, but you've tested this fairly well right? then i think this is good to go
|
Cool, thx. Yeah, I've done multiple test imports |
|
I didn't update the vendored raintank/schema yet (#1335 (comment)). I'll make a PR for that, because otherwise the build is broken |
This change makes the importer rely on tsdb-gw to authenticate the incoming requests and associate them with an org-id based on the user the authenticated as.
It also creates a new
mdata/importerpackage which contains all the importer data conversion logic and the related structs for sending the data over the wire.fixes #1334