vector/internal_events/
journald.rs

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