Ingest an HTTP JSON Dataset into OpenSearch with Load
Download a public JSON dataset, reshape it to one object per line with a small Python script, and bulk index it into OpenSearch with Load.
Detect PostgreSQL event triggers left disabled after a migration, enable them behind an approval gate, then re-read evtenabled to confirm.
An event trigger is how a team enforces DDL policy inside the database. It audits every schema change, refuses an unsafe DROP, records a migration. Someone runs ALTER EVENT TRIGGER ... DISABLE to push a migration through, the migration lands, the re-enable is forgotten. From then on the policy is off and nothing reports it, because a disabled event trigger looks exactly like one that was never created from the application's point of view: no error, no warning, no row in the audit table.
This guard reads pg_event_trigger, treats evtenabled = 'D' as the fault, enables the targeted triggers again behind a dry run plus an approval gate, then re-reads evtenabled and fails the run if any target did not reach the requested state.
This blueprint was created by zkasuran.
evtenabled has four states, not two. O fires in origin and local sessions, A always including replica sessions, R in replica sessions only, D never. Only D is the fault here. An R trigger is inert on a primary by design, which is a deliberate choice on a replica rather than a break, so the flow reports it and never changes it.dry_run is true and auto_remediate is false, so a plain run reports and never enables anything.auto_remediate is true and dry_run is false. It then waits for a human to resume the Pause with approved set true. An unanswered gate reads as not approved.desired_state decides what the trigger is restored to, O or A, instead of the flow guessing. A trigger that was ENABLE ALWAYS before someone disabled it comes back as ALWAYS only when you ask for it.desired_triggers narrows the pass to a named allowlist, so a trigger that is meant to stay disabled is never touched.detect (io.kestra.plugin.jdbc.postgresql.Query) reads pg_event_trigger joined to pg_proc, keeps the rows at evtenabled = 'D' that match the allowlist, then returns the handler function, the command tags the trigger filters on and the exact ALTER EVENT TRIGGER statement that restores the requested state.roster reads every event trigger with its state decoded, plus a count per state, so the log shows the O, A and R triggers next to the D ones.summarize (io.kestra.plugin.core.output.OutputValues) builds the target name list and the JSON the remediation loop iterates.log_state (io.kestra.plugin.core.log.Log) logs the count, the targets, the full roster and the mode.guard (io.kestra.plugin.core.flow.If) branches on the count. With none found, clean logs the roster and the run ends. Otherwise findings_alert posts the gap to Slack on every detection.mode (io.kestra.plugin.core.flow.If) enters the remediation branch only when auto_remediate is true and dry_run is false. Otherwise report_only lists what would be enabled.approval_gate (io.kestra.plugin.core.flow.Pause) holds the run for a human. enable_triggers (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 1) then runs one ALTER EVENT TRIGGER per target.reverify re-reads evtenabled for every target and returns only the ones that did not reach the requested state, counting a dropped trigger as absent. verify_result fails the run through io.kestra.plugin.core.execution.Fail when that list is not empty.evtenabled states, so a replica-only trigger is reported rather than quietly switched on a primary.format('%I'), so the trigger name is quoted by the database.O or A, instead of an assumption about what the trigger held before.PostgreSQL will not tell you that one of its own policy triggers is off. There is no scheduler for the check, no approval step before flipping something that changes how DDL behaves, no proof that an ALTER took effect. Kestra adds each piece. It schedules the sweep, keeps it read-only until an operator asks for a change, holds the change behind a human approval, builds the ALTER inside the database so names are quoted correctly, re-reads evtenabled to turn a hopeful fix into a verified one, then posts to Slack both when a gap is found and when a step fails.
Run on Kestra 2.0.5 against a PostgreSQL 16 server, with a local HTTP sink standing in for Slack. The database was seeded with three event triggers on ddl_command_end, each with its own handler writing a labelled row to a ddl_audit table: one audit trigger, one policy trigger that stays enabled, one deliberately set to ENABLE REPLICA.
CREATE TABLE produced a ddl_audit row from both enabled triggers. After ALTER EVENT TRIGGER audit_ddl_end DISABLE, the same CREATE TABLE produced a row from the still enabled trigger and nothing from the disabled one. That is the gap this guard closes.O, O, R) it returned 0. After one trigger was disabled it returned exactly 1, never the enabled trigger nor the replica-only one, confirmed with psql against pg_event_trigger.D.ALTER EVENT TRIGGER ... ENABLE and the re-read reported 0 targets off the requested state. A CREATE TABLE after the run wrote the audit row again. The enabled trigger and the replica-only trigger were untouched.D and the run failed and alerted.A PostgreSQL server reachable over JDBC. The connecting user must be able to read pg_event_trigger, which any role can. It must also own the triggers it enables, which usually means a superuser since creating an event trigger is a superuser action.
POSTGRES_USERNAME: PostgreSQL user, read when use_secret_auth is true.POSTGRES_PASSWORD: password for that user.SLACK_WEBHOOK_URL: used by findings_alert and the errors block.SECRET_.| Name | Type | Default | Description |
|---|---|---|---|
postgres_url |
STRING | jdbc:postgresql://localhost:5432/postgres |
JDBC URL for the target database. |
use_secret_auth |
BOOL | true |
Read credentials from secrets. Set false only for inline test credentials. |
desired_triggers |
STRING | "" |
Comma separated allowlist of trigger names. Empty targets every disabled event trigger. |
desired_state |
SELECT | origin |
origin restores evtenabled O, always restores A. |
dry_run |
BOOL | true |
Report without enabling anything. |
auto_remediate |
BOOL | false |
Enable behind the approval gate when dry_run is false. |
POSTGRES_USERNAME, POSTGRES_PASSWORD and SLACK_WEBHOOK_URL as namespace secrets.postgres_url pointed at a database that has event triggers. The default dry run reports any that sit at evtenabled = 'D'.dry_run false and auto_remediate true, then resume the paused execution with approved true.desired_triggers to the names your runbook disables during a migration, so the sweep is scoped to exactly the guards that must come back.desired_state to always for a trigger that must fire in replica sessions too.ddl_command_end audit table and compares its newest entry with the migration log, to narrow the window of DDL that was never audited.pg_trigger.tgenabled to cover per-table triggers, which use ALTER TABLE ... ENABLE TRIGGER and are a different object.