vector/internal_events/
apache_metrics.rs

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