https://github.com/sapcc/promdump
Dumps prometheus queries
https://github.com/sapcc/promdump
golang prometheus
Last synced: 11 months ago
JSON representation
Dumps prometheus queries
- Host: GitHub
- URL: https://github.com/sapcc/promdump
- Owner: sapcc
- License: apache-2.0
- Created: 2023-03-06T14:14:01.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T16:33:49.000Z (about 2 years ago)
- Last Synced: 2025-02-19T18:47:26.569Z (over 1 year ago)
- Topics: golang, prometheus
- Language: Go
- Homepage:
- Size: 177 KB
- Stars: 2
- Watchers: 47
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Promdump
Dumps a prometheus query to a local file in a generic readable format for further data processing
## Minimal usage
```sh
promdump dump -u $PROM_URL '$PROM_QUERY' > query.json
```
Outputs the flattened query results as json to stdout that can be directly consumed by pandas via:
```python
import pandas as pd
df = pd.read_json("query.json", orient="records")
print(df)
```
To get available metrics and their labels as JSON of a prometheus run
```sh
promdump metrics $PROM_URL
```
## Arguments
Multiple queries can be specified by separating them with a space.
### --backend/-b $BACKEND
Specifies the HTTP backend. Can be `curl` or `go`.
### --client-cert $CERT
Specifies the name of the client certificate to use.
### --format/-f $FORMAT
Specifies the serialization format. Can be `json` or `parquet`.
### --layout/-l $LAYOUT
Specifies the data layout.
- `raw` directly serializes the response of prometheus.
- `nested` creates "rows" of metric name, timestamp value and the label set as a nested element.
- `flat` flattens the label set into the upper structure.
### --compress/-c $COMPRESSION
Specifies the compression for the output. Can be `none` or `gzip`.
### --start/-s $START
Specifies the start timestamp for the query (layout: `2006-01-02T15:04:05`). Defaults to `now - 5m`.
### --end/-e $END
Specifies the end timestamp for the query (layout: `2006-01-02T15:04:05`). Defaults to `now`.
### --step/-S $STEP
Specifies the sample rate for the query. Defaults to `1m`.
### --url/-u $URLS
Specifies the prometheis to query separated by `,`
## Note on MacOS with client-cert authentification
You need to enable that curl HTTP backend:
```sh
CURL_SSL_BACKEND=secure-transport promdump -b curl --client-cert $CERT_NAME dump -u $PROM_URL '$PROM_QUERY'
```