New to Kestra?
Use blueprints to kickstart your first workflows.
Enforce OpenSearch log retention with Kestra. A weekly DELETE request removes the thirty-day-old dated index and posts a Discord confirmation.
Dated log indexes grow forever unless something deletes them on schedule. This blueprint enforces a thirty-day retention policy with io.kestra.plugin.opensearch.Request, the plugin's raw REST escape hatch: a DELETE call targets app-logs-yyyy.MM.dd where the date is computed by Pebble as thirty days before the run. Discord receives a confirmation naming the exact index and the HTTP status, so the retention trail is written where the team already reads.
delete_expired_index (io.kestra.plugin.opensearch.Request) sends DELETE to the endpoint app-logs-{{ (trigger.date ?? execution.startDate) | dateAdd(-30, 'DAYS') | date('yyyy.MM.dd') }}. Using trigger.date ?? execution.startDate means scheduled runs and manual backfills both compute the correct day.{{ outputs.delete_expired_index.status }} and the body as {{ outputs.delete_expired_index.response }}.confirm posts the deleted index name and the status code to Discord.errors block posts a distinct Discord alert when the delete fails, for example on a missing index or a permissions problem.Schedule trigger enforces the policy every Monday at 03:00.Request pattern for any OpenSearch admin API that has no dedicated task, aliases, settings, snapshots.Deleting data is the one job that must be observable. Every run of this flow records which index it targeted, what the cluster answered, and who was told, all in the execution history. Backfills recompute the date correctly, failures alert a human, and changing the retention window is a one-line diff in version control instead of an edit inside a forgotten crontab.
app-logs-yyyy.MM.dd, or adjust the endpoint pattern to your naming scheme.OPENSEARCH_HOST: OpenSearch endpoint, for example https://opensearch.example.com:9200.OPENSEARCH_USERNAME: OpenSearch username.OPENSEARCH_PASSWORD: OpenSearch password.DISCORD_WEBHOOK_URL: Discord incoming webhook URL.disabled: false on the weekly trigger.io.kestra.plugin.core.flow.ForEach so one weekly run clears the whole expired range.Request call to the snapshot API.