Real-Time Events

Guardrails needs to know when resources change in your GCP projects so it can update the CMDB, evaluate controls, and take enforcement actions. There are two mechanisms for delivering these change notifications. You choose one for each project.

Choosing the Right Mechanism

Event PollersEvent Handlers
How it worksGuardrails periodically queries GCP Logging (Cloud Audit Logs) for recent API events.Logging sinks and Pub/Sub deliver events to Guardrails in near real-time.
Latency1–10 minutes (configurable polling interval).Near real-time (seconds).
ScalabilityLimited. GCP Logging entries.list API has a rate limit of 1 call per second per project. As project count grows per service account, polling dominates API quota.Excellent. Pub/Sub handles high event volumes natively.
GCP infrastructureNone. Guardrails uses existing Cloud Audit Log data via API.Logging Sink, Pub/Sub Topic, Pub/Sub Subscription, and IAM policy per project.
Setup complexityLowest. Enabled by default, no GCP resources needed.Moderate. Requires Pub/Sub and Logging APIs enabled, plus Guardrails deploys infrastructure via Terraform stacks.
Recommended forDevelopment environments, POCs, projects with very low activity.Production environments. The recommended mechanism for all projects.
StatusActive (default for new projects).Preferred.

How They Relate

These two mechanisms are mutually exclusive. You should only have one active at a time for each project. If you enable event handlers, the event pollers stop running automatically. Event Handlers and Event Pollers should never be enabled at the same time. Duplicate event processing is highly undesirable.

The typical progression is:

  1. Start with Event Pollers, enabled by default when you connect a project. Works immediately with no setup.
  2. Upgrade to Event Handlers when you're ready for production-grade real-time events. This is the recommended configuration.

[!NOTE] Event pollers operate based on the value of the GCP > Turbot > Event Handlers policy, not on the state of the Event Handler controls. When Event Handling is enabled, pollers stop running automatically. If event handler controls go into an error state, pollers still won't run. Resolve event handler issues as quickly as possible to avoid losing events.

GCP Logging Dependency

Both mechanisms depend on Cloud Audit Logs being active in your projects. GCP automatically logs Admin Activity audit logs, which capture resource creation, modification, and deletion events.

Event Handler Architecture

The event handler infrastructure is configured by Guardrails Stacks (Terraform) in each project. These stacks create:

Events flow through these components on their way to Guardrails:

  1. GCP Logging: User/API events originate here.
  2. Logging Sink: Events are filtered and directed to the Pub/Sub Topic.
  3. Pub/Sub Topic: Data path between the Logging Sink and the Subscription.
  4. Pub/Sub Subscription: Makes an HTTP call to pass event data to the Guardrails event ingestion endpoint.
  5. (Optional) API Gateway and Events Proxy: Enterprise customers with private ALBs may deploy an API Gateway. SaaS customers do not have this step.
  6. Guardrails ALB: Common entry point for events and API calls.
  7. Guardrails Events Container: Events are processed, triggering CMDB updates or control runs.

Guardrails Policies and Stacks

Guardrails uses Terraform to deploy the event handling infrastructure. The Terraform source is compiled from several inputs:

All inputs are compiled into the read-only GCP > Turbot > Event Handlers > Pub/Sub > Source and GCP > Turbot > Event Handlers > Logging > Source policy values. Looking at the "Depends On" tab of these Source policy values shows all dependent policies. Errors in any dependent policy may prevent event handlers from deploying properly.

Guides

GuideDescription
Event HandlersSet up push-based real-time event delivery (recommended for production).
Event PollersConfigure polling frequency and lookback window. Enabled by default.