New to Kestra?
Use blueprints to kickstart your first workflows.
Gate on OpenSearch error counts with Kestra. Count 5xx logs hourly, alert Discord and fail the run above a threshold, log an all-clear below it.
A digest tells you what happened yesterday; a gate stops the line now. This blueprint runs an hourly io.kestra.plugin.opensearch.Search with size: 0 counting documents with a 5xx status over the last hour, then branches with io.kestra.plugin.core.flow.If. Above the threshold, the flow posts the exact numbers to Discord and fails itself with io.kestra.plugin.core.execution.Fail, so the spike shows up as a red execution that downstream automation can react to. Below the threshold, it logs an all-clear and exits green.
count_recent_errors (io.kestra.plugin.opensearch.Search) filters the app-logs index to status between 500 and 599 with @timestamp newer than now-1h. With size: 0, only {{ outputs.count_recent_errors.total }} travels back.gate (io.kestra.plugin.core.flow.If) compares the total against the error_threshold input, which defaults to 50.alert_spike posts the count and threshold to Discord, then fail_execution (io.kestra.plugin.core.execution.Fail) turns the execution red on purpose.all_clear (io.kestra.plugin.core.log.Log) records the healthy count.errors block posts a Discord alert on any failure, covering both deliberate breaches and a broken search.Schedule trigger runs the gate at the top of every hour.Alerting rules inside a monitoring stack are opaque to the pipelines they protect. Declaring the gate as a flow makes the threshold an input you can override per run, the verdict an execution state other flows can subscribe to, and every check a logged, replayable execution. When the gate fires, the red run and the Discord message point at the same execution id.
status field and @timestamp, app-logs by default.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.status field to your log schema, and pick a realistic error_threshold default.disabled: false on the hourly trigger.If branch.term filter and run one gate per critical service.