id: vernemq-mqtt-cluster-health-and-queue-backlog-sentinel
namespace: company.infrastructure
description: "Continuously audits VerneMQ distributed MQTT broker cluster node
health, monitors queue message drop telemetry, executes synthetic publish
probes, and alerts on telemetry congestion."
inputs:
- id: vernemq_host
type: STRING
defaults: "localhost"
description: "Hostname or IP address of the VerneMQ broker node."
- id: vernemq_mqtt_port
type: INT
defaults: 1883
description: "TCP port for standard MQTT client connections (default: 1883)."
- id: vernemq_metrics_port
type: INT
defaults: 8888
description: "HTTP port for VerneMQ Prometheus metrics and status endpoint
(default: 8888)."
- id: max_dropped_messages_threshold
type: INT
defaults: 10
description: "Maximum allowable dropped messages from queue overflow before
triggering a critical alert."
- id: synthetic_probe_topic
type: STRING
defaults: "kestra/sentinel/heartbeat"
description: "MQTT topic used for synthetic heartbeat publish verification."
- id: slack_channel
type: STRING
defaults: "#devops-alerts"
description: "Slack channel for operational alerts and incident escalation."
triggers:
- id: periodic_vernemq_audit
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"
disabled: true
tasks:
- id: probe_vernemq_metrics
type: io.kestra.plugin.core.http.Request
description: "Fetches Prometheus telemetry from VerneMQ HTTP metrics endpoint to
evaluate cluster node count and queue drops."
uri: "http://{{ inputs.vernemq_host }}:{{ inputs.vernemq_metrics_port
}}/metrics"
method: GET
options:
timeout:
readIdleTimeout: PT15S
- id: publish_synthetic_mqtt_probe
type: io.kestra.plugin.mqtt.Publish
description: "Executes a synthetic MQTT publish probe to verify broker
responsiveness, socket health, and payload ingestion."
server: "tcp://{{ inputs.vernemq_host }}:{{ inputs.vernemq_mqtt_port }}"
clientId: "kestra-vernemq-sentinel"
topic: "{{ inputs.synthetic_probe_topic }}"
serdeType: JSON
qos: 1
retain: false
from:
probe_id: "{{ execution.id }}"
probe_origin: "kestra-sentinel"
timestamp: "{{ now() }}"
status: "HEALTH_CHECK"
- id: classify_cluster_health
type: io.kestra.plugin.core.flow.Switch
description: "Evaluates HTTP status code, synthetic MQTT publish status, and
dropped message counts to route incident handling."
value: >-
{% if outputs.probe_vernemq_metrics.code != 200 %}
BROKER_METRICS_UNAVAILABLE
{% elseif outputs.probe_vernemq_metrics.body is defined and
('vmq_queue_message_drop' in outputs.probe_vernemq_metrics.body and
(outputs.probe_vernemq_metrics.body | split('vmq_queue_message_drop')[1] |
split('\n')[0] | trim | int(0)) > inputs.max_dropped_messages_threshold)
%}
QUEUE_DROP_SPIKE
{% else %}
HEALTHY
{% endif %}
cases:
BROKER_METRICS_UNAVAILABLE:
- id: alert_metrics_unavailable
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: "Notifies DevOps on-call when the VerneMQ metrics endpoint is
unreachable or returning HTTP errors."
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": "[CRITICAL] VerneMQ Broker Telemetry Endpoint Unreachable",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "[ALERT] VerneMQ Broker Telemetry Offline"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Broker Host:*\n`{{ inputs.vernemq_host }}:{{ inputs.vernemq_metrics_port }}`"
},
{
"type": "mrkdwn",
"text": "*HTTP Status:*\n`{{ outputs.probe_vernemq_metrics.code }}`"
},
{
"type": "mrkdwn",
"text": "*Execution ID:*\n`{{ execution.id }}`"
},
{
"type": "mrkdwn",
"text": "*Timestamp:*\n`{{ now() }}`"
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Immediate action required: Verify VerneMQ daemon state, Erlang runtime, and network security groups."
}
]
}
]
}
- id: fail_on_unavailable
type: io.kestra.plugin.core.execution.Fail
description: "Marks execution as failed to trigger alerting escalation."
QUEUE_DROP_SPIKE:
- id: alert_queue_drops
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: "Dispatches high-priority alert when VerneMQ dropped message
counter breaches acceptable threshold."
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"text": "[WARNING] VerneMQ Queue Message Drops Exceeded Threshold",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "[WARNING] VerneMQ Telemetry Queue Drops Detected"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Broker Host:*\n`{{ inputs.vernemq_host }}`"
},
{
"type": "mrkdwn",
"text": "*Threshold:*\n`{{ inputs.max_dropped_messages_threshold }}`"
},
{
"type": "mrkdwn",
"text": "*Synthetic Ingress:*\n`PUBLISHED (QoS 1)`"
},
{
"type": "mrkdwn",
"text": "*Status:*\n`QUEUE_CONGESTION`"
}
]
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "Action required: Inspect subscriber consumer lag, slow clients, and queue buffer memory settings."
}
]
}
]
}
HEALTHY:
- id: log_cluster_healthy
type: io.kestra.plugin.core.log.Log
description: "Records clean health audit metrics when broker connectivity and
queue thresholds are nominal."
message: "[OK] VerneMQ broker at {{ inputs.vernemq_host }} is healthy. Metrics
endpoint responded with HTTP {{ outputs.probe_vernemq_metrics.code
}} and synthetic probe published successfully."
- id: audit_run_summary
type: io.kestra.plugin.core.log.Log
description: "Final audit log summarizing execution metrics, probe topic, and
verified endpoint state."
message: "[AUDIT] VerneMQ sentinel completed execution {{ execution.id }}.
Target broker: {{ inputs.vernemq_host }}:{{ inputs.vernemq_mqtt_port }}.
Probe topic: {{ inputs.synthetic_probe_topic }}."