Schedule icon
AwsCLI icon
Return icon
If icon
Create icon
SlackIncomingWebhook icon
Log icon

Amazon RDS Connection Spike and Headroom Sentinel

Monitor Amazon RDS database connection spikes and pool exhaustion with Kestra. Query CloudWatch metrics, open GitHub DBA issues, and notify Slack.

Categories
CloudDataInfrastructure

Diagram unavailable

We could not build the topology for this blueprint. The flow itself is valid, use the YAML on the left to run it.

Relational databases in production environments can experience sudden connection spikes due to application thread pool leaks, traffic surges, or cascading query deadlocks. When connection pools exhaust available instance capacity (max_connections), incoming client requests are refused, causing cascading service outages. This blueprint queries Amazon CloudWatch for RDS DatabaseConnections metrics on a regular cadence, identifies headroom breaches, automatically logs a prioritized GitHub DBA investigation ticket, and alerts database engineers on Slack.

How it works

  1. periodic_database_health_check (io.kestra.plugin.core.trigger.Schedule) initiates the check periodically (shipped disabled for safe manual validation).
  2. probe_rds_metrics (io.kestra.plugin.aws.cli.AwsCLI) queries Amazon CloudWatch metrics (AWS/RDS -> DatabaseConnections) for the peak connection count across the last 15 minutes.
  3. evaluate_connection_headroom (io.kestra.plugin.core.debug.Return) calculates whether maximum connections breached the operator-defined threshold.
  4. branch_on_connection_spike (io.kestra.plugin.core.flow.If) evaluates the headroom condition:
    • then: Automatically files a GitHub tracking issue via create_dba_incident_issue (io.kestra.plugin.github.issues.Create) and alerts the DBA Slack channel via alert_dba_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook).
    • else: Logs a clean status message (log_database_healthy) confirming normal operational load.
  5. log_audit_complete (io.kestra.plugin.core.log.Log) records the final connection summary for observability.
  6. The errors block alerts Slack if AWS credentials or CloudWatch API calls fail.

What you get

  • Automated CloudWatch metric auditing without manual console browsing.
  • Early warning before connection pool exhaustion causes client connection refusal errors.
  • Automated GitHub tracking issues with instance identifiers and peak utilization metrics.
  • Immediate Slack notifications for rapid database troubleshooting.

Who it's for

  • Data Administrators (DBAs) and Site Reliability Engineers managing Amazon RDS (PostgreSQL/MySQL).
  • Backend platform teams managing microservice connection pool sizing.
  • Cloud infrastructure leads ensuring database headroom stability.

Why orchestrate this with Kestra

Kestra unifies AWS metric polling, conditional logic, GitHub issue creation, and Slack notifications into a single auditable workflow. It securely injects AWS credentials, handles transient network retries, and eliminates the need for separate standalone alerting lambdas or fragmented monitoring scripts.

Prerequisites

  • An AWS account with an active RDS instance.
  • An AWS IAM user or role with cloudwatch:GetMetricData permission.
  • A GitHub Personal Access Token with repository issue creation permissions.
  • A Slack incoming webhook URL for notifications.

Secrets

  • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY: AWS credentials with CloudWatch read permissions.
  • GITHUB_TOKEN: GitHub token used to open database investigation issues.
  • SLACK_WEBHOOK: Slack Incoming Webhook URL for DBA alerts.

Inputs

  • aws_region (STRING, default us-east-1): Target AWS region hosting the RDS database.
  • db_instance_identifier (STRING, default production-postgres-cluster): Name or identifier of the RDS instance to monitor.
  • connection_threshold (INT, default 250): Maximum tolerated connections before alerting.
  • github_repository (STRING, default my-org/database-operations): Target GitHub repository for logging incident issues.

Outputs

  • outputs.probe_rds_metrics.vars.MetricDataResults: Raw CloudWatch metric data points.
  • outputs.evaluate_connection_headroom.value: Extracted metric evaluation containing max_connections, threshold, and is_exhausted.

Quick start

  1. Configure AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, GITHUB_TOKEN, and SLACK_WEBHOOK in your Kestra namespace.
  2. Import this flow and set db_instance_identifier to match your target RDS database.
  3. Run the flow manually to verify metric retrieval and Slack notification dispatch.
  4. Enable the periodic_database_health_check trigger for continuous headroom monitoring.

How to extend

  • Add an automated query killer task or RDS reboot task gated behind manual operator approval.
  • Pull CPU and memory utilization metrics alongside connection counts for a complete health report.
  • Route critical alerts to PagerDuty or Opsgenie when connection exhaustion is imminent.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.