New to Kestra?
Use blueprints to kickstart your first workflows.
Audits Apache Iceberg table snapshot metadata and manifest fragmentation with DuckDB, recommending maintenance actions via Slack.
This blueprint acts as an automated data lakehouse optimization sentinel for Apache Iceberg tables using DuckDB. Scheduled weekly, it inspects Iceberg metadata.json manifests, tracks snapshot lineage accumulation, evaluates small manifest fragmentation, and delivers maintenance recommendations to Slack before planning latency degrades downstream analytical queries.
weekly_iceberg_metadata_audit trigger (io.kestra.plugin.core.trigger.Schedule) fires every Sunday at 04:00 UTC.inspect_iceberg_metadata task (io.kestra.plugin.scripts.python.Script) queries the table's metadata.json file on cloud object storage using DuckDB, extracting snapshot count, lineage length, and Iceberg format versions.check_optimization_needs flowable task (io.kestra.plugin.core.flow.If) branches based on whether snapshot accumulation exceeded defined health thresholds.notify_slack_lakehouse (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) dispatches maintenance recommendations to the lakehouse team.log_lakehouse_nominal records confirmed status.export_lakehouse_manifest task tags the execution with searchable status labels.flowchart TD
A[Schedule: Sunday 04:00 UTC] --> B[inspect_iceberg_metadata: DuckDB S3 read_json_auto]
B --> C{Snapshots > Threshold?}
C -- Yes --> D[notify_slack_lakehouse: Slack Webhook]
C -- No --> E[log_lakehouse_nominal: Log]
D --> F[export_lakehouse_manifest: Execution Labels]
E --> F
metadata.json into multi-megabyte files that slow query planning in Trino, DuckDB, or Athena.CALL system.expire_snapshots().| Name | Type | Default | Description |
|---|---|---|---|
iceberg_table_metadata_path |
STRING | s3://lakehouse-data/tables/orders/metadata/v15.metadata.json |
S3 or cloud storage URI to the Apache Iceberg table metadata.json file. |
max_snapshot_count_warning |
INT | 50 |
Maximum permissible number of active table snapshots before alerting for snapshot expiration. |
slack_channel |
STRING | #lakehouse-alerts |
Slack channel destination for Iceberg metadata optimization alerts. |
{{ outputs.inspect_iceberg_metadata.vars.total_active_snapshots }}: Number of active snapshots in the Iceberg table metadata.{{ outputs.inspect_iceberg_metadata.vars.iceberg_format_version }}: Table format version (e.g. 1 or 2).{{ outputs.inspect_iceberg_metadata.vars.needs_optimization }}: Boolean flag indicating maintenance necessity.{{ outputs.inspect_iceberg_metadata.outputFiles['iceberg_metadata_report.json'] }}: Full JSON metadata diagnostics payload.AWS_ACCESS_KEY_ID: AWS IAM access key ID.AWS_SECRET_ACCESS_KEY: AWS IAM secret access key.SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.iceberg_table_metadata_path.s3_region in DuckDB matches the bucket region to prevent HTTP 301 Moved Permanently redirects.metadata.json via version numbering or Iceberg catalog pointers (e.g. Nessie, Polaris, AWS Glue).rewrite_data_files and rewrite_manifests tasks directly within Kestra.