Getting data out from Prometheus

5,844 views
Skip to first unread message

Peter Zaitsev

unread,
Oct 6, 2015, 11:08:08 AM10/6/15
to Prometheus Developers
Hi,

Reading some other threads I see what Prometheus is positioned as live monitoring system not to be in competition with R 

The question however becomes what is the recommended way to get data out of Prometheus and load it in some other system crunch with R or other statistical package ? 


Julius Volz

unread,
Oct 6, 2015, 11:21:20 AM10/6/15
to Peter Zaitsev, Prometheus Developers
Since Prometheus doesn't have a specific bulk data export feature yet, your best bet is using the HTTP querying API: http://prometheus.io/docs/querying/api/

If you want to get out the raw values as they were ingested, you may actually not want to use /api/v1/query_range, but /api/v1/query, but with a range specified in the query expression.

For example, if you wanted to get all raw (timestamp/value) pairs for the metric "up" from 2015-10-06T15:10:51.781Z until 1h into the past from that timestamp, you could query that like this:


Cheers,
Julius

--
You received this message because you are subscribed to the Google Groups "Prometheus Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-devel...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Fabian Reinartz

unread,
Oct 6, 2015, 12:24:08 PM10/6/15
to Peter Zaitsev, Prometheus Developers

Currently there is no defined way to get a dump of the raw data, unfortunately.

As Julius said the querying API can be used for now but is not suitable for snapshotting as this will exceed your memory.
One would have to fetch the newest data frequently.

We are open to have a proper way to export data in bulk though.


rzar...@gmail.com

unread,
Jul 16, 2016, 4:15:00 AM7/16/16
to Prometheus Developers, p...@percona.com
Hi all,

any updates on a way to dump prometheus data ?
i'd love to use prometheus, but the idea that i'm "locked" inside a storage that i can't get out is slowing me down.

as our monitoring systems is built on modularity and ease module swapping, this stops us from using the really powerfull prometheus :(

rzar...@gmail.com

unread,
Jul 16, 2016, 5:24:12 AM7/16/16
to Prometheus Developers, p...@percona.com

Ben Kochie

unread,
Jul 16, 2016, 5:51:52 AM7/16/16
to rzar...@gmail.com, Prometheus Developers, Peter Zaitsev

The API supports getting instant vectors which returns lists of values and timestamps.

We're working on plans for proper backups, but it's not implemented yet.


Rachid Zarouali

unread,
Jul 16, 2016, 5:53:36 AM7/16/16
to Ben Kochie, Prometheus Developers, Peter Zaitsev
Awesome Ben !

i'll wait for the dump feature zen and see how we can maybe switch to prometheus :) for the time being we'll stick to graphite :)

Ben Kochie

unread,
Jul 16, 2016, 8:08:18 AM7/16/16
to Rachid Zarouali, Prometheus Developers, Peter Zaitsev

Nothing is stopping you from using both.   :-)

The important thing is to think about your metrics and what is important to monitor for your needs.

Rachid Zarouali

unread,
Jul 16, 2016, 10:46:35 AM7/16/16
to Ben Kochie, Prometheus Developers, Peter Zaitsev

Indeed,

They overlap somehow, but yes it's still doable.

I'll think about it ;-)

Rachid

witt...@googlemail.com

unread,
May 7, 2018, 12:33:37 PM5/7/18
to Prometheus Developers
As an intermediary solution, I created a file called all-prometheus-metrics.txt containing one metric per line:

cadvisor_version_info
container_cpu_system_seconds_total
...
scrape_samples_scraped
up

And retrieved the values for each metric for the last 14 days using this bash script that queries the REST API:
for metric in $(cat all-prometheus-metrics.txt); do curl "localhost:9090/api/v1/query?query=$metric%5B14d%5D" | gzip > $metric.gz; done

The interval syntax is query=scrape_samples_scraped[14d] and url encoded to %5B14d%5D. The pipe through gzip reduces storage requirements on the fly.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages