New to Kestra?
Use blueprints to kickstart your first workflows.
Audits HashiCorp Consul catalog for services failing health checks past thresholds, calculating dead nodes and alerting SREs on Slack.
In dynamic cloud environments utilizing HashiCorp Consul for service discovery and mesh networking, microservice containers and virtual machines frequently terminate abruptly without invoking graceful catalog deregistration hooks.
When an ephemeral service instance crashes or gets rescheduled by Kubernetes or Nomad, its corresponding health check transitions to critical. Unless DeregisterCriticalServiceAfter is explicitly defined on each individual service registration payload, the dead service endpoint remains registered in Consul DNS and HTTP lookup catalogs indefinitely. Downstream load balancers (such as Envoy, NGINX, or Traefik) and upstream consumers continue routing live user requests to unreachable endpoints, causing cascading HTTP 502/503 outages.
This blueprint acts as an automated service mesh hygiene sentinel. Executing every fifteen minutes, it queries the Consul Health API for services stuck in critical status, identifies unmanaged dead nodes, and delivers actionable Slack alerts with exact CLI deregistration commands to on-call platform engineers.
audit_failing_consul_services trigger (io.kestra.plugin.core.trigger.Schedule) initiates catalog health queries every fifteen minutes.scan_critical_service_checks task (io.kestra.plugin.scripts.python.Script) invokes the Consul /v1/health/state/critical endpoint for the target datacenter, parsing check outputs and service identifiers.evaluate_failing_services flowable task (io.kestra.plugin.core.flow.If) evaluates whether any critical services exceed healthy cluster SLAs.notify_slack_consul_deregistration (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) dispatches a triage card detailing the primary offending service, node, and copy-paste remediation commands (consul services deregister -id=...).log_healthy_consul_catalog logs healthy catalog status.export_consul_audit_manifest task records an execution summary for SRE telemetry pipelines.flowchart TD
A[Schedule: Every 15 Minutes] --> B[scan_critical_service_checks: Consul Health API]
B --> C{Critically Failing Services Found?}
C -- Yes --> D[notify_slack_consul_deregistration: Slack Webhook]
C -- No --> E[log_healthy_consul_catalog: Log]
D --> F[export_consul_audit_manifest: Return JSON]
E --> F
DeregisterCriticalServiceAfter definitions.| Name | Type | Default | Description |
|---|---|---|---|
consul_http_addr |
STRING | "http://localhost:8500" |
Base URL of the HashiCorp Consul agent or cluster API endpoint. |
critical_failing_threshold_minutes |
INT | 30 |
Duration a service health check must remain in critical status before alerting. |
datacenter |
STRING | "dc1" |
Target Consul datacenter namespace to query. |
slack_channel |
STRING | "#sre-service-discovery" |
Slack channel destination for service discovery notifications. |
{{ outputs.scan_critical_service_checks.vars.has_stale_services }}: Boolean flag indicating if critical service checks were discovered.{{ outputs.scan_critical_service_checks.vars.stale_count }}: Total number of service instances currently stuck in critical status.{{ outputs.scan_critical_service_checks.vars.top_service }}: Service name of the most prominent failing registration.{{ outputs.scan_critical_service_checks.vars.top_node }}: Node hosting the offending failing check.{{ outputs.scan_critical_service_checks.outputFiles['consul_health_audit.json'] }}: Structured JSON audit report.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL with permissions to post messages.SLACK_WEBHOOK_URL in your Kestra namespace secrets.consul_http_addr to point to your internal Consul server or agent URL.acl.enabled = true), pass the management or operator token via the X-Consul-Token HTTP header in requests.PUT /v1/catalog/deregister directly after manager approval via io.kestra.plugin.core.flow.Pause./v1/catalog/datacenters to enforce multi-region catalog hygiene.