@@ -39,9 +39,9 @@ use vrl::value::{KeyString, ObjectMap, Value};
3939use crate :: enrichment_tables:: memory:: {
4040 MemoryConfig ,
4141 internal_events:: {
42- MemoryEnrichmentTableFlushed , MemoryEnrichmentTableInserted , MemoryEnrichmentTableRead ,
43- MemoryEnrichmentTableReadFailed , MemoryEnrichmentTableRemoved ,
44- MemoryEnrichmentTableTtlExpiredCount ,
42+ MemoryEnrichmentTableFlushed , MemoryEnrichmentTableInsertFailed ,
43+ MemoryEnrichmentTableInserted , MemoryEnrichmentTableRead , MemoryEnrichmentTableReadFailed ,
44+ MemoryEnrichmentTableRemoved , MemoryEnrichmentTableTtlExpiredCount ,
4545 } ,
4646} ;
4747
@@ -285,7 +285,7 @@ impl CuckooMemoryTable {
285285 continue ;
286286 } ;
287287
288- if self . cuckoo_config . ttl_enabled || self . cuckoo_config . counter_enabled {
288+ let res = if self . cuckoo_config . ttl_enabled || self . cuckoo_config . counter_enabled {
289289 let ttl = self
290290 . config
291291 . ttl_field
@@ -317,21 +317,29 @@ impl CuckooMemoryTable {
317317 . and_then ( |p| value. get ( p) )
318318 . and_then ( |v| v. as_integer ( ) )
319319 . and_then ( |v| i32:: try_from ( v) . ok ( ) ) ;
320- let _ = self . filter . insert_if_not_present_with_update (
320+ self . filter . insert_if_not_present_with_update (
321321 k,
322322 InsertValues { ttl, counter } ,
323323 LookupValues {
324324 ttl,
325325 counter_diff : counter,
326326 } ,
327- ) ;
327+ )
328328 } else {
329- let _ = self . filter . insert_if_not_present ( k) ;
329+ self . filter . insert_if_not_present ( k)
330+ } ;
331+
332+ if res. is_some_and ( |r| r. matches_key ( k, & self . filter ) ) {
333+ emit ! ( MemoryEnrichmentTableInsertFailed {
334+ key: k,
335+ include_key_metric_tag: self . config. internal_metrics. include_key_tag
336+ } ) ;
337+ } else {
338+ emit ! ( MemoryEnrichmentTableInserted {
339+ key: k,
340+ include_key_metric_tag: self . config. internal_metrics. include_key_tag
341+ } ) ;
330342 }
331- emit ! ( MemoryEnrichmentTableInserted {
332- key: k,
333- include_key_metric_tag: self . config. internal_metrics. include_key_tag
334- } ) ;
335343 }
336344 }
337345}
0 commit comments