Schedule icon
Query icon
DiscordIncomingWebhook icon

Snapshot Prometheus Query Results to Internal Storage

Snapshot a PromQL result set from Prometheus into Kestra internal storage for audits and offline analysis, with a Discord note on the series count.

Categories
DataInfrastructure

Prometheus data expires; audit questions do not. This blueprint captures a PromQL result set as a durable file before retention erases it. Each night, io.kestra.plugin.prometheus.Query evaluates avg_over_time(up[24h]), the daily availability of every scrape target, with fetchType: STORE. Instead of flowing through task outputs, the full result set lands as a file in Kestra's internal storage, attached to the execution and addressable by URI for downstream processing. A Discord note confirms the capture and reports the series count.

How it works

  1. snapshot_availability (io.kestra.plugin.prometheus.Query, fetchType: STORE) runs the PromQL expression and writes the complete result set to internal storage. The file is exposed as {{ outputs.snapshot_availability.uri }} and the series count as {{ outputs.snapshot_availability.size }}.
  2. notify posts the series count to Discord, keeping only scalars in the JSON payload.
  3. The errors block posts a distinct Discord alert on failure, because a silent gap defeats the point of an audit record.
  4. A disabled-by-default Schedule trigger captures the snapshot nightly at 01:00.

What you get

  • A dated, immutable record of per-target availability that survives Prometheus retention limits.
  • The result set as a file URI, ready to feed warehouse loads, object storage uploads, or scripts.
  • STORE semantics that handle large result sets without bloating execution context, unlike FETCH.
  • A capture log in the execution history, with an alert whenever a day is missed.

Who it's for

  • Platform teams answering uptime questions months after the metrics expired.
  • Compliance and audit stakeholders who need availability evidence on file.
  • Data teams moving metric extracts into a warehouse for long-term analysis.

Why orchestrate this with Kestra

Scripting this means a cron job, an HTTP call, a file naming convention, somewhere durable to put the file, and a notification when it breaks. Kestra collapses all of it, the query task streams the result to managed internal storage, the URI flows to any downstream task, the schedule and the failure alert live in the same YAML, and every capture is traceable to an execution.

Prerequisites

  • A Prometheus server reachable from your Kestra instance.
  • A Discord incoming webhook for the confirmation and failure notes.
  • The Query task supports HTTP basic auth through its username and password properties if Prometheus sits behind one.

Secrets

  • PROMETHEUS_URL: base URL of the Prometheus server, e.g. http://prometheus:9090.
  • DISCORD_WEBHOOK_URL: Discord incoming webhook URL.

Quick start

  1. Add the PROMETHEUS_URL and DISCORD_WEBHOOK_URL secrets to your Kestra namespace.
  2. Execute the flow and download the stored file from the execution's Outputs tab to inspect the captured series.
  3. Swap the PromQL for the result set you need to keep, then set disabled: false on the daily trigger.

How to extend

  • Load the stored file into a warehouse with a downstream task, feeding it {{ outputs.snapshot_availability.uri }}.
  • Ship snapshots to object storage, such as S3 or GCS, for retention independent of Kestra.
  • Use the time property to snapshot the metric state at a fixed timestamp, for example midnight, for consistent daily records.
  • Capture several expressions per night by adding more Query tasks, one file each.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.