Automated API SLA and Data Drift Quarantine Pipeline
Runs parallel endpoint probes, aggregates batch metrics in DuckDB, scores drift in Python, and quarantines bad partitions.
Audits MySQL InnoDB tables for storage fragmentation bloat, recommending OPTIMIZE TABLE commands to reclaim disk space.
In active MySQL database workloads with frequent UPDATE operations and row deletions, the underlying InnoDB storage engine allocates new extents without automatically releasing unused space back to the operating system filesystem. Over months of application traffic, table data files (.ibd) accumulate substantial internal free space (DATA_FREE).
When fragmentation exceeds 30% to 50% of total table capacity, companies incur unnecessary cloud disk storage costs (e.g. AWS EBS gp3 or GCP Persistent Disk). Furthermore, fragmented B-tree index pages degrade buffer pool hit ratios and slow down table range scans.
This blueprint provides an automated storage advisor that audits MySQL information_schema.TABLES weekly, calculates exact fragmentation percentages and reclaimable megabytes, and compiles executable OPTIMIZE TABLE remediation advisories directly into your DBA team's Slack channel.
weekly_fragmentation_audit trigger (io.kestra.plugin.core.trigger.Schedule) executes every Sunday at 04:00 UTC.query_table_free_space task (io.kestra.plugin.jdbc.mysql.Query) queries information_schema.TABLES for InnoDB tables with DATA_FREE > 0.evaluate_table_fragmentation task (io.kestra.plugin.scripts.python.Script) filters tables exceeding min_wasted_mb_threshold and fragmentation_ratio_threshold, generating fragmentation_report.json.evaluate_advisory_trigger flowable task (io.kestra.plugin.core.flow.If) evaluates whether any candidates require defragmentation.alert_dba_fragmentation_advisor (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable maintenance plan.export_storage_manifest task records reclaimable disk stats for capacity planning.flowchart TD
A[Schedule: Weekly Sunday 04:00 UTC] --> B[query_table_free_space: MySQL]
B --> C[evaluate_table_fragmentation: Python Storage Analyzer]
C --> D{Fragmentation Threshold Breached?}
D -- Yes --> E[alert_dba_fragmentation_advisor: Slack]
D -- No --> F[log_compact_storage_status: Log]
E --> G[export_storage_manifest: Return JSON]
F --> G
OPTIMIZE TABLE) prepared in advance.Manually inspecting table fragmentation across dozens of database instances requires ad-hoc bash scripts and manual metric calculations. Kestra automates the inspection, analysis, and alerting into a scheduled, auditable workflow with zero ongoing maintenance.
| Name | Type | Default | Description |
|---|---|---|---|
mysql_url |
STRING | jdbc:mysql://... |
JDBC URL of target MySQL instance. |
mysql_username |
STRING | db_monitor |
Monitoring database user. |
target_schema |
STRING | app_db |
Database schema name to inspect. |
fragmentation_ratio_threshold |
FLOAT | 0.30 |
Minimum free-to-total size ratio (e.g. 0.30 = 30%). |
min_wasted_mb_threshold |
INT | 500 |
Minimum wasted MB to qualify table. |
slack_channel |
STRING | #dba-maintenance |
Slack channel destination for alerts. |
{{ outputs.evaluate_table_fragmentation.vars.action_recommended }}: Boolean flag indicating if any table exceeded thresholds.{{ outputs.evaluate_table_fragmentation.vars.total_reclaimable_mb }}: Total estimated disk space reclaimable across the schema.{{ outputs.evaluate_table_fragmentation.vars.top_table }}: Name of the table with the greatest wasted space.{{ outputs.evaluate_table_fragmentation.outputFiles['fragmentation_report.json'] }}: Complete JSON diagnostic report.MYSQL_PASSWORD: Password for the MySQL database user.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.MYSQL_PASSWORD and SLACK_WEBHOOK_URL in your Kestra namespace secrets.innodb_file_per_table=ON (enabled by default in modern MySQL). If disabled, space is reclaimed only within the shared ibdata1 tablespace.OPTIMIZE TABLE rebuilds the table in place and requires temporary disk space approximately equal to the size of the table.io.kestra.plugin.core.flow.EachSequential to automatically iterate through all candidate tables and execute OPTIMIZE TABLE during scheduled maintenance windows.SHOW GLOBAL STATUS LIKE 'Innodb_buffer_pool_reads' to correlate table fragmentation with cache miss spikes.