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 );
96 counter!(
97 "component_errors_total",
98 "error_type" => error_type::CONNECTION_FAILED,
99 "stage" => error_stage::RECEIVING,
100 )
101 .increment(1);
102 }
103}
104
105#[derive(Debug)]
106pub struct DockerLogsContainerMetadataFetchError<'a> {
107 pub error: Error,
108 pub container_id: &'a str,
109}
110
111impl InternalEvent for DockerLogsContainerMetadataFetchError<'_> {
112 fn emit(self) {
113 error!(
114 message = "Failed to fetch container metadata.",
115 error = ?self.error,
116 error_type = error_type::REQUEST_FAILED,
117 stage = error_stage::RECEIVING,
118 container_id = ?self.container_id
119 );
120 counter!(
121 "component_errors_total",
122 "error_type" => error_type::REQUEST_FAILED,
123 "stage" => error_stage::RECEIVING,
124 "container_id" => self.container_id.to_owned(),
125 )
126 .increment(1);
127 }
128}
129
130#[derive(Debug)]
131pub struct DockerLogsTimestampParseError<'a> {
132 pub error: ParseError,
133 pub container_id: &'a str,
134}
135
136impl InternalEvent for DockerLogsTimestampParseError<'_> {
137 fn emit(self) {
138 error!(
139 message = "Failed to parse timestamp as RFC3339 timestamp.",
140 error = ?self.error,
141 error_type = error_type::PARSER_FAILED,
142 stage = error_stage::PROCESSING,
143 container_id = ?self.container_id
144 );
145 counter!(
146 "component_errors_total",
147 "error_type" => error_type::PARSER_FAILED,
148 "stage" => error_stage::PROCESSING,
149 "container_id" => self.container_id.to_owned(),
150 )
151 .increment(1);
152 }
153}
154
155#[derive(Debug)]
156pub struct DockerLogsLoggingDriverUnsupportedError<'a> {
157 pub container_id: &'a str,
158 pub error: Error,
159}
160
161impl InternalEvent for DockerLogsLoggingDriverUnsupportedError<'_> {
162 fn emit(self) {
163 error!(
164 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.",
165 error = ?self.error,
166 error_type = error_type::CONFIGURATION_FAILED,
167 stage = error_stage::RECEIVING,
168 container_id = ?self.container_id,
169 );
170 counter!(
171 "component_errors_total",
172 "error_type" => error_type::CONFIGURATION_FAILED,
173 "stage" => error_stage::RECEIVING,
174 "container_id" => self.container_id.to_owned(),
175 )
176 .increment(1);
177 }
178}