vector/internal_events/
loki.rs1use metrics::counter;
2use vector_lib::internal_event::{
3 ComponentEventsDropped, INTENTIONAL, InternalEvent, error_stage, error_type,
4};
5
6#[derive(Debug)]
7pub struct LokiEventUnlabeledError;
8
9impl InternalEvent for LokiEventUnlabeledError {
10 fn emit(self) {
11 error!(
12 message = "Event had no labels. Adding default `agent` label.",
13 error_code = "unlabeled_event",
14 error_type = error_type::CONDITION_FAILED,
15 stage = error_stage::PROCESSING,
16 internal_log_rate_limit = true,
17 );
18
19 counter!(
20 "component_errors_total",
21 "error_code" => "unlabeled_event",
22 "error_type" => error_type::CONDITION_FAILED,
23 "stage" => error_stage::PROCESSING,
24 )
25 .increment(1);
26 }
27}
28
29#[derive(Debug)]
30pub struct LokiOutOfOrderEventDroppedError {
31 pub count: usize,
32}
33
34impl InternalEvent for LokiOutOfOrderEventDroppedError {
35 fn emit(self) {
36 let reason = "Dropping out-of-order event(s).";
37
38 error!(
39 message = reason,
40 error_code = "out_of_order",
41 error_type = error_type::CONDITION_FAILED,
42 stage = error_stage::PROCESSING,
43 internal_log_rate_limit = true,
44 );
45
46 emit!(ComponentEventsDropped::<INTENTIONAL> {
47 count: self.count,
48 reason,
49 });
50
51 counter!(
52 "component_errors_total",
53 "error_code" => "out_of_order",
54 "error_type" => error_type::CONDITION_FAILED,
55 "stage" => error_stage::PROCESSING,
56 )
57 .increment(1);
58 }
59}
60
61#[derive(Debug)]
62pub struct LokiOutOfOrderEventRewritten {
63 pub count: usize,
64}
65
66impl InternalEvent for LokiOutOfOrderEventRewritten {
67 fn emit(self) {
68 debug!(
69 message = "Timestamps rewritten.",
70 count = self.count,
71 reason = "out_of_order",
72 internal_log_rate_limit = true,
73 );
74 counter!("rewritten_timestamp_events_total").increment(self.count as u64);
75 }
76}
77
78#[derive(Debug)]
79pub struct LokiTimestampNonParsableEventsDropped;
80
81impl InternalEvent for LokiTimestampNonParsableEventsDropped {
82 fn emit(self) {
83 let reason = "Dropping timestamp non-parsable event(s).";
84
85 error!(
86 message = "Event timestamp non-parsable.",
87 error_code = "non-parsable_timestamp",
88 error_type = error_type::CONDITION_FAILED,
89 stage = error_stage::PROCESSING,
90 internal_log_rate_limit = true,
91 );
92
93 emit!(ComponentEventsDropped::<INTENTIONAL> { count: 1, reason });
94
95 counter!(
96 "component_errors_total",
97 "error_code" => "non-parsable_timestamp",
98 "error_type" => error_type::CONDITION_FAILED,
99 "stage" => error_stage::PROCESSING,
100 )
101 .increment(1);
102 }
103}