vector/internal_events/
loki.rs

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