Backfilling historical data into Prometheus

Backfilling brings past metrics into Prometheus after a migration, using promtool and OpenMetrics input, but only some history is worth importing. This page explains what maps, what does not, and how the work is sequenced.

On this page

Backfilling historical data into Prometheus after a migration

Backfilling answers one question for a team leaving Nagios, Zabbix, Graphite, StatsD, collectd or InfluxDB: can old history appear beside new Prometheus data in dashboards and alert comparisons? Yes, if the history can be expressed as OpenMetrics input and written as Prometheus blocks with promtool tsdb create-blocks-from openmetrics. The import is a one-time operation that creates TSDB blocks from files you prepare. It is not live ingestion, so it does not replace the scrape pipeline or the old system during cutover. The effort depends on how many series, how many days of history, and how many recording rules need the imported data to produce their own results. Confirm the exact promtool subcommands and flags against the version you will run, because they change between releases.

Plan the import against retention before you run it. The Prometheus storage documentation describes local storage as a single-node database that is not clustered or replicated, so the imported blocks live on one disk that you must back up and size yourself. Default retention is 15 days, configured by --storage.tsdb.retention.time or --storage.tsdb.retention.size. If you import a year of history into a server that keeps 15 days, the older blocks are removed by retention, so set retention deliberately before the import. Also check that the imported blocks do not overlap existing blocks in a way that causes conflicts, and that the head block, which holds the most recent data, is not used as a source for historical imports. Ask whoever runs your Prometheus server to confirm the disk capacity and retention settings in writing before work starts.

Which source history maps cleanly to Prometheus blocks

This table compares common source history types against the Prometheus series, metric type and label decisions they require before conversion. Read each row as a question to answer from the actual export, not a guarantee that the data will carry over. The main takeaway is that numeric counters and gauges map most directly, while check states, aggregates and tagged fields need explicit decisions before any block is created.

Source historyTypical Prometheus mappingWhat is lost or reshapedConfirm before converting
Numeric time series with timestampsGauge or counter series with the original metric name, labels from source tagsLittle is lost if timestamps and units are preserved in the exportUnits, timestamp precision and whether values are cumulative
Cumulative countersCounter series, so rate() and increase() work after backfillCounter resets in the source must be visible in the samples or the rates will misleadWhether resets occurred and where they fall in the history
Gauges such as memory or queue depthGauge series with one sample per source timestampSampling interval may differ from the scrape interval used todayOriginal sampling interval and any gaps in the export
Aggregated graphs (Graphite rollups, StatsD timers)Often a gauge per aggregate, such as a mean or percentile, rather than raw samplesRaw observations are gone, so histograms cannot be rebuilt and percentiles cannot be recomputedWhich aggregate functions and retention rollups produced each series
Check results and event state (Nagios, Zabbix triggers)Usually a 0 or 1 gauge per check, or no series at all if only events were storedStatus text, messages and event durations often lack a numeric series and need a converted proxyWhether the export holds numeric values or only state changes
Tagged line protocol series (InfluxDB)One series per field, with tags mapped to labels and field type chosen per metricMultiple fields per point split into separate series, and string fields do not map to numeric valuesField types, tag cardinality and any timestamp precision changes
Dotted metric names (Graphite)Metric name and labels derived from name segments through a documented mapping ruleAmbiguous segments can produce inconsistent labels, and high-cardinality segments can explode series countThe mapping rules applied to each dotted name pattern

Documented tools and export paths for historical data

Prometheus offers a few documented ways to bring historical samples into a server, and each one starts from a different source format. The choice depends on where your history lives today, how far back it goes, and whether it should land in local blocks or in an external long-term store. Confirm flags and limits in the promtool and Prometheus documentation for the exact version you run.

Promtool backfilling into local blocks

The promtool tsdb create-blocks-from openmetrics command converts an OpenMetrics text file into TSDB blocks that a Prometheus server can read after they are placed in its data directory. This is the path for loading a bounded history set once, such as a window of exported samples from the old system. Check how the server handles overlapping blocks, how retention applies to backfilled data, and whether the server must be stopped before the blocks are added. Confirm the exact subcommand and flags in the promtool documentation for your version.

Default block span
2 hours
Storage docs

OpenMetrics text as the input

