Schedule icon
Query icon
Switch icon
SlackIncomingWebhook icon
If icon
Log icon

Vitess Tablet Health & Shard Routing Sentinel

Audit Vitess SHOW VITESS_TABLETS for non-serving primary and replica tablets, dispatch Slack incident alerts, and correlate shard topology.

Categories
DataInfrastructure

Vitess is a cloud-native database clustering system designed for horizontal scaling and sharding of MySQL. Traffic routing, connection pooling, and cross-shard query aggregation are handled by stateless VTGate proxy servers, which direct SQL operations to backend VTTablet management daemons. In production, host hardware crashes, network partitioning between VTGate and cell topologies, pod evictions during Kubernetes rolling updates, or failed emergency reparenting (VTOrc failover) can leave tablets in a NOT_SERVING state. When a primary tablet ceases serving, VTGate cannot route writes to that shard partition, causing immediate application query errors and transaction rollbacks. This blueprint provides automated continuous surveillance over SHOW VITESS_TABLETS, differentiates primary write outages from replica read degradations, alerts engineering teams via Slack, and audits SHOW VITESS_SHARDS topology layouts during cluster degradation.

How it works

  1. Scheduled trigger (every_fifteen_minutes) initiates diagnostic health verification every 15 minutes, with manual runs supported via customizable inputs.
  2. Diagnostic probe (probe_vitess_tablets) connects to the Vitess VTGate proxy over the MySQL wire protocol (port 15306) via io.kestra.plugin.jdbc.mysql.Query and executes SHOW VITESS_TABLETS; to inspect all registered cluster tablets.
  3. Classification logic evaluates query output using Pebble templating, discerning whether any primary tablets are in a NOT_SERVING state (CRITICAL), if replica or read-only tablets are degraded (WARNING), if all tablets are serving (HEALTHY), or if the VTGate connection failed (PROBE_FAILED).
  4. Routing task (route_by_tablet_health) switches execution along dedicated paths according to the classified severity.
  5. On CRITICAL or WARNING states, structured Slack incident cards notify operations channels with impacted gateway endpoints, tablet counts, severity classifications, and targeted keyspaces.
  6. When primary tablet failures occur and audit_shard_topology is enabled, query_vitess_shards executes SHOW VITESS_SHARDS; to capture the shard partitioning boundaries and primary assignments across the affected keyspace.
  7. On PROBE_FAILED, dedicated alerts notify administrators of unreachable proxy ports or authentication failures.
  8. Audit log task (log_audit_summary) writes execution metadata and evaluated tablet counts to task logs.

What you get

  • Automated continuous surveillance of Vitess tablet states across all cells, keyspaces, and shard ranges.
  • Differentiated operational alerting distinguishing critical primary write partition dropouts from replica read degradations.
  • Automated topology correlation capturing shard boundary assignments during active incident investigations.
  • Full execution traceability and audit logging without leaking database credentials in logs or alert payloads.
  • Clean code standards with strictly zero emojis across workflow definitions, notifications, and logs.

Who it's for

  • Database Reliability Engineers and Platform Teams maintaining large-scale sharded Vitess clusters.
  • Site Reliability Engineers ensuring MySQL write partition availability and zero-downtime resharding.
  • Infrastructure Architects managing distributed database topologies across multiple Kubernetes zones.

Why orchestrate this with Kestra

  • Declarative YAML definition unifies distributed tablet surveillance, conditional severity triage, and topology diagnostics into version-controlled GitOps workflows.
  • Native MySQL JDBC plugin connectivity communicates directly with VTGate's MySQL wire protocol without external agent daemons or Python container overhead.
  • Built-in conditional routing isolates healthy baseline checks from multi-tiered incident notification cards.
  • Immutable execution history provides operational evidence documenting tablet recovery timelines and shard failover durations.
  • Cloud-native scheduling and flow-level error-trapping ensure continuous sentinel operation independent of external cron infrastructure.

Prerequisites

  • Vitess cluster running with VTGate MySQL wire compatibility enabled (default port 15306).
  • Database user with permissions to execute SHOW VITESS_TABLETS and SHOW VITESS_SHARDS via VTGate.
  • Slack incoming webhook URL for operational incident dispatch.

Secrets

  • VITESS_USERNAME: Username for authenticating to the Vitess VTGate MySQL interface.
  • VITESS_PASSWORD: Password for the Vitess database user.
  • SLACK_WEBHOOK_URL: Incoming webhook URL for posting incident cards to Slack.

Quick start

  1. Configure VITESS_USERNAME, VITESS_PASSWORD, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Deploy this blueprint to your Kestra instance and trigger an initial run with default inputs to verify connectivity against your VTGate server.
  3. Review the execution log in the Kestra UI to verify tablet query execution from SHOW VITESS_TABLETS.
  4. Enable the every_fifteen_minutes schedule trigger to activate automated continuous monitoring.

How to extend

  • Add SHOW VITESS_REPLICATION_STATUS; checks to detect replication lag and throttler delays across replica tablets.
  • Integrate PagerDuty alerting via io.kestra.plugin.pagerduty.notifications.PagerDutyAlert for immediate on-call escalation during primary shard dropouts.
  • Attach VTOrc (Vitess Orchestrator) API probes to monitor automated failover decision queues.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.