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