Promtool reads OpenMetrics text, not the native format of the source system. Your team must write a converter that turns each exported sample into a metric name, a label set, a float value and a timestamp in that layout. Decide early how old metric names and tags map to Prometheus names and labels, and validate a small sample file with promtool before you convert the full export. Mismatched types or unsorted timestamps are common reasons a conversion fails or produces misleading series.

Source system export and query APIs

The origin of the history is the source system's own export or query interface, such as a time-series API, a CSV dump or a database table. Inventory which series exist, how far back each goes, and what sampling interval was used, because gaps and resolution changes will show up in backfilled data. Ask the platform owner how exports are paginated and whether they are complete, since a partial export produces a partial history that looks valid. Keep the export query and the converter in version control so the process can be rerun.

Remote write to external storage

Remote write sends samples from Prometheus to an external long-term store, and remote read queries that store back. This suits history that must outlive the local disk or be queried across several servers, and it avoids hand-building blocks. The store, not the local server, then becomes the system of record for those samples, so retention, replication and access control must be designed there. Confirm the protocol version and the store's ingestion limits before sending bulk historical data through the same path as live traffic.

Storage docs

Choosing between blocks and remote storage

Local blocks keep history on the same single-node database that serves live queries, which is simple but bounded by that server's disk and retention settings. Remote storage separates history from the scraping server and supports longer windows, but adds a second system to operate. Local storage is not clustered or replicated, so any backfilled blocks need the same backup and recovery plan as live data. Document which decision you made and why, since auditors and the next operator will ask.

How exported history becomes queryable Prometheus blocks

The flow starts with the source export from the legacy system, which the team converts to OpenMetrics text using its own label mapping. The promtool tool then builds blocks in a staging directory, where the team validates the time ranges before anything touches a live server. A decision point follows: place the blocks into the Prometheus data directory for local retention, or send them to a long-term store. Queries and recording rule checks confirm the result, and the 3-hour head block limit and overlapping blocks are what to check at each hand-off.

Flow from legacy export to queryable blocks, with the local or remote storage decision.

How the head block and overlapping blocks affect imported history

Backfilled history must land in time ranges that the running server is not writing to. Prometheus keeps recent samples in the head block, protects them with a write-ahead log, and cuts them into two-hour blocks on disk. The head block is the live window, so an imported block whose time range reaches into it will compete with samples the server is appending right now. Set your cutover timestamp, the point where live scraping took over from the old system, and generate history that ends before the head's window begins. Treat the 3-hour head block limit named for this topic as a figure to confirm against the Prometheus version you run, because the exact window behavior determines where your cutover timestamp can sit.

Overlapping blocks are the failure mode to design against. When two blocks hold samples for the same series over the same period, queries can return duplicated or conflicting points, rate and increase calculations near the seam can be distorted, and compaction has to merge the blocks before the data is clean. Decide where backfill output goes before generating anything. A staging Prometheus with its own data directory, queried alongside production through federation or a remote read path, is easier to back out than writing blocks straight into the production directory. Ask whoever operates your Prometheus version which compaction messages and query effects to expect when a block overlaps.

Test overlap behavior on a copy of the data directory before touching production. Take the copy from a stopped server or a consistent filesystem snapshot, since the Prometheus storage documentation says local storage is not clustered or replicated and should be handled like any other single-node database. Run the import against the copy, start a separate Prometheus process pointed at it, and check the seam. Compare sample counts for a known series on each side of the cutover timestamp, look for duplicate series in a query, and watch the logs through the first compaction cycle. Record disk use before and after, and keep the copy until queries across the seam match what you expected. Only then schedule the change on production, in a window where you can restore the original directory.

Backfill sequence from inventory to decommissioning

