id: tyk-gateway-health-and-reload-sentinel
namespace: company.team
description: |
Audits Tyk Open Source API Gateway instances on a schedule by probing the
gateway health endpoint and verifying canary ingress routing status, detecting
daemon degradation, route desynchronization, or stale cache drift, and
dispatching actionable Slack alerts with safe automated hot-reload remediation.
triggers:
- id: periodic_gateway_audit
type: io.kestra.plugin.core.trigger.Schedule
description: "Periodically audits Tyk API Gateway health and canary routing
integrity. Shipped disabled by default; enable once tyk_host points to an
active Tyk container."
cron: "*/15 * * * *"
disabled: true
inputs:
tyk_host: "localhost"
tyk_port: 8080
canary_listen_path: "canary-health-probe"
auto_reload: "false"
dry_run: "true"
inputs:
- id: tyk_host
type: STRING
displayName: "Tyk Gateway Host"
defaults: "localhost"
description: "Hostname or IP address of the Tyk Open Source API Gateway instance."
- id: tyk_port
type: INT
displayName: "Tyk Gateway Port"
defaults: 8080
description: "Port exposed by the Tyk Gateway HTTP listener (default: 8080)."
- id: canary_listen_path
type: STRING
displayName: "Canary Listen Path"
defaults: "canary-health-probe"
description: "Listen path of the canary API route monitored for end-to-end data
plane routing."
- id: auto_reload
type: STRING
displayName: "Auto-Reload Gateway Cache"
defaults: "false"
description: "Set to 'true' to trigger an automated hot-reload via /tyk/reload
when canary routing fails."
- id: dry_run
type: STRING
displayName: "Dry Run Mode"
defaults: "true"
description: "When 'true', alerts on routing failures and logs intended
remediations without issuing /tyk/reload."
tasks:
- id: probe_tyk_gateway_health
type: io.kestra.plugin.core.http.Request
description: "Queries Tyk Gateway GET /hello endpoint to verify daemon runtime
health, version, and responsiveness."
uri: "http://{{ inputs.tyk_host }}:{{ inputs.tyk_port }}/hello"
method: GET
headers:
Accept: "application/json"
options:
allowFailed: true
- id: probe_canary_ingress_route
type: io.kestra.plugin.core.http.Request
description: "Sends probe request to canary listen path to confirm active data
plane routing and reverse-proxy flow."
uri: "http://{{ inputs.tyk_host }}:{{ inputs.tyk_port }}/{{
inputs.canary_listen_path }}"
method: GET
headers:
Accept: "application/json"
options:
allowFailed: true
- id: classify_gateway_verdict
type: io.kestra.plugin.core.flow.Switch
description: "Classifies Tyk Gateway operational state based on /hello health
responses and canary ingress status."
value: >-
{% if outputs.probe_tyk_gateway_health.status != 200 or
(fromJson(outputs.probe_tyk_gateway_health.body).status ?? '') != 'pass'
%} GATEWAY_UNHEALTHY {% elif outputs.probe_canary_ingress_route.status ==
404 or outputs.probe_canary_ingress_route.status >= 500 %}
CANARY_ROUTING_FAILED {% else %} HEALTHY {% endif %}
cases:
GATEWAY_UNHEALTHY:
- id: alert_gateway_unhealthy
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: "Dispatches critical operational alert when Tyk /hello endpoint
reports failure or non-pass status."
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#gateway-alerts",
"text": ":rotating_light: *Tyk API Gateway Unhealthy*",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rotating_light: *Tyk Gateway Health Check Failed*\n*Host:* `{{ inputs.tyk_host }}:{{ inputs.tyk_port }}`\n*HTTP Status:* `{{ outputs.probe_tyk_gateway_health.status }}`\n*Reported Status:* `{{ fromJson(outputs.probe_tyk_gateway_health.body).status ?? 'UNKNOWN' }}`\nThe gateway data plane is degraded or unresponsive. Microservice ingress traffic may fail."
}
}
]
}
CANARY_ROUTING_FAILED:
- id: alert_canary_routing_failed
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: "Dispatches alert when canary listen path returns 404 or server
error, indicating route drift or stale cache."
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#gateway-alerts",
"text": ":warning: *Tyk Gateway Canary Ingress Route Failed*",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":warning: *Canary Ingress Routing Drift Detected*\n*Host:* `{{ inputs.tyk_host }}:{{ inputs.tyk_port }}`\n*Listen Path:* `/{{ inputs.canary_listen_path }}`\n*HTTP Status:* `{{ outputs.probe_canary_ingress_route.status }}`\nCanary API endpoint returned error or 404. Gateway cache may be stale or out of sync with Redis."
}
}
]
}
- id: evaluate_remediation_on_routing_failure
type: io.kestra.plugin.core.flow.If
description: "Evaluates safety gate before issuing hot-reload signal to Tyk
Gateway."
condition: "{{ inputs.auto_reload == 'true' and inputs.dry_run == 'false' }}"
then:
- id: trigger_gateway_hot_reload
type: io.kestra.plugin.core.http.Request
description: "Issues GET /tyk/reload to flush internal memory cache and reload
API definitions from store."
uri: "http://{{ inputs.tyk_host }}:{{ inputs.tyk_port }}/tyk/reload"
method: GET
headers:
X-Tyk-Authorization: "{{ secret('TYK_SECRET') }}"
- id: log_hot_reload_triggered
type: io.kestra.plugin.core.log.Log
message: "Triggered automated hot-reload on Tyk Gateway to resynchronize API
definitions."
else:
- id: log_dry_run_suppressed
type: io.kestra.plugin.core.log.Log
message: "Dry-run active or auto_reload disabled. Suppressed automated
/tyk/reload request."
HEALTHY:
- id: log_gateway_healthy
type: io.kestra.plugin.core.log.Log
message: "Tyk Gateway is healthy (/hello=pass, canary status={{
outputs.probe_canary_ingress_route.status }})."
- id: log_audit_summary
type: io.kestra.plugin.core.log.Log
description: "Records execution audit lineage and parameter state across Tyk
gateway verification steps."
message: "Tyk Gateway Sentinel Audit Complete: Host={{ inputs.tyk_host }},
Port={{ inputs.tyk_port }}, CanaryPath={{ inputs.canary_listen_path }},
DryRun={{ inputs.dry_run }}."
errors:
- id: alert_connectivity_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: "Dispatches critical outage alert when network connection to Tyk
Gateway fails completely."
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#gateway-alerts",
"text": ":rotating_light: *Tyk API Gateway Connection Failure*",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":rotating_light: *Tyk Gateway Ingress Unreachable*\n*Target Host:* `{{ inputs.tyk_host }}:{{ inputs.tyk_port }}`\n*Execution ID:* `{{ execution.id }}`\nKestra was unable to establish an HTTP connection. Check container status, network routes, or firewall rules."
}
}
]
}