New to Kestra?
Use blueprints to kickstart your first workflows.
Audits MongoDB replica set active connections against configured capacity, alerting DBAs on Slack before connection exhaustion rejects clients.
This blueprint acts as an automated connection capacity guardian for MongoDB database clusters. Scheduled every 10 minutes, it inspects serverStatus().connections telemetry, computes active-to-total connection utilization percentages, and alerts database administrators on Slack before connection spikes breach maxIncomingConnections ceilings and reject incoming microservice client requests.
periodic_connection_probe trigger (io.kestra.plugin.core.trigger.Schedule) fires every 10 minutes.audit_mongodb_connections task (io.kestra.plugin.scripts.python.Script) connects to MongoDB via PyMongo, runs the administrative serverStatus command, and extracts active and available connection slots.check_connection_saturation flowable task (io.kestra.plugin.core.flow.If) branches based on whether connection utilization reached the warning percentage.notify_slack_dba (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) dispatches an urgent incident card with connection metrics.log_connections_nominal records confirmed status.export_connection_manifest task tags the execution with searchable status labels.flowchart TD
A[Schedule: Every 10 Minutes] --> B[audit_mongodb_connections: MongoDB serverStatus]
B --> C{Connection Utilization > Threshold?}
C -- Yes --> D[notify_slack_dba: Slack Webhook]
C -- No --> E[log_connections_nominal: Log]
D --> F[export_connection_manifest: Execution Labels]
E --> F
net.maxIncomingConnections.| Name | Type | Default | Description |
|---|---|---|---|
mongodb_connection_uri |
STRING | mongodb://mongodb-primary.internal:27017 |
MongoDB connection string pointing to the primary replica set node. |
max_connection_utilization_percent_warning |
FLOAT | 80.0 |
Connection utilization percentage threshold above which a saturation warning is triggered. |
slack_channel |
STRING | #mongodb-dba-alerts |
Slack channel destination for MongoDB connection capacity alerts. |
{{ outputs.audit_mongodb_connections.vars.current_connections }}: Count of active incoming connections.{{ outputs.audit_mongodb_connections.vars.available_connections }}: Remaining available connection slots before rejection.{{ outputs.audit_mongodb_connections.vars.total_capacity }}: Total configured connection ceiling.{{ outputs.audit_mongodb_connections.vars.utilization_percent }}: Percentage of connection capacity consumed.{{ outputs.audit_mongodb_connections.outputFiles['mongodb_connections_report.json'] }}: Full JSON connection health report.clusterMonitor or read privileges on the admin database.MONGODB_USER: MongoDB authentication username.MONGODB_PASSWORD: MongoDB authentication password.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.MONGODB_USER, MONGODB_PASSWORD, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.mongodb_connection_uri.net.maxIncomingConnections to 65,536, but system file descriptor limits (ulimit -n) often constrain practical connection capacity much lower (e.g. 1,024 or 4,096); verify operating system file descriptor limits.currentOp() to identify which client IP addresses and usernames account for the highest share of active connections.