Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryotarai/prometheus-tsdb-dump
prometheus-tsdb-dump reads a Prometheus TSDB block and writes metrics
https://github.com/ryotarai/prometheus-tsdb-dump
Last synced: 2 months ago
JSON representation
prometheus-tsdb-dump reads a Prometheus TSDB block and writes metrics
- Host: GitHub
- URL: https://github.com/ryotarai/prometheus-tsdb-dump
- Owner: ryotarai
- Created: 2020-01-10T12:18:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T01:13:09.000Z (over 1 year ago)
- Last Synced: 2024-10-06T03:50:02.910Z (3 months ago)
- Language: Go
- Homepage:
- Size: 26.4 KB
- Stars: 25
- Watchers: 4
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# prometheus-tsdb-dump
prometheus-tsdb-dump reads a Prometheus TSDB block and writes metrics.
## Installation
```
$ git clone https://github.com/ryotarai/prometheus-tsdb-dump.git
$ cd prometheus-tsdb-dump
$ make build
```## Usage
```
$ prometheus-tsdb-dump -block /path/to/prometheus-data/block-ulid -format victoriametrics
{"metric":{"__name__":"up","job":"node-exporter","instance":"a"},"values":[1,1,1],"timestamps":[1578636058619,1578636118619,1578636178619]}
{"metric":{"__name__":"up","job":"node-exporter","instance":"b"},"values":[1,1,1],"timestamps":[1578636058619,1578636118619,1578636178619]}
```## Options
- `-format`: Output format (default: victoriametrics)
- `-min-timestamp`: Minimum timestamp of exported samples (unix time in msec)
- `-max-timestamp`: Maximum timestamp of exported samples (unix time in msec)## Output Formats
Output format can be configured via `-format` option.
### `victoriametrics`
`victoriametrics` format is a JSON streaming format which can be imported via [VictoriaMetrics' `/api/v1/import` API](https://github.com/VictoriaMetrics/VictoriaMetrics#how-to-import-time-series-data). It looks like:
```
{"metric":{"__name__":"up","job":"node-exporter"},"values":[1,1,1],"timestamps":[1578636058619,1578636118619,1578636178619]}
```#### How to import TSDB data from Prometheus to VictoriaMetrics
First, take a snapshot of Prometheus TSDB:
```
$ curl -XPOST http://your-prometheus:9090/api/v1/admin/tsdb/snapshot
{"status":"success","data":{"name":"20200110T104512Z-xxxxxxxxxxxx"}}
```Then, import data to VictoriaMetrics:
```
$ cd /path/to/prometheus/data/snapshots/20200110T104512Z-xxxxxxxxxxxx
$ parallelism="$(nproc)"
$ find . -mindepth 1 -maxdepth 1 -type d | xargs -n1 -P "$parallelism" sh -c 'echo $0; prometheus-tsdb-dump-linux -block "$0" -format victoriametrics | curl http://your-victoriametrics:8428/api/v1/import -T -'
```