/promdump

Dumps prometheus queries

Primary LanguageGoApache License 2.0Apache-2.0

Promdump

Dumps a prometheus query to a local file in a generic readable format for further data processing

Minimal usage

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:

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

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:

CURL_SSL_BACKEND=secure-transport promdump -b curl --client-cert $CERT_NAME dump -u $PROM_URL '$PROM_QUERY'