vector/internal_events/
apache_metrics.rs

1use vector_lib::{
2    NamedInternalEvent, counter,
3    internal_event::{CounterName, InternalEvent, error_stage, error_type},
4    json_size::JsonSize,
5};
6
7use crate::sources::apache_metrics;
8
9#[derive(Debug, NamedInternalEvent)]
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            CounterName::ComponentReceivedEventsTotal,
22            "endpoint" => self.endpoint.to_owned(),
23        )
24        .increment(self.count as u64);
25        counter!(
26            CounterName::ComponentReceivedEventBytesTotal,
27            "endpoint" => self.endpoint.to_owned(),
28        )
29        .increment(self.byte_size.get() as u64);
30    }
31}
32
33#[derive(Debug, NamedInternalEvent)]
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        );
48        counter!(
49            CounterName::ComponentErrorsTotal,
50            "stage" => error_stage::PROCESSING,
51            "error_type" => error_type::PARSER_FAILED,
52            "endpoint" => self.endpoint.to_owned(),
53        )
54        .increment(1);
55    }
56}