Skip to content

Commit

Permalink
fix(loki sink, observability): Drop non-fatal template render errors …
Browse files Browse the repository at this point in the history
…to warnings (vectordotdev#17746)

If a render error doesn't result in a dropped event, it seems more like
a warning than an error.

For the places that currently emit template errors with `drop_event:
false`:

* `loki` sink: skips inserting label if key or value fails to render;
falls back to `None` for
  partitioning using `tenant_id`
* `throttle` transform: falls back to `None` for throttle key
* `log_to_metric` transform: skips tag addition
* `papertrail` sink: falls back to `vector` for the `process` field
* `splunk_hec_logs` sink: falls back to `None` for partition keys
(source, sourcetype, index)
* `splunk_hec_metrics` sink: falls back to `None` for source,
sourcetype, index

Fixes: vectordotdev#17487

Signed-off-by: Jesse Szwedko <jesse.szwedko@datadoghq.com>

Signed-off-by: Jesse Szwedko <jesse.szwedko@datadoghq.com>
  • Loading branch information
jszwedko authored Jun 23, 2023
1 parent 92a36e0 commit 4ebc3e1
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions src/internal_events/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,33 @@ impl<'a> InternalEvent for TemplateRenderingError<'a> {
}
msg.push('.');

error!(
message = %msg,
error = %self.error,
error_type = error_type::TEMPLATE_FAILED,
stage = error_stage::PROCESSING,
internal_log_rate_limit = true,
);
if self.drop_event {
error!(
message = %msg,
error = %self.error,
error_type = error_type::TEMPLATE_FAILED,
stage = error_stage::PROCESSING,
internal_log_rate_limit = true,
);

counter!(
"component_errors_total", 1,
"error_type" => error_type::TEMPLATE_FAILED,
"stage" => error_stage::PROCESSING,
);
counter!(
"component_errors_total", 1,
"error_type" => error_type::TEMPLATE_FAILED,
"stage" => error_stage::PROCESSING,
);

if self.drop_event {
emit!(ComponentEventsDropped::<UNINTENTIONAL> {
count: 1,
reason: "Failed to render template.",
});
} else {
warn!(
message = %msg,
error = %self.error,
error_type = error_type::TEMPLATE_FAILED,
stage = error_stage::PROCESSING,
internal_log_rate_limit = true,
);
}
}
}

0 comments on commit 4ebc3e1

Please sign in to comment.