-
Notifications
You must be signed in to change notification settings - Fork 105
Conversation
a4f76c5
to
1b4d285
Compare
why is it optional? what happens to invalid tags if we "accept" them? and why would we accept them? |
It is optional because when enforced then it introduces new restrictions which previously have not been applied. That way some current user who isn't sure whether some of their metrics would get rejected can just disable the enforcement and look at the new |
If metrics with invalid tags get accepted, as long as they still contain a |
adds new configuration option which decides whether ingested metrics with invalid tags should be rejected or not. even if rejection is disabled a new counter will be increased every time when an invalid metric has been received. this should make it easy for users who are not sure whether they currently send invalid metrics to MT to figure it out before they enable the rejection
ingests valid metrics, such with invalid tags, and such with invalid tag values. it does each of those cases once with invalid metric rejection enabled and once with it disabled. at the end of each test it verifies whether the counters have been updated correctly and whether the index has been grown by the expected size.
1b4d285
to
ae9ee2e
Compare
Now that #1335 is merged I've rebased this onto master |
see https://github.com/grafana/metrictank/blob/master/docs/CONTRIBUTING.md#when-contributing-prs rule 16: potentially breaking change requires changelog update |
also rule 8! |
in.invalidTagMD.Inc() | ||
if !rejectInvalidTags { | ||
log.Debugf("in: Invalid metric %v, not rejecting it because rejection due to invalid tags is disabled: %s", md, err) | ||
ignoreError = true |
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 is fragile because md.Validate() just returns the first failure it encounters (out of possibly many). we rely on the implementation detail that in md.Validate(), the tag check is the last one.
it's possible that an md is invalid for multiple reasons. if we ever add another validation check after the tag check, we would ignore that other failure.
But i don't see a simple solution, so it's probably fine. maybe add a comment about this
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.
good point, will add a comment
input/input_test.go
Outdated
rejectInvalidTags = false | ||
data := getTestMetricData() | ||
data.Tags = []string{"valid=tag"} | ||
testIngestMetricData(t, "valid_with_rejection_0", data, handler, index, 0, 0, 1) |
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.
why don't we follow the best practice of 1 function that has all the cases listed as entries in a table?
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.
Just because it results in clearer errors when one fails. but I can easily change that
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.
also, this is a lot of code for testing something that should be fairly trivial. especially all the code around dynamically generating test data, do we need it?
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.
It definitely helps to make sure that the logic does what we want it to, and to ensure it doesn't get changed by accident in the future for example due to changes in raintank/schema.
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.
needs a couple tweaks
c22f89d
to
f3283df
Compare
f3283df
to
ba021f9
Compare
@Dieterbe thx for the review. I think I've addressed all the comments. |
This gives users the option to reject ingested metrics with invalid tags. Even when rejection is disabled it counts the metrics with invalid tags, this should make it easy for users to predict whether enabling the rejection is going to actually reject some of their metrics or not.
Also updates the vendored
raintank/schema
to the latest version, because it uses the new tag validation functions.This is part of: grafana/grafana#15261
As discussed in: #1217 (comment)
Depends on this PR to be merged, because otherwise with the latest
raintank/schema
the serialization ofcwr.ChunkWriteRequest
is broken: #1335The benchmarks look about the same with and without this change: