Fail icon
FluxQuery icon
Log icon
If icon
Pause icon
Loop icon
Write icon
SlackIncomingWebhook icon
Schedule icon

Rebuild missing InfluxDB hourly rollups before raw expiry

Find missing InfluxDB hourly rollups, approve oldest-first repairs from retained raw data and verify means and sample counts after each write.

Categories
Data

Safety

A failed hourly downsampler can leave a dashboard gap that becomes permanent once raw retention expires. Recomputing from an already truncated source would replace that gap with a misleading aggregate. This flow repairs only settled windows whose entire scan interval remains inside retention, using the existing rollup convention: one host tag, numeric mean and integer samples fields at the UTC window start.

Guard What it stops
Exact host, measurement and field; restricted names; distinct buckets Writes to unrelated series or the raw bucket
Bucket ids and retention rechecked; Write uses the approved bucket ID Repairing a recreated bucket or aggregating a window that may have expired
One hour of retention margin and configurable settling delay Using retention-edge data or racing a normal recent aggregation
At most 168 hourly windows and 10,000 selected raw samples An unbounded historical rebuild
Unexpected tags, off-hour target points and conflicting completed aggregates fail Merging different series or overwriting unexplained rollups
Both mode switches, approval and confirmation that writers are stopped An unattended repair without acknowledged writer quiescence
Exact raw sample and target-field snapshot rechecked per window Applying an approval after source values or rollups changed
Point read after each write and final gap query Reporting success while a selected rollup remains incomplete

InfluxDB has no conditional point write. Stop the normal downsampler and late-arrival writes for this host before approving, then keep them stopped until the execution terminates. The flow queues its own executions; it does not lock another flow, administrator or InfluxDB task. A recheck narrows the race but cannot replace that operating procedure.

How it works

  1. bounds (io.kestra.plugin.influxdb.FluxQuery) fixes UTC hourly bounds and records both bucket identities. detect runs the aggregation and comparison in InfluxDB, returning missing or short windows in oldest-first order. A completed rollup must match both the source count and mean; a zero mean is valid.
  2. report lists each gap with its window timestamp, sample count and proposed mean. Default executions report and finish without changing data. The disabled Schedule forces these safe inputs.
  3. approval (io.kestra.plugin.core.flow.Pause) waits up to 20 minutes. approved_repair requires onResume.approved ?? false and writers_quiesced: true.
  4. repair_oldest_first (io.kestra.plugin.core.flow.Loop, concurrency limit 1) runs recheck_window immediately before write_rollup (io.kestra.plugin.influxdb.Write). It compares every raw timestamp/value plus the two target fields with the approved snapshot. Writes use the captured bucket ID, reuse the window timestamp and update only mean and samples.
  5. read_written_window checks the repaired point. verify_all_windows repeats the full gap query and require_continuity fails if any raw-backed window is incomplete. alert_failure posts to Slack on a failure, including permission refusal and stale approval.

What you get

  • Repaired hourly means and sample counts before their raw source expires.
  • Oldest gaps first, with a record of the approved windows and each write.
  • Retry from actual bucket state: completed windows are skipped and unrelated point fields survive.

Who it's for

Data platform operators maintaining an InfluxDB 2.x hourly mean/count rollup with shorter raw retention.

Why orchestrate this with Kestra

InfluxDB can aggregate and backfill its own data. Kestra coordinates the incident response: bounded discovery, human approval, stale-plan refusal, ordered plugin writes and a failed execution with an alert if recovery cannot be proved.

Tested end to end

Kestra 2.0.6, bundled InfluxDB plugin 1.5.7 and InfluxDB OSS 2.7.12. Validation returned no constraints, warnings, infos or deprecations. Independent influx query --raw reads bracketed the saved execution cases. The fixture used 72-hour raw retention and 30-day rollup retention, with two missing windows and one short rollup.

Approved repair changed incomplete windows from 3 to 0, complete windows from 2 to 5 and represented raw samples from 7 to 15. All 23 raw points were conserved. Other hosts, similarly named measurements, a legitimate zero mean, rollup annotations and windows at or after the settling cutoff were preserved. Interruption after the first write left two gaps; the next execution repaired those two. The fresh fixture repeated healthy, repair and stale-approval cases with read permissions on both buckets and write permission only on the rollup bucket. Slack used an HTTP test sink. Bucket recreation and a stopped server during approval failed before Write; the concurrent second execution queued. All 24 invalid identifier requests (quotes, Unicode, spaces and 65-character names across six inputs) were rejected before execution. Target-tag, negative/excess count, mean-tolerance and 168-window boundary cases also passed.

Case Execution Result
Healthy, including a zero mean 7l382QyB7w6vQpzMIKJMG7 SUCCESS
Missing and short, dry run 3YDLnANNYeW9C7bMXJw5Eq SUCCESS
Declined approval 6iO0kyBuyuCAsT9XvCHoKB SUCCESS
Approved repair 6w3WQwluNlXoxlrkmH4Jdy SUCCESS: 3 incomplete windows to 0
Repeat 2ClBBintYrDpVj0ypD94o8 SUCCESS
Write refused with HTTP 403 7kpldok0uwHsigUr6NEtZk FAILED as intended, no rollup write
Raw value changed during approval 44SMa1VySuzfKZrKB7bMvl FAILED as intended, no rollup write
Killed after first write 6vGBX8eAA89zPW3yKtW2XA KILLED: first write retained
Reconcile interrupted repair 2pxMLbi89yMLH76KiiU3cP SUCCESS: 2 incomplete windows to 0
Retention shortened during approval 7Jd2HpEHGzpJCgvDfOcRL9 FAILED as intended, no rollup write
Additional raw tag dimension 1kurF4nmghAvwlz8j52zOl FAILED as intended, no rollup write
Conflicting completed mean 6lPC4VQGMjt2RAdxeLuG9b FAILED as intended, no rollup write
Off-hour rollup timestamp 6SDbKBVFMgHrSl8XPtARyO FAILED as intended, no rollup write
Writers not confirmed stopped 1egjF7xCZmMm4dTpcbMH8s FAILED as intended, no rollup write
auto_remediate true, dry_run true 33JfD0rYowf5HRv2dd2YQg SUCCESS
auto_remediate false, dry_run false Jq4Gc9uebjYhAQRXVlqPZ SUCCESS
No matching raw series 3LaqeYa4pHcHyPMumxPCcx SUCCESS
Already completed window preserved 7IqmLAzjwWOsib1r1oCfMH SUCCESS
Exactly 10,000 selected raw samples 4jyuBRSKwWnEd4jxDUNZdL SUCCESS
10,001 selected raw samples 6X3XOnZ7hXbA9cwPzkStsn FAILED as intended, no rollup write
Raw and rollup bucket identical 13Fi7otqd5pkYqTP5tRcBh FAILED as intended, no rollup write
Bucket recreated during approval 3GV7nSBwDUkdHR2dNWONFe FAILED as intended, no rollup write
Second execution queued 1gr48XL1FDNx38mkfUBgjR SUCCESS
Rollup count exceeds source 58pPcDIYTlMegqlyWrkWIQ FAILED as intended, no rollup write
168 selected hourly windows 66rxV6omHU17e6fwrapvzu SUCCESS
Mean just inside tolerance 2cPYuMjEDBeDvaBAlEVE6P SUCCESS
Mean just outside tolerance 3sBka44O6nUTypDk2XdhkC FAILED as intended, no rollup write
Negative rollup count 1ZhPb9aFzRxD7RdYmMZLI3 FAILED as intended, no rollup write
Server stopped during approval 6oIt1pwOOvjDYiBBo5Rm7 FAILED as intended, no rollup write
Unavailable endpoint 2Xb8ehncaRa3OGPOYEM4vc FAILED as intended, no rollup write
Additional target tag dimension 7SBCMRgj6nshTfhLEYR6cY FAILED as intended, no rollup write
Fresh fixture: healthy, including a zero mean qbafmQbLMi80gwruAwB4v SUCCESS as expected
Fresh fixture: approved repair 76p41FznQIhftMhter4VjK SUCCESS as expected
Fresh fixture: raw value changed during approval AqTzOJzD6ax1O9ghNc2nb FAILED as expected

