Commands icon
Process icon
If icon
SlackIncomingWebhook icon
Log icon
Schedule icon

Neon Postgres Compute Scale And Idle Sentinel

Proactively audit Neon Serverless Postgres compute endpoints to eliminate idle compute leaks and enforce automatic suspension policies.

Categories
CloudInfrastructure

How it works

This sentinel workflow automates FinOps governance for Neon Serverless Postgres infrastructure:

  1. Daily Morning Trigger: Automatically wakes up at 08:00 UTC every day to review active compute resources and detect overnight compute leaks.
  2. API Endpoint Inspection: Queries the Neon Management REST API (/v2/projects/{project_id}/endpoints) to inspect each compute endpoint's state and autoscaling parameters.
  3. Autosuspend Policy Audit: Evaluates suspend_timeout_seconds across read-write and read-only endpoints, identifying instances where autosuspend is disabled (0) or set to an excessively long window.
  4. FinOps Alert Dispatch: If non-suspending or leaking endpoints are discovered, dispatches a rich Slack notification with endpoint IDs, current states, and direct console links.
  5. Error Guard: Employs Kestra's native errors task block to notify platform engineers if the audit execution encounters network timeouts or API credential errors.

What you get

  • Continuous prevention of runaway cloud database compute unit (CU) costs.
  • Identification of abandoned read-replicas or test branch endpoints left perpetually running.
  • Automated audit artifacts (neon_audit_summary.json) archived for billing reconciliation.
  • Direct Slack alerts containing actionable remediation details.

Who it's for

  • FinOps Practitioners: Enforcing cloud budget guardrails and eliminating idle database waste.
  • Database Administrators & DevOps: Managing Neon Serverless Postgres branches and compute autoscaling.
  • Engineering Leads: Tracking cloud infrastructure spend across ephemeral development environments.

Why orchestrate this with Kestra

  • Automated Policy Enforcement: Eliminate manual dashboard checking with automated scheduled workflows.
  • Secure Credential Storage: Inject your Neon API tokens securely using Kestra's encrypted secrets manager ({{ secret('NEON_API_KEY') }}).
  • Extensible Workflows: Easily add automated remediation steps, such as invoking the Neon API to reset suspend timeouts automatically.
  • Native Visibility: View detailed execution logs, output metrics, and artifacts directly within the Kestra UI.

Prerequisites

  • A Neon Cloud account and project ID.
  • A Neon API Key with read access to project endpoints.
  • A Slack Incoming Webhook URL.

Secrets

Configure the following secrets in your Kestra namespace or instance settings:

  • NEON_API_KEY: Your personal or service account Neon API key.
  • SLACK_WEBHOOK_URL: The incoming webhook URL for your designated FinOps alerts channel.

Quick start

  1. Click Use Blueprint to copy this flow into your Kestra instance.
  2. Add NEON_API_KEY and SLACK_WEBHOOK_URL to your Kestra secrets store.
  3. Update the neon_project_id input with your Neon project identifier.
  4. Run an initial manual execution to verify connectivity, then activate the daily schedule trigger.

How to extend

  • Automated Autosuspension Reset: Add an automated PATCH request to automatically set suspend_timeout_seconds back to 300 seconds for offending endpoints.
  • Branch Pruning: Combine this flow with Neon API calls to delete stale preview database branches that have had zero active queries for over 14 days.
  • Cost Dashboard Ingestion: Push audited compute hours and unit allocations into BigQuery, Snowflake, or ClickHouse for multi-cloud FinOps dashboards.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.