API Evolution Watchtower
Monitor third-party OpenAPI specifications for consumer-impacting contract changes and govern accepted revisions with persistent PASS/WARN/BLOCK decisions.
Run an ES|QL error count query against Elasticsearch, alert Slack on a threshold breach, and log the result for platform teams.
An application logging errors to Elasticsearch can spike in volume with nobody watching
until a customer complains; Elasticsearch itself shows the count if someone opens Discover,
it does not keep a schedule, compare the count against a threshold you declare, or notify
anyone. This blueprint runs the aggregation server-side with ES|QL's own STATS COUNT(*)
and reports the real number, not a client-side guess.
This blueprint was created by Mohit Jeswani.
query_error_count (io.kestra.plugin.elasticsearch.Esql) runs an ES|QL pipe query
that filters to ERROR-level documents since lookback_minutes ago and aggregates them
with STATS error_count = COUNT(*), using a dynamic ? parameter rather than string
concatenation. Read-only; nothing in Elasticsearch is changed. allowFailure: true
covers a connection or syntax error without failing the flow outright.evaluate (io.kestra.plugin.core.output.OutputValues) reads the real aggregated
error_count directly from the ES|QL response's own row, keyed by the STATS alias.route (io.kestra.plugin.core.flow.If):summary logs the count and severity, closing the governance cycle.errors alerts Slack if the flow itself fails, for example an unreachable cluster.CRITICAL vs. ERROR_COUNT_BREACH) so you know which one happened without reading logs.Esql used as a
standing threshold gate with dynamic query parameters, the first blueprint in this repo
to exercise ES|QL rather than the classic Search/Request DSL-based tasks.Elasticsearch answers one ES|QL query at a time; it does not decide what threshold counts
as a breach, compare the real-time count against it, or notify a Slack channel when it
crosses. Kestra keeps lookback_minutes and max_error_count as flow inputs, turns the
aggregation into a Slack page naming the real count, and keeps a full execution history of
every check.
elasticsearch Docker image,
with an index named logs containing a level keyword field and a @timestamp date
field (or adjust the query to match your real mapping).SLACK_WEBHOOK_URL: used by alert and the errors block. In Kestra OSS, provide it as
the base64-encoded environment variable SECRET_SLACK_WEBHOOK_URL.| Input | Default | Purpose |
|---|---|---|
lookback_minutes |
15 |
How far back from now to count errors |
max_error_count |
10 |
Error count at or above which the alert fires |
{{ outputs.query_error_count.row }} / .size / .total: the single aggregated row and
row counts, as Esql reports them with fetchType: FETCH_ONE.{{ outputs.evaluate.values.error_count }} / .severity: the real error count, and
OK, ERROR_COUNT_BREACH, or CRITICAL.interpolateParams implementation); this is safe for a date filter here, but is not the
same security guarantee as a true server-side bind variable for untrusted input.logs, level, @timestamp) are hardcoded on
the task; adjust them to match your real index mapping before relying on this gate.fetchType: FETCH_ONE assumes the query returns exactly one aggregated row; a query
changed to group by an extra dimension (for example BY service) would need FETCH
instead and a different evaluate step to sum across rows.docker run -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.15.0) and add the SLACK_WEBHOOK_URL secret.query_error_count's query to match your real index, level field, and
timestamp field.summary logs the real count.max_error_count below the real current count to confirm alert fires.every_5_minutes trigger once the threshold matches your real SLO.BY service grouping to the STATS clause and switch fetchType to FETCH to
alert per-service instead of on one cluster-wide total.io.kestra.plugin.elasticsearch.Search in the alert branch to pull a sample of the
actual error documents for richer Slack context beyond the bare count.async: true on query_error_count for a query against a much larger lookback
window that would otherwise risk timing out on the synchronous endpoint.