Prerequisites

  • Kestra 2.0.6 with the InfluxDB plugin and InfluxDB 2.x with Flux. Only OSS 2.7.12 was exercised.
  • A raw numeric field with exactly the host tag and a rollup measurement using the convention above. Extra rollup fields are preserved. This flow does not adapt an arbitrary downsampling schema.
  • Token permissions: read both named buckets, including bucket metadata; write the rollup bucket only. No raw write, delete, task-management or operator token is required.
  • Permission to stop the regular downsampler and late arrivals for the selected host while an approved repair runs.

Secrets

  • INFLUXDB_URL, INFLUXDB_ORG, INFLUXDB_TOKEN: server URL, organization and scoped token. The token input has type SECRET.
  • SLACK_WEBHOOK_URL: failure notification destination.

Inputs

Input Default Purpose
influxdb_url, influxdb_org, influxdb_token Corresponding secrets Connection and scoped credentials
raw_bucket, rollup_bucket raw, rollup Distinct source and destination buckets
measurement, raw_field cpu, usage Exact raw measurement and numeric field
rollup_measurement, host cpu_hourly, server-a Exact rollup measurement and host
lookback_hours 48 1 to 168 settled hourly windows
settling_hours 2 1 to 24 hours excluded before the current UTC hour
dry_run, auto_remediate true, false Writes require false and true respectively
slack_webhook_url SLACK_WEBHOOK_URL secret Failure alert endpoint

Names start with an ASCII letter and contain at most 64 letters, digits, underscores, dots or hyphens. Choose the lookback and settling delay comfortably inside both retention periods, allowing the extra hour of margin. For example, the defaults fit the tested 72-hour raw bucket. Queries have a 20-second read timeout and tasks a 30-second timeout; writes have no automatic retry.

Quick start

  1. Confirm that the downsampler writes a mean and sample count at each hourly window start. Add the four secrets and grant the bucket permissions above.
  2. Set the exact buckets, measurement, field and host. Run with the defaults and inspect report. Compare a proposed window with a direct Flux query before enabling repair.
  3. Stop the downsampler and late arrivals for this host. Execute with auto_remediate: true and dry_run: false.
  4. Review the proposed windows at the Pause. Resume with approved: true and writers_quiesced: true. A declined approval preserves the gaps.
  5. Confirm success and read the repaired points independently. Restore normal writers. After a failed or interrupted run, inspect retained data and run again; already complete windows are spared.
  6. Enable the hourly Schedule for reporting after manual validation. It always forces safe mode.

How to extend

  • Add a threshold path with io.kestra.plugin.influxdb.FluxTrigger polling an independently configured gap query. Configure connection, organization and query at trigger level; polling triggers have no execution inputs. Keep the flow's discovery and approval rechecks. This path was schema-checked but not executed.
  • Support another aggregate only by changing detection, payload and verification together, then testing the exact convention used by the regular downsampler.

Limits: recovery covers windows still represented in retained raw data. It cannot identify a completely expired or entirely absent raw window, prove that upstream ingestion was complete or recreate the full dashboard. It assumes writers remain quiescent during repair. Mean comparisons use a relative tolerance of 1e-9 * (1 + abs(expected)). InfluxDB 3, multiple tag dimensions, other window sizes and the polling-trigger extension were not tested. Snapshot values appear in execution outputs; restrict access to execution history.

Links

This blueprint was created by zkasuran.

See How

New to Kestra?

Use blueprints to kickstart your first workflows.