This sequence moves history from a legacy system into Prometheus in verified stages, so the imported data can be trusted by dashboards, alerts and the people who rely on them. Each phase ends with a check that the team can review before moving on.

  1. Inventory the history you actually need

    The platform owner and the teams that use dashboards and alerts list each metric family, the questions it answers (incident review, capacity trends, compliance evidence, SLO baselines) and the time range each question needs. Most teams find that only a small set of series justifies backfilling, and the rest can stay in the archive. The step closes with a signed-off inventory that lists every metric, its purpose, its required range and its owner.

  2. Export and map source data

    Engineers export the chosen series from the source system and map source names, tags and units onto Prometheus metric names and labels. Mapping rules are written down once and reused, so the same transformation applies to every export. Confirm the export format and tooling against the exact version of the source system, since export options change between releases. The step closes when a sample of each mapped series can be traced back to its original value.

  3. Convert to OpenMetrics and create staging blocks

    Engineers convert the mapped data to the OpenMetrics text format and use promtool's backfilling feature to create TSDB blocks in a staging directory, not in a live server. Samples that feed recording rules are backfilled as well, so the rule output exists for the imported range. Check the promtool version against the Prometheus version that will read the blocks. The step closes when promtool completes without errors and the block directories are present in staging.

  4. Validate counts, ranges and rule output

    Before any block reaches a live server, the team compares series counts, first and last timestamps and sample totals against the source export for every metric family. They also run the recording rules over the imported range and compare their output with values computed from the source. Any mismatch goes back to the mapping step, since fixing it at this point is far cheaper than cleaning up a live database. The step closes with a written validation record that the platform owner accepts.

  5. Load the blocks into a test Prometheus

    Engineers copy the validated blocks into a test Prometheus instance that matches the production configuration as closely as possible, including retention settings and storage path. They then query the imported range with the same PromQL used by production dashboards and alerts. Watch for the three-hour head block limit and overlapping blocks, which can cause gaps or errors if blocks are not created and placed correctly. The step closes when the dashboards load the imported history without gaps and the test results match the validation record.

  6. Run the imported history in parallel

    The test instance, or the production instance once the import is accepted, runs alongside the old monitoring system for a period agreed by the owners. During this period, dashboards from the old system and from Prometheus are compared for the same live window, and alert firing is reviewed so differences are understood before anyone relies on them. The team records every discrepancy with its cause and fix. The step closes when the owners agree that differences are explained and the live data matches.

  7. Cut dashboards and alerts over

    Dashboards and alert rules move to Prometheus one group at a time, with the owning team signing off each group and the old copies kept in version control until the cutover is complete. Alertmanager routing is confirmed so that the right people receive each notification. The step closes when every in-scope dashboard and alert is served by Prometheus and the owners have confirmed that nothing essential depends on the old system.

  8. Archive the export and decommission the source

    The original exports, mapping rules, promtool commands, validation records and the signed-off inventory are stored in a controlled archive so the migration can be audited or repeated later. Only then is the source system switched off, following its own retirement steps and any retention obligations the organization has. Confirm archive requirements with your compliance and records owners before deleting anything. The step closes when the archive is verified and the source is removed from the monitoring estate.

What drives the effort and cost of a backfill

This table lists the factors that change how much work a historical backfill into Prometheus takes, which direction each one pushes cost, and what to ask for in a written scope. Read it before requesting a quote, because the same amount of history can cost very different amounts of effort depending on the export quality and the number of dependent rules.

DriverWhy it changes effortWhat to ask for in a written scope
Volume and time span of historyMore days or months of samples means more conversion, more blocks to create and longer validation runs. Cost rises with the span, not with the number of dashboards.State the start and end dates, the expected sample volume per day, and which time ranges are in scope versus discarded.
Number of distinct seriesEach unique label set becomes a separate series in the generated blocks. Large series counts increase conversion time, memory use and the disk footprint of the output.Ask for an estimated series count from the source system and a plan to drop unused series before import.
Label cardinalityHigh-cardinality labels such as user IDs or request paths multiply series and can make imported data unusable for queries. Reducing labels usually means redesigning the mapping, which adds effort.Request a label mapping document that lists each source field, its target label and any labels that will be dropped or aggregated.
Quality and consistency of the source exportMissing timestamps, mixed units, duplicate points and inconsistent metric names need cleaning before conversion. Poor exports are the most common source of unplanned work.Ask who produces the export, what format it uses, and whether the provider will fix known gaps or only document them.
Recording rules and dashboards that depend on imported dataEach recording rule or dashboard that reads history must be checked against the imported blocks. Rules that depend on exact historical names or units add rework.List every recording rule, alert rule and dashboard that should show history, and state which must match old values exactly.
Storage placement: local blocks versus long-term storeLocal blocks sit in the Prometheus data directory, which is single-node storage. Sending history to a long-term store adds a separate ingestion path and its own configuration and testing.Confirm the target storage, its retention settings and whether the backfill must also pass through remote write.
Validation depthSpot checks against the source are quick. Full comparison of queries, rule outputs and dashboard values across the imported range takes much more time and may find problems that need a second pass.Specify the queries to compare, the acceptable tolerance for differences, and who signs off on the results.
Number of source systemsEach source system has its own export format, naming scheme and time handling. Merging several sources into one consistent history multiplies mapping and testing work.Ask for a per-source inventory with export method, owner and known differences in naming or time zones.

