vector/internal_events/
nginx_metrics.rs1use metrics::counter;
2use vector_lib::{
3 NamedInternalEvent,
4 internal_event::{InternalEvent, error_stage, error_type},
5 json_size::JsonSize,
6};
7
8use crate::sources::nginx_metrics::parser::ParseError;
9
10#[derive(Debug, NamedInternalEvent)]
11pub struct NginxMetricsEventsReceived<'a> {
12 pub byte_size: JsonSize,
13 pub count: usize,
14 pub endpoint: &'a str,
15}
16
17impl InternalEvent for NginxMetricsEventsReceived<'_> {
18 fn emit(self) {
19 trace!(
20 message = "Events received.",
21 byte_size = %self.byte_size,
22 count = %self.count,
23 endpoint = self.endpoint,
24 );
25 counter!(
26 "component_received_events_total",
27 "endpoint" => self.endpoint.to_owned(),
28 )
29 .increment(self.count as u64);
30 counter!(
31 "component_received_event_bytes_total",
32 "endpoint" => self.endpoint.to_owned(),
33 )
34 .increment(self.byte_size.get() as u64);
35 }
36}
37
38#[derive(NamedInternalEvent)]
39pub struct NginxMetricsRequestError<'a> {
40 pub error: crate::Error,
41 pub endpoint: &'a str,
42}
43
44impl InternalEvent for NginxMetricsRequestError<'_> {
45 fn emit(self) {
46 error!(
47 message = "Nginx request error.",
48 endpoint = %self.endpoint,
49 error = %self.error,
50 error_type = error_type::REQUEST_FAILED,
51 stage = error_stage::RECEIVING,
52 );
53 counter!(
54 "component_errors_total",
55 "endpoint" => self.endpoint.to_owned(),
56 "error_type" => error_type::REQUEST_FAILED,
57 "stage" => error_stage::RECEIVING,
58 )
59 .increment(1);
60 }
61}
62
63#[derive(NamedInternalEvent)]
64pub(crate) struct NginxMetricsStubStatusParseError<'a> {
65 pub error: ParseError,
66 pub endpoint: &'a str,
67}
68
69impl InternalEvent for NginxMetricsStubStatusParseError<'_> {
70 fn emit(self) {
71 error!(
72 message = "NginxStubStatus parse error.",
73 endpoint = %self.endpoint,
74 error = %self.error,
75 error_type = error_type::PARSER_FAILED,
76 stage = error_stage::PROCESSING,
77 );
78 counter!(
79 "component_errors_total",
80 "endpoint" => self.endpoint.to_owned(),
81 "error_type" => error_type::PARSER_FAILED,
82 "stage" => error_stage::PROCESSING,
83 )
84 .increment(1);
85 }
86}