Schedule icon
Request icon
Switch icon
SlackIncomingWebhook icon
If icon
Log icon

Apache APISIX Route Health & Upstream Drift Sentinel

Audit Apache APISIX gateway health and canary route status, detect configuration drift, and dispatch Slack alerts.

Categories
Infrastructure

Continuously audits Apache APISIX API Gateway instances on a schedule by probing Control API health and interrogating Admin API route definitions, identifying missing canary endpoints, disabled routes, and control plane failures while providing dual-gated automated remediation.

How it works

  1. periodic_gateway_audit (io.kestra.plugin.core.trigger.Schedule) triggers every 15 minutes, passing target host, port configurations, and canary route identifiers. Shipped disabled by default for safe initial setup.
  2. probe_apisix_control_health (io.kestra.plugin.core.http.Request) invokes the APISIX Control API endpoint GET /v1/healthcheck to verify daemon process readiness and runtime health.
  3. probe_canary_route_status (io.kestra.plugin.core.http.Request) queries the APISIX Admin API endpoint GET /apisix/admin/routes/{id} with administrative credentials (X-API-KEY) to inspect the operational status of the designated canary route.
  4. classify_gateway_verdict (io.kestra.plugin.core.flow.Switch) evaluates the responses:
    • CONTROL_PLANE_UNHEALTHY: Fires when the Control API returns non-200 or status is not ok, alerting #gateway-alerts via io.kestra.plugin.slack.notifications.SlackIncomingWebhook.
    • CANARY_ROUTE_MISSING: Fires when the canary route returns 404, indicating accidental deletion or desynchronized GitOps state. Dispatches a Slack alert and, if auto_restore_route is enabled and dry_run is false, provisions the canonical route via PUT /apisix/admin/routes/{id}.
    • CANARY_ROUTE_DISABLED: Fires when the route exists but its status is set to 0 (disabled), dropping ingress traffic. Dispatches a Slack alert and, if remediation gates pass, issues a PATCH request to restore status: 1.
    • HEALTHY: Confirms normal gateway operation and records compliant state via io.kestra.plugin.core.log.Log.
  5. log_audit_summary (io.kestra.plugin.core.log.Log) records completion details and parameter state for regulatory compliance and audit lineage.
  6. The global errors block intercepts connection timeouts or refused sockets, alerting on-call engineers when the APISIX container or pod is down.

What you get

  • Automated Day 2 health and drift monitoring for Apache APISIX API Gateway deployments.
  • Early warning when ingress routes are accidentally disabled, deleted, or de-synchronized from GitOps configurations.
  • Safe dual-key automated remediation (auto_restore_route: true and dry_run: false) preventing unintended production mutations.
  • Centralized audit lineage tracking gateway control plane availability over time.

Who it's for

  • Platform Engineers and Site Reliability Engineers managing cloud-native API gateways and Kubernetes ingress controllers.
  • DevOps Teams operating Apache APISIX standalone or clustered topologies.
  • Security and Compliance Teams enforcing route availability and ingress baseline policies.

Why orchestrate this with Kestra

API gateways sit at the perimeter of production microservices architectures. A failure in the control plane or an accidental route deletion silently causes catastrophic outages for upstream consumers. Kestra provides declarative scheduled orchestration, robust multi-branch condition evaluation with Pebble expressions, built-in credential masking via secrets, and safe remediation execution without brittle custom cron scripts.

Prerequisites

  • A running Apache APISIX instance (version 3.x+). The official open-source Docker image (apache/apisix:3.9.1-debian) is free and open-source under the Apache 2.0 license.
  • APISIX Control API enabled (port 9092) and Admin API enabled (port 9180).
  • An incoming Slack webhook URL for routing alerts.

Secrets

  • APISIX_ADMIN_KEY: Administrative API key for APISIX Admin API authentication (passed in X-API-KEY header; default in open-source container is edd1c9f034335f136f87ad84b625c8f1).
  • SLACK_WEBHOOK_URL: Slack incoming webhook URL used by alert_control_plane_unhealthy, alert_canary_route_missing, alert_canary_route_disabled, and alert_connectivity_failure.

Quick start

  1. Start a local Apache APISIX container:
    docker run -d --name apisix-quickstart -p 9080:9080 -p 9180:9180 -p 9092:9092 apache/apisix:3.9.1-debian
    
  2. Create a canary route on the APISIX Admin API:
    curl -i http://localhost:9180/apisix/admin/routes/canary_health_route -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '{"uri":"/healthz","status":1,"upstream":{"type":"roundrobin","nodes":{"127.0.0.1:8080":1}}}'
    
  3. Configure APISIX_ADMIN_KEY and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  4. Execute this workflow with default inputs (dry_run: true).
  5. Verify in the execution logs that log_gateway_healthy confirms healthy gateway operation.
  6. Enable periodic_gateway_audit to schedule continuous 15-minute evaluations.

How to extend

  • Add multiple canary routes or upstream pool probes within a parallel task block to audit the entire route catalog.
  • Wire a downstream PagerDuty incident trigger via io.kestra.plugin.pagerduty.notifications.PagerDutyAlert when CONTROL_PLANE_UNHEALTHY fires.
  • Combine with GitOps webhook triggers (io.kestra.plugin.core.trigger.Webhook) to automatically audit route integrity immediately after CI/CD deployment pipelines merge.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.