prometheus-backfill
prometheus-backfill
is yet another tool to backfill historical data points to Prometheus. =)
At this moment there are hard ways to take it on Prometheus, so the promisse here is to expose the interfaces to import old data from any disered input to supported remote storage integration and continue using Prometheus as Querier.
The basic import tool reading from Prometheu's API data as json[.gz] files is provided in prometheus-backfill
Notes:
The IO support are the following (TODO is not in development ATM):
Supported input:
- compressed json file from Prometheus' API
- JSON file*
- CSV*
Supported output:
- InfluxDB
- Prometheus remote storage* (using native implementation)
- Prometheus TSDB*
- Elasticsearch*
'* TODO, not developed yet.
Install
Binary:
make build
cp ./bin/prometheus-backfill ~/bin/
Docker (image available on Github Registry):
make container-build
docker pull docker.pkg.github.com/mtulio/prometheus-backfill/prometheus-backfill:latest
Use Cases
Usage
./bin/prometheus-backfill -h
Generate the samples from Prometheus:
PROM_ADDR=localhost:9090
METRIC_PATH="/path/to/metrics/metric-up.json.gz"
$ curl -sq \
-H "Accept-encoding: gzip" \
--data-urlencode "start=$(date -d '1 day ago' +%s)" \
--data-urlencode "end=$(date -d 'now' +%s)" \
--data-urlencode "step=1m" \
--data-urlencode "query=up" \
"${PROM_ADDR}/api/v1/query_range" > "${METRIC_PATH}"
Running from binary:
/usr/bin/time -v \
./bin/prometheus-backfill \
-e json.gz \
-i "${METRIC_PATH}" \
-o "influxdb=http://localhost:8086=prometheus=admin=Super$ecret"
Rnuning from Docker
podman run --rm \
-v ${METRIC_PATH}:/data/metric.json.gz
-it docker.pkg.github.com/mtulio/prometheus-backfill/prometheus-backfill:latest \
/prometheus-backfill \
-e json.gz \
-i /data/metric.json.gz \
-o "influxdb=http://localhost:8086=prometheus=admin=Super$ecret"
Packages
You can customize a input parser/processor and the output storage, or use the default. Just see the package backfill.
Just a few ideas to use a custom package:
- Customize from a custom metric format to write to Proemtheus Storage
- Create a pipeline processing input metrics to a Prometheus Storage
- ...
Roadmap / How to Contribute
Just open a PR or issue if it may help you and you want to contribute.
See the following ideas of this project:
- Develop tests, and tests, and tests... =)
- Improve the documentation
- Improve the parser to consume less memory and parallel processing files/metrics/points.
- Support Remote Storage package from Prometheus