-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Allow for loki-canary to generate a percentage of out of order log lines #4126
Conversation
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.
Some nits then lgtm
cmd/loki-canary/main.go
Outdated
@@ -42,6 +42,10 @@ func main() { | |||
queryTimeout := flag.Duration("query-timeout", 10*time.Second, "How long to wait for a query response from Loki") | |||
|
|||
interval := flag.Duration("interval", 1000*time.Millisecond, "Duration between log entries") | |||
outOfOrderPercentage := flag.Int("out-of-order-percentage", 0, "Percentage (0-100) of log entries that should be sent out of order.") | |||
outOfOrderMin := flag.Int("out-of-order-min", 30, "Minimum amount of time to go back for out of order entries (in seconds).") |
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 make these time.Duration
instead of an int measuring seconds for ease of use.
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.
thought this would make the math ugly later on, but it's fine since <time.Duration>.Seconds()
exists, so done
pkg/canary/writer/writer.go
Outdated
@@ -58,6 +65,10 @@ func (w *Writer) run() { | |||
select { | |||
case <-t.C: | |||
t := time.Now() | |||
if i := rand.Intn(99) + 1; i <= w.outOfOrderPercentage { |
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.
if i := rand.Intn(99) + 1; i <= w.outOfOrderPercentage { | |
if i := rand.Intn(100) + 1; i <= w.outOfOrderPercentage { |
I think this should be Intn(100)
due to inclusivity ([0,n)
).
edit: Oh I see, were you using 99
then adding one in order to ensure it was at least one second behind? I see the appeal, but I think it's unnecessarily complex as we're only guaranteeing it's older than time.Now()
, not necessarily the log line previously sent.
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.
No you're right it should be 100
, I misread the notation.
This rng is to decide whether the log line should be out of order in the first place, not how much time to subtract.
order timestamps, percentage and out of order time range is all configurable. Signed-off-by: Callum Styan <callumstyan@gmail.com>
percentage check. Signed-off-by: Callum Styan <callumstyan@gmail.com>
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 ran this locally and think there are a few pieces missing. Notably, the reader and comparator currently expect the data to be ordered and will likely need to be refactored to support unordered writes. This may end up being a nontrivial refactor, but worthwhile.
Without unordered writes enabled we get log lines (stderr) like this in the canary
The first block is from the The second block is from the comparators code
We don't see log lines from either of the above example blocks if EDIT: also note that we need to have promtail pipeline stages to use the generated timestamp from the canaries log lines as the actual timestamp, otherwise all the log lines are ordered as far as loki is concerned. |
various parts of the canary code are actually doing. Signed-off-by: Callum Styan <callumstyan@gmail.com>
We should ensure that the Also, the equality matcher in |
I think we should update the docs to include information about these changes and make it explicit you need to configure promtail time extraction from the log line for this to work. Aside from adding some docs this LGTM! |
…uirement to use pipeline stages. Signed-off-by: Callum Styan <callumstyan@gmail.com>
ref #1544 |
Allows loki canary to generate a percentage of log lines with out of order timestamps, percentage and out of order time range is configurable.
Signed-off-by: Callum Styan callumstyan@gmail.com