Skip to content

Conversation

@suikammd
Copy link
Contributor

@suikammd suikammd commented Jul 3, 2024

Fix #20763

@suikammd suikammd requested a review from a team as a code owner July 3, 2024 03:27
@github-actions github-actions bot added the domain: sinks Anything related to the Vector's sinks label Jul 3, 2024
let mut sink = LokiSink::new(config, client).unwrap();

let mut e1 = LogEvent::from("hello world");
use vector_lib::config::log_schema;
Copy link
Contributor

Choose a reason for hiding this comment

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

should we move this use statement to the beginning of this tests module?

Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Thanks @suikammd ! I left a question below about the behavior.


impl InternalEvent for LokiEventTimestampOutOfRangeError {
fn emit(self) {
error!(
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this a warn! since it doesn't actually inhibit processing? Also, what happens when we send an event to Loki without a timestamp? Does it just use the current timestamp?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

According to Loki api, timestamp is must.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I see, I missed that you are returning early. In that case we'd want to emit the metrics for errors and discarded events. See an example here:

impl<'a> InternalEvent for SplunkInvalidMetricReceivedError<'a> {
fn emit(self) {
error!(
message = "Invalid metric received.",
error = ?self.error,
error_type = error_type::INVALID_METRIC,
stage = error_stage::PROCESSING,
value = ?self.value,
kind = ?self.kind,
internal_log_rate_limit = true,
);
counter!(
"component_errors_total", 1,
"error_type" => error_type::INVALID_METRIC,
"stage" => error_stage::PROCESSING,
);
counter!(
"component_discarded_events_total", 1,
"error_type" => error_type::INVALID_METRIC,
"stage" => error_stage::PROCESSING,
);
}
}


#[tokio::test]
async fn timestamp_out_of_range() {
use vector_lib::config::log_schema;
Copy link
Contributor

Choose a reason for hiding this comment

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

I meant the beggining of this module, about line 10. It is more idiomatic to have all the use statements at the begginning of the module, so we don't have to dive into each scope and find those statements.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get it, check the new commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, thats it! Thanks :)

Some(timestamp) => timestamp,
None => {
emit!(LokiEventTimestampOutOfRangeError);
return None;
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 also need to use the finalizers here and explicitly nack the event via update_status like finalizers.update_status(EventStatus::Errored). Otherwise Vector will consider them to have been successfully processed.

Some(Value::Timestamp(ts)) => match ts.timestamp_nanos_opt() {
Some(timestamp) => timestamp,
None => {
let finalizers = event.take_finalizers();
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 you already have the finalizers separated above on line 250.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, I missed this line

Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

Thanks @suikammd !

@jszwedko jszwedko enabled auto-merge July 9, 2024 15:48
@suikammd
Copy link
Contributor Author

suikammd commented Jul 12, 2024

@jszwedko It seems like I don't have the permissions to add the no-changelog label, can you help add this label?
image

@jszwedko
Copy link
Member

Thanks for the bump @suikammd . This change should actually have a changelog entry. Do you mind adding one? See https://github.com/vectordotdev/vector/blob/master/changelog.d/README.md for details.

auto-merge was automatically disabled July 12, 2024 16:39

Head branch was pushed to by a user without write access

@suikammd
Copy link
Contributor Author

Thanks for the bump @suikammd . This change should actually have a changelog entry. Do you mind adding one? See https://github.com/vectordotdev/vector/blob/master/changelog.d/README.md for details.

I add a changelog, but I accidentally rebased the master branch :(, sorry for that.

Copy link
Member

@jszwedko jszwedko left a comment

Choose a reason for hiding this comment

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

I think you still need to fill in the changelog fragment :) See https://github.com/vectordotdev/vector/blob/master/changelog.d/README.md for details about what the content should look like.

@@ -0,0 +1,3 @@
Loki sink drop events with timestamp can not parsed by chrono.
Copy link
Contributor

Choose a reason for hiding this comment

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

What about something like this?

Suggested change
Loki sink drop events with timestamp can not parsed by chrono.
Loki sink now drops events with non-parseable timestamps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Get it, but the word parseable is not recognized. Maybe should update the checklist.
image

Copy link
Contributor

@jorgehermo9 jorgehermo9 Jul 13, 2024

Choose a reason for hiding this comment

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

i'm not an english native speaker, maybe @jszwedko can help us here😁. I think the spelling is correct

@@ -0,0 +1,3 @@
Loki sink now drops events with non-processable timestamps.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Loki sink now drops events with non-processable timestamps.
Loki sink now drops events with non-parsable timestamps.

I think parsable is actually the correct spelling, but what you have here seems fine to me too. Thanks for adding the changelog!

@jszwedko jszwedko enabled auto-merge July 15, 2024 20:02
auto-merge was automatically disabled July 16, 2024 08:34

Head branch was pushed to by a user without write access

@jszwedko jszwedko enabled auto-merge July 16, 2024 13:02
auto-merge was automatically disabled July 17, 2024 03:36

Head branch was pushed to by a user without write access

@jszwedko jszwedko enabled auto-merge July 17, 2024 12:26
@jszwedko jszwedko added this pull request to the merge queue Jul 17, 2024
@github-actions
Copy link

Regression Detector Results

Run ID: f0915b07-01f9-49db-8378-34607e979f24 Metrics dashboard

Baseline: 5a10aa2
Comparison: 6d179e5

Performance changes are noted in the perf column of each table:

  • ✅ = significantly better comparison variant performance
  • ❌ = significantly worse comparison variant performance
  • ➖ = no significant change in performance

No significant changes in experiment optimization goals

Confidence level: 90.00%
Effect size tolerance: |Δ mean %| ≥ 5.00%

There were no significant changes in experiment optimization goals at this confidence level and effect size tolerance.

Experiments ignored for regressions

Regressions in experiments with settings containing erratic: true are ignored.

perf experiment goal Δ mean % Δ mean % CI links
file_to_blackhole egress throughput -9.48 [-16.31, -2.64]

Fine details of change detection per experiment

perf experiment goal Δ mean % Δ mean % CI links
http_elasticsearch ingress throughput +2.83 [+2.60, +3.07]
datadog_agent_remap_datadog_logs ingress throughput +2.75 [+2.55, +2.94]
http_to_http_acks ingress throughput +1.38 [+0.04, +2.72]
fluent_elasticsearch ingress throughput +1.12 [+0.62, +1.62]
syslog_log2metric_splunk_hec_metrics ingress throughput +0.70 [+0.59, +0.81]
syslog_humio_logs ingress throughput +0.69 [+0.56, +0.83]
otlp_http_to_blackhole ingress throughput +0.69 [+0.51, +0.87]
syslog_regex_logs2metric_ddmetrics ingress throughput +0.44 [+0.31, +0.56]
datadog_agent_remap_datadog_logs_acks ingress throughput +0.36 [+0.16, +0.56]
datadog_agent_remap_blackhole ingress throughput +0.26 [+0.16, +0.37]
socket_to_socket_blackhole ingress throughput +0.15 [+0.08, +0.21]
http_text_to_http_json ingress throughput +0.12 [-0.00, +0.25]
splunk_hec_indexer_ack_blackhole ingress throughput +0.02 [-0.07, +0.10]
http_to_s3 ingress throughput +0.01 [-0.25, +0.28]
http_to_http_noack ingress throughput +0.01 [-0.12, +0.14]
splunk_hec_route_s3 ingress throughput +0.01 [-0.32, +0.34]
splunk_hec_to_splunk_hec_logs_acks ingress throughput -0.00 [-0.13, +0.12]
splunk_hec_to_splunk_hec_logs_noack ingress throughput -0.01 [-0.10, +0.09]
http_to_http_json ingress throughput -0.14 [-0.22, -0.05]
syslog_loki ingress throughput -0.42 [-0.51, -0.33]
datadog_agent_remap_blackhole_acks ingress throughput -0.51 [-0.65, -0.37]
otlp_grpc_to_blackhole ingress throughput -0.93 [-1.06, -0.81]
syslog_splunk_hec_logs ingress throughput -1.02 [-1.12, -0.92]
syslog_log2metric_tag_cardinality_limit_blackhole ingress throughput -1.63 [-1.72, -1.53]
syslog_log2metric_humio_metrics ingress throughput -2.80 [-2.95, -2.65]
file_to_blackhole egress throughput -9.48 [-16.31, -2.64]

Explanation

A regression test is an A/B test of target performance in a repeatable rig, where "performance" is measured as "comparison variant minus baseline variant" for an optimization goal (e.g., ingress throughput). Due to intrinsic variability in measuring that goal, we can only estimate its mean value for each experiment; we report uncertainty in that value as a 90.00% confidence interval denoted "Δ mean % CI".

For each experiment, we decide whether a change in performance is a "regression" -- a change worth investigating further -- if all of the following criteria are true:

  1. Its estimated |Δ mean %| ≥ 5.00%, indicating the change is big enough to merit a closer look.

  2. Its 90.00% confidence interval "Δ mean % CI" does not contain zero, indicating that if our statistical model is accurate, there is at least a 90.00% chance there is a difference in performance between baseline and comparison variants.

  3. Its configuration does not mark it "erratic".

Merged via the queue into vectordotdev:master with commit 6d179e5 Jul 17, 2024
ym pushed a commit to ym/vector that referenced this pull request Aug 18, 2024
…otdev#20780)

* fix(loki sinks): Fix loki event timestamp out of range panic

* change LokiEventTimestampOutOfRangeError error to warn

* move use to begin of file

* update skipped events finalizer to errored

* fix: remove duplicate take finalizers

* add changelog

* fix changelog name

* fix spelling issue

* modify changelog contents

* modify changelog contents

* fix by check-events script error

* fix word

* fix word

* fix word

* fix cargo fmt
AndrooTheChen pushed a commit to discord/vector that referenced this pull request Sep 23, 2024
…otdev#20780)

* fix(loki sinks): Fix loki event timestamp out of range panic

* change LokiEventTimestampOutOfRangeError error to warn

* move use to begin of file

* update skipped events finalizer to errored

* fix: remove duplicate take finalizers

* add changelog

* fix changelog name

* fix spelling issue

* modify changelog contents

* modify changelog contents

* fix by check-events script error

* fix word

* fix word

* fix word

* fix cargo fmt
vparfonov pushed a commit to vparfonov/vector that referenced this pull request Jul 24, 2025
…otdev#20780)

* fix(loki sinks): Fix loki event timestamp out of range panic

* change LokiEventTimestampOutOfRangeError error to warn

* move use to begin of file

* update skipped events finalizer to errored

* fix: remove duplicate take finalizers

* add changelog

* fix changelog name

* fix spelling issue

* modify changelog contents

* modify changelog contents

* fix by check-events script error

* fix word

* fix word

* fix word

* fix cargo fmt
openshift-merge-bot bot pushed a commit to ViaQ/vector that referenced this pull request Jul 24, 2025
…otdev#20780)

* fix(loki sinks): Fix loki event timestamp out of range panic

* change LokiEventTimestampOutOfRangeError error to warn

* move use to begin of file

* update skipped events finalizer to errored

* fix: remove duplicate take finalizers

* add changelog

* fix changelog name

* fix spelling issue

* modify changelog contents

* modify changelog contents

* fix by check-events script error

* fix word

* fix word

* fix word

* fix cargo fmt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: sinks Anything related to the Vector's sinks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vector panics when Loki timestamp nanoseconds are unparseable

3 participants