New to Kestra?
Use blueprints to kickstart your first workflows.
Stream Google Cloud Pub/Sub messages into Postgres in real time with Kestra. One governed execution per message, safe upserts, and Teams alerts on failure.
Stream Google Cloud Pub/Sub messages straight into Postgres in real time, turning every message into a governed, observable Kestra execution. This event-driven blueprint solves the classic gap between a high-throughput message bus and a relational database: instead of writing and babysitting a custom consumer service, you get one execution per message, payload validation, safe parameterized upserts, full run history, and automatic failure alerts to Microsoft Teams. It is ideal for ingesting order events, IoT readings, clickstream data, or any JSON message stream that needs to land in Postgres with auditability.
io.kestra.plugin.gcp.pubsub.RealtimeTrigger listens on the orders topic via the kestra-orders-sub subscription and starts one execution per message. With serdeType: JSON, each payload is parsed so its fields are directly addressable as trigger.data.*.route task (io.kestra.plugin.core.flow.If) checks trigger.data.event_type == 'order' and only lets order events proceed, skipping everything else.upsert_order task (io.kestra.plugin.jdbc.postgresql.Query) runs an INSERT ... ON CONFLICT (order_id) DO UPDATE against Postgres, binding order_id, customer, and amount through named parameters so values are never concatenated into SQL.alert_on_failure error handler (io.kestra.plugin.microsoft365.teams.TeamsIncomingWebhook) posts a notification to Microsoft Teams with the failing execution id.Pub/Sub delivers messages, but it has no scheduler, no per-message run history, no validation step, and no built-in retry or alerting around the database write. Kestra fills that gap: the event trigger reacts the moment a message arrives, each message becomes a first-class execution you can inspect and replay, step-level retries and the error handler protect the load, and lineage across the trigger, validation, and upsert is captured automatically. It is all declared in readable YAML, so the pipeline is versioned and reviewable rather than buried in consumer code.
A Pub/Sub topic (orders) with a subscription, and a Postgres orders table with an order_id primary key.
GCP_PROJECT_ID: GCP project hosting the Pub/Sub topic.GCP_SERVICE_ACCOUNT: service account key JSON with Pub/Sub subscribe access.POSTGRES_URL: JDBC URL, e.g. jdbc:postgresql://host:5432/db.POSTGRES_USERNAME: database username.POSTGRES_PASSWORD: database password.TEAMS_WEBHOOK_URL: Microsoft Teams incoming webhook URL.topic and subscription at your Pub/Sub resources.route condition, the SQL, and the parameters to match your schema.disabled: true so importing the blueprint does not connect with placeholder config).route condition to fan out by event type, or replace If with a Switch to route different events to different tables.