vector/internal_events/
apache_metrics.rs1use metrics::counter;
2
3use vector_lib::internal_event::InternalEvent;
4use vector_lib::{
5 internal_event::{error_stage, error_type},
6 json_size::JsonSize,
7};
8
9use crate::sources::apache_metrics;
10
11#[derive(Debug)]
12pub struct ApacheMetricsEventsReceived<'a> {
13 pub byte_size: JsonSize,
14 pub count: usize,
15 pub endpoint: &'a str,
16}
17
18impl InternalEvent for ApacheMetricsEventsReceived<'_> {
19 fn emit(self) {
21 trace!(message = "Events received.", count = %self.count, byte_size = %self.byte_size, endpoint = %self.endpoint);
22 counter!(
23 "component_received_events_total",
24 "endpoint" => self.endpoint.to_owned(),
25 )
26 .increment(self.count as u64);
27 counter!(
28 "component_received_event_bytes_total",
29 "endpoint" => self.endpoint.to_owned(),
30 )
31 .increment(self.byte_size.get() as u64);
32 }
33}
34
35#[derive(Debug)]
36pub struct ApacheMetricsParseError<'a> {
37 pub error: apache_metrics::ParseError,
38 pub endpoint: &'a str,
39}
40
41impl InternalEvent for ApacheMetricsParseError<'_> {
42 fn emit(self) {
43 error!(
44 message = "Parsing error.",
45 error = ?self.error,
46 stage = error_stage::PROCESSING,
47 error_type = error_type::PARSER_FAILED,
48 endpoint = %self.endpoint,
49 internal_log_rate_limit = true,
50 );
51 counter!(
52 "component_errors_total",
53 "stage" => error_stage::PROCESSING,
54 "error_type" => error_type::PARSER_FAILED,
55 "endpoint" => self.endpoint.to_owned(),
56 )
57 .increment(1);
58 }
59}