Which history to import based on what it must support

Trend dashboards need enough history to show seasonality and to let people compare this month with the same period last year, but they rarely need every raw sample. Most dashboards query at coarse resolution over long ranges, so the history that matters is the series those panels use, at the resolution they query. Confirm which dashboards the business relies on before choosing a window, because a wide import of unused metrics adds work without adding value.

  • Dashboard inventory: List every panel that will move, and note the metric names, label sets and time ranges each one queries.
  • Recording rule outputs: Where panels use expensive aggregations, import the recorded series so the dashboards keep their current response times.
  • Raw series for drill-down: Keep raw samples only for metrics that engineers open during incident review.
  • Archived export for the rest: Leave low-use metrics in the archived export and link to it from the migration runbook.
  • Label continuity: Check that label names match the old system's naming, since a renamed label splits one panel into two series.

Before you start, confirm with the dashboard owners which panels must render unchanged on cutover day.

What usually goes wrong with historical imports and how to prevent it

Historical imports fail in predictable ways, and most of the damage shows up later in dashboards and alerts rather than during the load. The cards below pair each risk with a check to run before, during and after the backfill, so the imported history supports the same decisions as the live data. The Prometheus docs describe reliability over precision as the project's design priority, so validating the import is the team's job.

Label mapping splits series

If the converted export uses different label names or values than live scrapes, one logical metric becomes several series. A counter exported with a host label while live targets use instance will not join with current data, and PromQL queries that span the boundary will show gaps or double counts. Before converting, write down the label set each live job produces and map every exported field to it. After the import, run a query that counts series per metric name for the old and new ranges and confirm that the totals line up with the expected number of hosts and jobs.

Timestamp and timezone errors

Exports often record times in local time, in seconds instead of milliseconds, or with a source-system offset that the converter drops. The result is history that appears hours or days away from where it belongs, or that overlaps the first live samples. Confirm the source timezone and time unit with the system owner, convert a few known events by hand, and check that a known outage or deploy appears at the correct timestamp in Prometheus. Keep one timezone across the converter, the Prometheus host and the dashboards.

Overlapping blocks corrupt results

Backfilled blocks that overlap each other or existing data in time can produce duplicate or inconsistent samples for the same series. The storage docs describe a local time series database organized into two-hour blocks, so an import that writes blocks for the same range from two runs is a common cause. Plan each import as one run with a defined time window, avoid repeating a window without deleting the earlier blocks first, and verify that the block time ranges listed on disk do not overlap before the server starts.

Block duration
2 hours

Imported history mixed with live series

Once history and live data share metric names and labels, a dashboard that looks continuous may actually combine two sources with different scrape intervals, units or definitions. A rate computed across the cutover can jump, and an alert written for live data may fire on imported history if the rule evaluates old ranges. Decide whether the backfilled period should carry a distinct label such as a migration source, document the cutover timestamp, and test each dashboard and alert rule against a range that crosses it.

Storage exhaustion from unplanned retention

Backfilled history does not respect the retention you think it does. Default local retention is 15 days, configurable by time or size, so older blocks may be removed quickly, or a large import may consume the disk and push out recent data. Calculate the size of the converted export before the run, set retention explicitly with the flags your deployment uses, and confirm free space on the Prometheus volume. Ask whether long-term history belongs in an external store through remote write instead of local disk.

Assuming imported accuracy matches the source

Prometheus values reliability over precision and is not a good choice where 100% accuracy is required, such as per-request billing. Imported values can also differ from the source because of rounding, resampling, counter resets or missing intervals in the export. Compare a sample of imported values against the original system for the same timestamps, document the known differences, and do not use the backfilled history as the sole evidence for billing, legal or audit decisions unless the source system remains the record.

Questions teams ask before backfilling Prometheus

How much does a Prometheus backfill cost?

The Prometheus software itself is licensed under Apache-2.0 with no paid edition, so the cost of a backfill comes from people, infrastructure and the work to convert history. The main cost components are the engineering time to export and map old data, the time to build and validate blocks, the extra disk and compute for the import, and the people who review dashboards and alert rules afterward. Most of this is one-time work, while storage for retained history recurs. Costs rise with the number of metric families, the volume of history, the number of rules that must be reproduced and the number of systems feeding the old store. When you request a quote, ask for the scope of sources, the mapping rules to be written, the validation steps and who owns the cutover decision.

