Teleport Log Sink regex filtering and high-volume event latency
0 reputation · 06 Dec 2022, 13:51 UTC
0 reputation · 06 Dec 2022, 13:51 UTC
How does the Teleport Audit Service prioritize event delivery when multiple regex filters are applied to high-throughput streams? Is there a documented mechanism to implement rate-limiting at the sink level to prevent webhook API exhaustion during event storms?
31275 reputation · 06 Dec 2022, 22:28 UTC
The Teleport Audit Service does not implement a priority queue for event delivery based on the content of the event or the complexity of the regex filter. Events are processed sequentially as they are generated. When multiple regex filters are applied to a high-throughput stream, the processing time for each event increases linearly with the number of filters and the complexity of the expressions.
While regex filtering reduces the volume of data sent to external providers, the evaluation occurs within the event pipeline. If complex patterns—specifically those prone to catastrophic backtracking—are used, CPU utilization on the Teleport Auth server will spike. This can introduce measurable latency for all events, including critical security alerts, because the processing bottleneck occurs before the event is dispatched to the sink.
Teleport does not currently provide a built-in, configurable rate-limiting mechanism at the individual Log Sink level to prevent external API exhaustion (e.g., Slack or PagerDuty rate limits). To prevent webhook exhaustion during an event storm, you must implement one of the following architectural patterns:
.*) that force the engine to scan large payloads.To determine if regex processing is impacting your event latency, monitor the following metrics during a simulated event spike:
event_timestamp in the audit log with the arrival timestamp at the webhook destination.Diagnostic Requirement: To provide a more specific recommendation on filter optimization, please provide the specific regex patterns currently in use and the average event payload size.
Use comments to ask for clarification. Post a solution as an answer.
31,275 reputation · 06 Dec 2022, 14:25 UTC
Each Log Sink runs its own worker goroutine that evaluates the compiled RE2 regex against every audit event. Because the matching is done per‑sink, adding more sinks increases overall CPU usage proportionally but does not add extra latency to an individual event beyond the O(len(event)) match cost; the workers operate in parallel.
Consequently, when you observe high CPU on the Auth server during a burst, check the number of active sinks and the audit_sink_filter_evaluations_total metric to see if the load stems from many sinks rather than a single complex pattern.