id: singlestore-pipeline-ingestion-stall-sentinel
namespace: company.data
inputs:
- id: singlestore_host
type: STRING
displayName: SingleStore Host
defaults: "singlestore.internal"
description: Hostname or IP address of the SingleStore master aggregator or leaf
node exposing port 3306.
- id: singlestore_port
type: INT
displayName: SingleStore Port
defaults: 3306
description: Port number for the MySQL wire protocol interface on SingleStore
(default 3306).
- id: singlestore_database
type: STRING
displayName: Database Name
defaults: "information_schema"
description: Database name to establish the session against (default
information_schema).
- id: slack_channel
type: STRING
displayName: Slack Channel
defaults: "#data-platform-alerts"
description: Slack channel destination for operational pipeline incident cards.
- id: auto_restart
type: BOOL
displayName: Auto Restart Failed Pipelines
defaults: true
description: Automatically dispatch START PIPELINE commands for pipelines stuck
in an Error state.
- id: dry_run
type: BOOL
displayName: Dry Run Mode
defaults: false
description: When true, audits pipeline states and dispatches notifications but
skips remediation restarts.
triggers:
- id: every_fifteen_minutes
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"
tasks:
- id: probe_stalled_pipelines
type: io.kestra.plugin.jdbc.mysql.Query
url: "jdbc:mysql://{{ inputs.singlestore_host }}:{{ inputs.singlestore_port
}}/{{ inputs.singlestore_database }}"
username: "{{ secret('SINGLESTORE_USERNAME') }}"
password: "{{ secret('SINGLESTORE_PASSWORD') }}"
fetchType: FETCH
allowFailure: true
sql: |
SELECT
p.DATABASE_NAME AS database_name,
p.PIPELINE_NAME AS pipeline_name,
p.STATE AS pipeline_state,
COALESCE(e.ERROR_KIND, 'None') AS error_kind,
COALESCE(e.ERROR_CODE, 0) AS error_code,
COALESCE(SUBSTRING(e.ERROR_MESSAGE, 1, 200), 'No error message recorded') AS error_message
FROM information_schema.PIPELINES p
LEFT JOIN (
SELECT
DATABASE_NAME,
PIPELINE_NAME,
ERROR_KIND,
ERROR_CODE,
ERROR_MESSAGE,
ROW_NUMBER() OVER (PARTITION BY DATABASE_NAME, PIPELINE_NAME ORDER BY ERROR_UNIX_TIMESTAMP DESC) AS rn
FROM information_schema.PIPELINES_ERRORS
) e ON p.DATABASE_NAME = e.DATABASE_NAME AND p.PIPELINE_NAME = e.PIPELINE_NAME AND e.rn = 1
WHERE p.STATE != 'Running'
ORDER BY p.STATE ASC, p.PIPELINE_NAME ASC
LIMIT 50;
- id: route_by_pipeline_health
type: io.kestra.plugin.core.flow.Switch
value: >-
{% if outputs.probe_stalled_pipelines.rows is null %} PROBE_FAILED {% else
%}
{% set error_count = 0 %}
{% set stopped_count = 0 %}
{% for row in outputs.probe_stalled_pipelines.rows %}
{% if row.pipeline_state == 'Error' %}
{% set error_count = error_count + 1 %}
{% else %}
{% set stopped_count = stopped_count + 1 %}
{% endif %}
{% endfor %}
{% if error_count > 0 %}
CRITICAL
{% elseif stopped_count > 0 %}
WARNING
{% else %}
HEALTHY
{% endif %}
{% endif %}
cases:
CRITICAL:
- id: alert_critical_slack
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ inputs.slack_channel }}",
"text": "[CRITICAL] SingleStore Ingestion Pipelines in Error State - Streaming Ingestion Halted",
"attachments": [
{
"color": "#D32F2F",
"title": "SingleStore Ingestion Pipeline Failure Incident",
"fields": [
{
"title": "Cluster Host",
"value": "{{ inputs.singlestore_host }}:{{ inputs.singlestore_port }}",
"short": true
},
{
"title": "Failed Pipelines Count",
"value": "{{ outputs.probe_stalled_pipelines.size }}",
"short": true
},
{
"title": "Severity",
"value": "CRITICAL - Pipeline Ingestion Stalled",
"short": true
},
{
"title": "Remediation Status",
"value": "{{ (inputs.auto_restart and not inputs.dry_run) ? 'Dispatching START PIPELINE' : 'Remediation Skipped (Dry Run or Disabled)' }}",
"short": true
}
],
"footer": "Kestra SingleStore Sentinel | Execution ID: {{ execution.id }}"
}
]
}
- id: check_remediation
type: io.kestra.plugin.core.flow.If
condition: "{{ inputs.auto_restart == true and inputs.dry_run == false }}"
then:
- id: restart_pipelines
type: io.kestra.plugin.core.flow.Loop
values: "{{ outputs.probe_stalled_pipelines.rows }}"
tasks:
- id: execute_start_pipeline
type: io.kestra.plugin.jdbc.mysql.Query
url: "jdbc:mysql://{{ inputs.singlestore_host }}:{{ inputs.singlestore_port
}}/{{ inputs.singlestore_database }}"
username: "{{ secret('SINGLESTORE_USERNAME') }}"
password: "{{ secret('SINGLESTORE_PASSWORD') }}"
sql: "START PIPELINE `{{ item.value.database_name }}`.`{{
item.value.pipeline_name }}`;"
- id: notify_remediation_slack
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ inputs.slack_channel }}",
"text": "[REMEDIATION] SingleStore START PIPELINE command dispatched for all failed pipelines."
}
WARNING:
- id: alert_warning_slack
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ inputs.slack_channel }}",
"text": "[WARNING] SingleStore Stopped Ingestion Pipelines Detected - Ingestion Inactive",
"attachments": [
{
"color": "#F57C00",
"title": "SingleStore Inactive Pipeline Warning",
"fields": [
{
"title": "Cluster Host",
"value": "{{ inputs.singlestore_host }}:{{ inputs.singlestore_port }}",
"short": true
},
{
"title": "Inactive Pipelines Count",
"value": "{{ outputs.probe_stalled_pipelines.size }}",
"short": true
},
{
"title": "Severity",
"value": "WARNING - Pipeline Stopped",
"short": true
},
{
"title": "Auto Restart",
"value": "{{ inputs.auto_restart ? 'Enabled' : 'Disabled' }}",
"short": true
}
],
"footer": "Kestra SingleStore Sentinel | Execution ID: {{ execution.id }}"
}
]
}
PROBE_FAILED:
- id: alert_probe_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ inputs.slack_channel }}",
"text": "[CRITICAL] SingleStore Sentinel Probe Failed - Unable to query information_schema.PIPELINES. Verify network routing and database credentials."
}
HEALTHY:
- id: log_pipelines_healthy
type: io.kestra.plugin.core.log.Log
message: "SingleStore cluster pipelines health is normal. All evaluated
pipelines are in Running state."
- id: log_audit_summary
type: io.kestra.plugin.core.log.Log
message: "SingleStore pipeline health audit completed. Status: {{
outputs.route_by_pipeline_health.value ?? 'PROCESSED' }}. Evaluated
stalled pipelines count: {{ outputs.probe_stalled_pipelines.size ?? 0 }}."
errors:
- id: on_flow_failure
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "{{ inputs.slack_channel }}",
"text": "[ERROR] SingleStore Pipeline Ingestion Stall Sentinel execution aborted unexpectedly. Execution ID: {{ execution.id }}."
}