How long does a backfill take?

Duration depends on scope rather than on a single number, so ask for a plan built from your own inventory before committing to dates. The biggest drivers are how many sources you have, how much history you keep, how clean the export format is and how many recording rules need historical blocks. Converting exports into OpenMetrics text and checking label consistency often takes longer than the import itself. Confirm with your team which dashboards and alerts must work on day one, because that list sets the minimum scope. A fixed-scope agreement in writing lets you compare timelines on the same deliverables.

What must our team provide before a backfill starts?

A backfill needs three things from your side: the historical exports, the rules that map old names and labels to Prometheus metrics, and named owners who can sign off on dashboards and alerts. Exports must be available in a readable form for the period you want to keep, and you should confirm how far back the source data goes. Mapping rules describe how old tags or dotted names become labels, including units and counter behavior. Owners confirm that a recreated panel or rule means the same thing as the original. Without these inputs, the import may finish but the history will not be trustworthy for comparison.

Can our in-house team run the backfill?

Yes, if the team has someone comfortable with Prometheus storage, the source system's export formats and the naming conventions used in both systems. The Prometheus storage documentation treats local storage as a single-node database, so the people running the import should understand block handling and disk capacity. Ask yourself whether the team can test conversions, validate results against the old system and keep working on the live estate at the same time. If any of those are doubtful, a partner can take on part of the work. Either way, agree in advance who owns validation.

Can history be loaded into a running Prometheus server?

Historical data is normally imported into blocks offline with promtool, and those blocks are then placed in the storage directory of a server. The live head block covers only recent samples and is limited to about three hours of data, so older samples cannot simply be written into it. Confirm with your engineers the exact procedure for your Prometheus version and whether a restart or a pause in scraping is needed. Overlapping blocks can cause problems, so check the blocks before they go into service. Plan a test on a copy of the server first.

What happens to alerts during the import?

Alerts can fire incorrectly during an import if recording rules or alert rules evaluate against partially loaded history or against a server that has just restarted. Before the import, decide which alerts stay active, which are silenced and which are paused for the window. Alertmanager silences and routing let you suppress notifications while you validate, but silences must be removed afterward so real problems still reach on-call staff. Confirm the sequence with your alerting owners and document it as part of the change record. Watch for duplicate notifications if old and new monitoring run side by side.

Does the Apache-2.0 license affect our tooling costs?

The Apache-2.0 license means there is no license fee for Prometheus itself, so tooling costs come from the infrastructure, the converters and scripts you build or adopt, and the people who maintain them. Check the license of each tool you use for conversion or validation, because other components may carry different terms. Ask whether any helper tools will be kept after the migration, since maintaining them becomes a recurring cost. Review the license terms of any third-party tooling with your legal or procurement team before adopting it.

How DeployOpen works on this

DeployOpen plans and delivers Prometheus backfills as fixed-scope work inside your own infrastructure. We start from the history you need to keep, the export format you have, and the recording rules and dashboards that depend on that history, then build and verify the blocks before anything reaches production.

How we scope

  • Inventory which metrics, time ranges and sources the backfill must cover, and which can stay in the old system.
  • Confirm the export formats, sample resolution and label mapping for each source before any conversion starts.
  • Agree in writing the deliverables, verification checks, and who owns the target Prometheus server and its retention settings.

How we build

  • Convert exports to OpenMetrics text and generate blocks with promtool, keeping time ranges aligned to the server's block layout.
  • Account for the 3-hour head block limit by splitting input so each generation step stays within the supported window.
  • Test overlapping block handling on a copy of the data and compare query results against the source system before cutover.

How we hand over

  • Document the conversion scripts, promtool commands, block directories and the order in which blocks were loaded.
  • Record the verification results, including sample counts and the queries used to compare old and new history.
  • Walk your operators through how to recognize and remove bad or overlapping blocks if a later load needs correcting.

How we support

  • Offer ongoing support and upgrades as a retainer once the backfill is live and the Prometheus server is in operation.
  • Re-run verification when recording rules, retention or the Prometheus version change in your environment.
  • Ask the support team to confirm response and coverage terms in the written agreement before work begins.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.