vector/internal_events/
tag_cardinality_limit.rs

1use metrics::counter;
2use vector_lib::NamedInternalEvent;
3use vector_lib::internal_event::{ComponentEventsDropped, INTENTIONAL, InternalEvent};
4
5#[derive(NamedInternalEvent)]
6pub struct TagCardinalityLimitRejectingEvent<'a> {
7    pub metric_name: &'a str,
8    pub tag_key: &'a str,
9    pub tag_value: &'a str,
10    pub include_extended_tags: bool,
11}
12
13impl InternalEvent for TagCardinalityLimitRejectingEvent<'_> {
14    fn emit(self) {
15        debug!(
16            message = "Event containing tag with new value after hitting configured 'value_limit'; discarding event.",
17            metric_name = self.metric_name,
18            tag_key = self.tag_key,
19            tag_value = self.tag_value,
20        );
21        if self.include_extended_tags {
22            counter!(
23                "tag_value_limit_exceeded_total",
24                "metric_name" => self.metric_name.to_string(),
25                "tag_key" => self.tag_key.to_string(),
26            )
27            .increment(1);
28        } else {
29            counter!("tag_value_limit_exceeded_total").increment(1);
30        }
31
32        emit!(ComponentEventsDropped::<INTENTIONAL> {
33            count: 1,
34            reason: "Tag value limit exceeded."
35        })
36    }
37}
38
39#[derive(NamedInternalEvent)]
40pub struct TagCardinalityLimitRejectingTag<'a> {
41    pub metric_name: &'a str,
42    pub tag_key: &'a str,
43    pub tag_value: &'a str,
44    pub include_extended_tags: bool,
45}
46
47impl InternalEvent for TagCardinalityLimitRejectingTag<'_> {
48    fn emit(self) {
49        debug!(
50            message = "Rejecting tag after hitting configured 'value_limit'.",
51            metric_name = self.metric_name,
52            tag_key = self.tag_key,
53            tag_value = self.tag_value,
54        );
55        if self.include_extended_tags {
56            counter!(
57                "tag_value_limit_exceeded_total",
58                "metric_name" => self.metric_name.to_string(),
59                "tag_key" => self.tag_key.to_string(),
60            )
61            .increment(1);
62        } else {
63            counter!("tag_value_limit_exceeded_total").increment(1);
64        }
65    }
66}
67
68#[derive(NamedInternalEvent)]
69pub struct TagCardinalityValueLimitReached<'a> {
70    pub key: &'a str,
71}
72
73impl InternalEvent for TagCardinalityValueLimitReached<'_> {
74    fn emit(self) {
75        debug!(
76            message = "Value_limit reached for key. New values for this key will be rejected.",
77            key = %self.key,
78        );
79        counter!("value_limit_reached_total").increment(1);
80    }
81}