Repair stale Pushgateway labels for a live Kestra batch job
Reconcile stale Pushgateway labels with Kestra execution history then rewrite the batch metrics behind approval.
Run an instant LogQL query against Loki, alert Slack on an error rate threshold breach, and log the result for SRE teams.
Loki computes a log-derived metric, like an error rate, the moment you ask for it; it does not keep a schedule, compare that number against a threshold you declare, or notify anyone when the rate crosses it. This blueprint evaluates the metric right now, as an instant query, and treats the real returned value as the governance signal, not a count estimated after scanning a window of raw log lines.
This blueprint was created by Mohit Jeswani.
query_error_rate (io.kestra.plugin.grafana.loki.Query) calls Loki's
/loki/api/v1/query instant-query endpoint with logql_query, evaluated at the current
time. Read-only; nothing in Loki is changed. allowFailure: true covers an unreachable
Loki instance or an invalid query without failing the flow outright.evaluate (io.kestra.plugin.core.output.OutputValues) reads the instant metric's own
numeric value with a jq filter; an empty result set (no matching series right now) is
treated as a rate of 0, not a probe failure.route (io.kestra.plugin.core.flow.If):summary logs the rate and severity, closing the governance cycle.errors alerts Slack if the flow itself fails, for example a Loki auth error.CRITICAL vs. ERROR_RATE_BREACH) so you know which one happened without reading logs.loki.Query used for an
instant metric threshold gate, distinct from this repo's existing Loki blueprints, which
all use QueryRange (range queries over a historical window) or the realtime Trigger
rather than an instant point-in-time metric evaluation.Loki answers one instant query at a time; it does not decide what threshold counts as a
breach, compare the real-time result against it, or notify a Slack channel when it
crosses. Kestra keeps logql_query and max_error_rate as flow inputs, turns the
evaluation into a Slack page naming the exact rate found, and keeps a full execution
history of every check.
grafana/loki Docker image,
receiving logs that logql_query can aggregate.LOKI_AUTH_TOKEN: the bearer token used by query_error_rate for a secured Loki
deployment. In Kestra OSS, provide it as the base64-encoded environment variable
SECRET_LOKI_AUTH_TOKEN. Leave unset for a local, unsecured Loki instance.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 |
|---|---|---|
logql_query |
sum(rate({job="api"} |= "error" [5m])) |
Instant LogQL metric expression to evaluate |
max_error_rate |
1.0 |
Value at or above which the alert fires |
{{ outputs.query_error_rate.logs }} / .resultType: the raw instant-query result
(timestamp, value, labels per series) and Loki's own result type (vector,
matrix, or streams).{{ outputs.evaluate.values.current_rate }} / .severity: the real numeric value found,
and OK, ERROR_RATE_BREACH, or CRITICAL.@Example Javadoc for
loki.Query shows a token property, but the actual field on AbstractLokiConnection is
authToken. This blueprint uses the verified real name, authToken.logql_query must be a metric expression (rate(...), count_over_time(...), etc.), not
a bare log-selector; a bare selector returns raw log lines (resultType: streams)
instead of a single numeric value, and this check's jq filter expects a number.0
here; if the underlying stream itself disappearing is also worth alerting on, pair this
gate with a separate check on log volume, not just rate.docker run -p 3100:3100 grafana/loki:latest) and add the
SLACK_WEBHOOK_URL secret (and LOKI_AUTH_TOKEN only if your instance is secured).logql_query to a real metric expression matching your log streams.summary logs the current rate.max_error_rate below the real current rate to confirm alert fires.every_5_minutes trigger once the threshold matches your real SLO.logql_query values with io.kestra.plugin.core.flow.Loop to monitor
more than one service's error rate in a single scheduled run.io.kestra.plugin.grafana.loki.QueryRange in the alert branch to pull the raw
matching log lines for the breach window, for richer context than the single rate value.