New to Kestra?
Use blueprints to kickstart your first workflows.
Export audit-tagged log lines from Grafana Loki weekly with Kestra. Authenticated queries, an execution-attached record, and Discord confirmations.
Compliance reviews ask a simple question, show us the audit events for that week, and Loki's retention window does not wait for the auditor. This blueprint captures the trail on a schedule: every Monday, io.kestra.plugin.grafana.loki.QueryRange fetches all lines matching {app="api", env="production"} |= "AUDIT" from the last 168 hours through an authenticated connection, keeps them as task outputs on the execution, and confirms the capture in Discord with the line count.
export_audit_logs (io.kestra.plugin.grafana.loki.QueryRange) runs the LogQL query with since: 168h, exactly one week back from execution time.authToken from {{ secret('LOKI_AUTH_TOKEN') }}; for multi-tenant Loki, add tenantId to scope the query to one tenant via the X-Scope-OrgID header.{{ outputs.export_audit_logs.logs }} and remain attached to the execution, a timestamped, immutable record of what the query returned that week.confirm_export posts the scalar line count to Discord; the errors block posts a distinct alert on failure, because a silently missing week defeats the purpose of the trail.Schedule trigger runs the export every Monday at 06:00.An export that matters is an export that provably ran. Kestra gives the query a schedule, retries against transient Loki failures, a permanent execution record holding the captured lines, and an alert the moment a week fails to capture. The whole control loop is a few lines of YAML with the credentials in secrets.
limit: 5000 cap: for high-volume audit streams, raise limit so the capture covers the full week rather than truncating.LOKI_URL: Loki base URL, e.g. https://loki.example.com.LOKI_AUTH_TOKEN: bearer token for the Loki API.DISCORD_WEBHOOK_URL: Discord incoming webhook URL.LOKI_URL, LOKI_AUTH_TOKEN, and DISCORD_WEBHOOK_URL secrets to your Kestra namespace.disabled: false on the weekly trigger.tenantId next to authToken to export one tenant at a time in a multi-tenant setup.since: 24h and a daily cron to stay well under the fetch limit.