vector/internal_events/
docker_logs.rs1use bollard::errors::Error;
2use chrono::ParseError;
3use metrics::counter;
4use vector_lib::{
5 internal_event::{InternalEvent, error_stage, error_type},
6 json_size::JsonSize,
7};
8
9#[derive(Debug)]
10pub struct DockerLogsEventsReceived<'a> {
11 pub byte_size: JsonSize,
12 pub container_id: &'a str,
13 pub container_name: &'a str,
14}
15
16impl InternalEvent for DockerLogsEventsReceived<'_> {
17 fn emit(self) {
18 trace!(
19 message = "Events received.",
20 count = 1,
21 byte_size = %self.byte_size,
22 container_id = %self.container_id
23 );
24 counter!(
25 "component_received_events_total", "container_name" => self.container_name.to_owned()
26 )
27 .increment(1);
28 counter!(
29 "component_received_event_bytes_total", "container_name" => self.container_name.to_owned()
30 ).increment(self.byte_size.get() as u64);
31 }
32}
33
34#[derive(Debug)]
35pub struct DockerLogsContainerEventReceived<'a> {
36 pub container_id: &'a str,
37 pub action: &'a str,
38}
39
40impl InternalEvent for DockerLogsContainerEventReceived<'_> {
41 fn emit(self) {
42 debug!(
43 message = "Received one container event.",
44 container_id = %self.container_id,
45 action = %self.action,
46 );
47 counter!("container_processed_events_total").increment(1);
48 }
49}
50
51#[derive(Debug)]
52pub struct DockerLogsContainerWatch<'a> {
53 pub container_id: &'a str,
54}
55
56impl InternalEvent for DockerLogsContainerWatch<'_> {
57 fn emit(self) {
58 info!(
59 message = "Started watching for container logs.",
60 container_id = %self.container_id,
61 );
62 counter!("containers_watched_total").increment(1);
63 }
64}
65
66#[derive(Debug)]
67pub struct DockerLogsContainerUnwatch<'a> {
68 pub container_id: &'a str,
69}
70
71impl InternalEvent for DockerLogsContainerUnwatch<'_> {
72 fn emit(self) {
73 info!(
74 message = "Stopped watching for container logs.",
75 container_id = %self.container_id,
76 );
77 counter!("containers_unwatched_total").increment(1);
78 }
79}
80
81#[derive(Debug)]
82pub struct DockerLogsCommunicationError<'a> {
83 pub error: Error,
84 pub container_id: Option<&'a str>,
85}
86
87impl InternalEvent for DockerLogsCommunicationError<'_> {
88 fn emit(self) {
89 error!(
90 message = "Error in communication with Docker daemon.",
91 error = ?self.error,
92 error_type = error_type::CONNECTION_FAILED,
93 stage = error_stage::RECEIVING,
94 container_id = ?self.container_id,
95 internal_log_rate_limit = true
96 );
97 counter!(
98 "component_errors_total",
99 "error_type" => error_type::CONNECTION_FAILED,
100 "stage" => error_stage::RECEIVING,
101 )
102 .increment(1);
103 }
104}
105
106#[derive(Debug)]
107pub struct DockerLogsContainerMetadataFetchError<'a> {
108 pub error: Error,
109 pub container_id: &'a str,
110}
111
112impl InternalEvent for DockerLogsContainerMetadataFetchError<'_> {
113 fn emit(self) {
114 error!(
115 message = "Failed to fetch container metadata.",
116 error = ?self.error,
117 error_type = error_type::REQUEST_FAILED,
118 stage = error_stage::RECEIVING,
119 container_id = ?self.container_id,
120 internal_log_rate_limit = true
121 );
122 counter!(
123 "component_errors_total",
124 "error_type" => error_type::REQUEST_FAILED,
125 "stage" => error_stage::RECEIVING,
126 "container_id" => self.container_id.to_owned(),
127 )
128 .increment(1);
129 }
130}
131
132#[derive(Debug)]
133pub struct DockerLogsTimestampParseError<'a> {
134 pub error: ParseError,
135 pub container_id: &'a str,
136}
137
138impl InternalEvent for DockerLogsTimestampParseError<'_> {
139 fn emit(self) {
140 error!(
141 message = "Failed to parse timestamp as RFC3339 timestamp.",
142 error = ?self.error,
143 error_type = error_type::PARSER_FAILED,
144 stage = error_stage::PROCESSING,
145 container_id = ?self.container_id,
146 internal_log_rate_limit = true
147 );
148 counter!(
149 "component_errors_total",
150 "error_type" => error_type::PARSER_FAILED,
151 "stage" => error_stage::PROCESSING,
152 "container_id" => self.container_id.to_owned(),
153 )
154 .increment(1);
155 }
156}
157
158#[derive(Debug)]
159pub struct DockerLogsLoggingDriverUnsupportedError<'a> {
160 pub container_id: &'a str,
161 pub error: Error,
162}
163
164impl InternalEvent for DockerLogsLoggingDriverUnsupportedError<'_> {
165 fn emit(self) {
166 error!(
167 message = "Docker engine is not using either the `jsonfile` or `journald` logging driver. Please enable one of these logging drivers to get logs from the Docker daemon.",
168 error = ?self.error,
169 error_type = error_type::CONFIGURATION_FAILED,
170 stage = error_stage::RECEIVING,
171 container_id = ?self.container_id,
172 internal_log_rate_limit = true,
173 );
174 counter!(
175 "component_errors_total",
176 "error_type" => error_type::CONFIGURATION_FAILED,
177 "stage" => error_stage::RECEIVING,
178 "container_id" => self.container_id.to_owned(),
179 )
180 .increment(1);
181 }
182}