vector/internal_events/
journald.rs

1use metrics::counter;
2use vector_lib::codecs::decoding::BoxedFramingError;
3use vector_lib::internal_event::InternalEvent;
4use vector_lib::internal_event::{error_stage, error_type};
5
6#[derive(Debug)]
7pub struct JournaldInvalidRecordError {
8    pub error: serde_json::Error,
9    pub text: String,
10}
11
12impl InternalEvent for JournaldInvalidRecordError {
13    fn emit(self) {
14        error!(
15            message = "Invalid record from journald, discarding.",
16            error = ?self.error,
17            text = %self.text,
18            error_type = error_type::PARSER_FAILED,
19            stage = error_stage::PROCESSING,
20            internal_log_rate_limit = true,
21        );
22        counter!(
23            "component_errors_total",
24            "stage" => error_stage::PROCESSING,
25            "error_type" => error_type::PARSER_FAILED,
26        )
27        .increment(1);
28    }
29}
30
31#[derive(Debug)]
32pub struct JournaldStartJournalctlError {
33    pub error: crate::Error,
34}
35
36impl InternalEvent for JournaldStartJournalctlError {
37    fn emit(self) {
38        error!(
39            message = "Error starting journalctl process.",
40            error = %self.error,
41            error_type = error_type::COMMAND_FAILED,
42            stage = error_stage::RECEIVING,
43            internal_log_rate_limit = true,
44        );
45        counter!(
46            "component_errors_total",
47            "stage" => error_stage::RECEIVING,
48            "error_type" => error_type::COMMAND_FAILED,
49        )
50        .increment(1);
51    }
52}
53
54#[derive(Debug)]
55pub struct JournaldReadError {
56    pub error: BoxedFramingError,
57}
58
59impl InternalEvent for JournaldReadError {
60    fn emit(self) {
61        error!(
62            message = "Could not read from journald.",
63            error = %self.error,
64            error_type = error_type::READER_FAILED,
65            stage = error_stage::PROCESSING,
66            internal_log_rate_limit = true,
67        );
68        counter!(
69            "component_errors_total",
70            "stage" => error_stage::PROCESSING,
71            "error_type" => error_type::READER_FAILED,
72        )
73        .increment(1);
74    }
75}
76
77#[derive(Debug)]
78pub struct JournaldCheckpointSetError {
79    pub error: std::io::Error,
80    pub filename: String,
81}
82
83impl InternalEvent for JournaldCheckpointSetError {
84    fn emit(self) {
85        error!(
86            message = "Could not set journald checkpoint.",
87            filename = ?self.filename,
88            error = %self.error,
89            error_type = error_type::IO_FAILED,
90            stage = error_stage::PROCESSING,
91            internal_log_rate_limit = true,
92        );
93        counter!(
94            "component_errors_total",
95            "stage" => error_stage::PROCESSING,
96            "error_type" => error_type::IO_FAILED,
97        )
98        .increment(1);
99    }
100}
101
102#[derive(Debug)]
103pub struct JournaldCheckpointFileOpenError {
104    pub error: std::io::Error,
105    pub path: String,
106}
107
108impl InternalEvent for JournaldCheckpointFileOpenError {
109    fn emit(self) {
110        error!(
111            message = "Unable to open checkpoint file.",
112            path = ?self.path,
113            error = %self.error,
114            error_type = error_type::IO_FAILED,
115            stage = error_stage::RECEIVING,
116            internal_log_rate_limit = true,
117        );
118        counter!(
119            "component_errors_total",
120            "stage" => error_stage::RECEIVING,
121            "error_type" => error_type::IO_FAILED,
122        )
123        .increment(1);
124    }
125}