Closed
Description
Currently the only way to bulk-import data is a hacky one involving client-side timestamps and scrapes with multiple samples per time series. We should offer an API for bulk import. This relies on #481.
EDIT: It probably won't be an web-based API in Prometheus, but a command-line tool.
Reacted by Alexander, Alexey Palazhchenko, David Chkhikvadze, Marek Wester, Arne Wiese, Sveta Smirnova, Alexander Rubin, Peter Waller, Sander Saares, Cemalettin Koc and 112 more
Reacted by Severin, Ingwersaft, ber860520, Alessandro Di Stefano and Ivan Velichko
Activity
[-]Add feature for bulk imports[/-][+]Add API for bulk imports[/+]RichiH commentedon Nov 17, 2015
Just as a random data point, I have several (I think valid) use cases for bulk imports.
grypyrg commentedon Jan 19, 2016
+1
foic commentedon Feb 14, 2016
This would be very useful for me as well. I understand that this could be used to blur the line between a true time-series event store and prometheus' communicated focus as a representation of recent monitoring state.
Its beneficial In the case where prometheus is the ingestion point for a fan out system involving influxdb or federated rollup prometheus nodes - this would allow me to just simply keep pumping all data through the prometheus entry points without having to have two input paths in the case where the data feed is delayed.
brian-brazil commentedon Feb 14, 2016
@foic I can't think of a sane Prometheus setup where that'd be useful. If you want to pump data to influxdb, it'd be best to do it without involving Prometheus as Prometheus is adding no value in such a setup. Similarly rollup depends on continuous pulling, and delayed data can't work with that.
I'd generally adivse to run duplicates, and live with the odd gap. It's not worth the effort to try and get it perfect.
foic commentedon Feb 15, 2016
Thanks @brian-brazil - this is pretty much an expected response :-) Sounds like there is
too much to change to make all the pieces work with historical data. Alert
manager, rollup etc etc.
Should this feature request be closed then if working with historical data
is too difficult?
On 15 February 2016 at 10:02, Brian Brazil [email protected] wrote:
brian-brazil commentedon Feb 15, 2016
@foic What you're requesting is different to what this feature request is mainly about.
Baughn commentedon Feb 15, 2016
There's some value to bulk import, even in a world where 'storage' isn't the intended purpose of Prometheus. For example...
Recently I've been working on a Prometheus configuration for a certain forum. Although some of the metrics are from PHP, most of the really useful ones are being exported by an nginx logtailer I wrote.
In order to quickly iterate on possible metrics, prior to putting it in production--that hasn't happened yet--I added code to the logtailer that lets it read logs with a time-offset, pausing between each record until it's "supposed" to happen. That's okay-ish, but it'd be much nicer if I could bulk import an entire day's worth of logs at once without actually waiting a day. Then I could look at the result, clear the DB, and try again.
There's the timestamp hack, but none of the client libraries support timestamps, and it's ugly anyway. I haven't tried to use it.
jinxcat commentedon Feb 15, 2016
@Baughn what do you mean by "timestamp hack"?
I have use for a bulk import endpoint as well, and that's for back-filling data that was interrupted/unavailable on the normal time flow.
Overall, I feel it might be somewhat on the border of what is the intended model of prometheus, but there will always be people with the need to diverge from the ideal setup or situation.
brian-brazil commentedon Feb 15, 2016
That's also not what this issue is about. This issue covers brand new data, with nothing newer than it in the database. It's also not backfilling data, which is when there's nothing older than it in the database.
We've never even discussed this variant.
Baughn commentedon Feb 15, 2016
The /metrics format allows specifying a timestamp in addition to the values. None of the clients support this, and Prometheus doesn't support adding values that are any older than than the newest one.
There's a list of caveats as long as your arm, starting with the impossibility of reliably doing this with multiple tasks exporting metrics, but in theory it should be possible to use timestamps to simulate fast-forwarding through historical data, which would cover my specific scenario.
I've never tried it, though.
brian-brazil commentedon Oct 26, 2016
Per post-Promcon discussions, the consensus was to have a API that can take in a time series at a time.
98 remaining items
brian-brazil commentedon Apr 20, 2020
@sam-mccall That sounds like you're looking for an ongoing push solution, which is not what this issue is about. This issue is about one-off bulk imports.
xgfone commentedon Apr 20, 2020
I understood! Prometheus told us one thing: it only supports the PULL mode, not PUSH, forever! For any proposal about PUSH, it will be rejected to accept.
PULL or PUSH? I follow @RichiH .
bwplotka commentedon Apr 20, 2020
I would not say rejected, but rather enabled somewhere else and letting Prometheus focus on what it is doing best, scraping/pulling metrics (:
For push, you have tons of Prometheus-based systems like Thanos or Cortex both are reusing lots of code (e.g PromQL) of Prometheus and enabling almost the same HTTP read APIs. Both of those do not pull metrics but allows to push them e.g via Prometheus, but anyone else can push as well.
So instead of having single projects being one-tool-for-everything (and thus for nothing, because it's almost impossible to make something efficient that is fully generic), you have others that integrate well with each other. 🤗
Anyway, for this issue, we want to solve the exact case of "ups I forgot to add this data to Prometheus (or Thanos or Cortex)" or "let's migrate my old data from DB X to Prometheus/Thanos/Cortex)"
MarkusTeufelberger commentedon Apr 20, 2020
I don't think that pulling and scraping metrics is what prometheus is doing best, for the record. Most exporters don't even support authentication and prometheus is also relatively inflexible when it comes to scrape configuration (e.g. only fixed intervals instead of dynamic ones, only text format supported, no parameter support in official libraries...). The thing I like about prometheus is the data analysis and alerting part as well as the relative flexibility when it comes to labels etc. (but that comes with a price as well of course) making it more suitable for monitoring dynamic infrastructures or dynamic portions of static infra. I couldn't care less if these data were pushed or pulled into the server before they show up there, as long as they are somewhat reliably showing up.
The minimal viable product I'd like to see is something (
tsdb write ...?) to write a single metric at a single point in time with a single set of labels to a database file. As far as I understand it, prometheus compaction can take it from there. No need for sorting, no need for multiple metrics, no need for any custom format, just a couple of command line parameters in an existing tool. Probably won't be able to import second-by-second data of every rack in a datacenter of the past decades within fractions of a second, but for importing a few thousand measurements it should be plenty enough. Everything else (e.g. a format to encode value:timestamp mappings to import more than one value or a way to import different values into different sets of labels) can come later after discussions, design documents etc.bwplotka commentedon Apr 20, 2020
Arguable, but anyone can have its own opinion, thanks for sharing. (:
Yea, that makes sense. Implementation-wise I can see a couple of problems, but overall generally it looks similar to what I would see as a client (or even embedded client) to
promtool receivewhich would receive simple remote-write API requests. (:Overall our survey started at #7119 is finishing, and remote write is the highest voted requirement. The next one is CSV. I will sum up results and we will definitely have a large discussion among maintainers soon (dev summit) to decide what to do next, but looks like CSV and something like
tsdb writeandpromtool receiveare plausible solutions.sam-mccall commentedon Apr 20, 2020
@brian-brazil Nope, we'd be happy with one-off bulk imports - run a session, import it, analyze it.
Ongoing push would be nice-to-have and seems related, but certainly not needed.
brian-brazil commentedon Apr 20, 2020
I wouldn't consider it to be one off if you're doing it regularly after every session.
shivakumargn commentedon Apr 30, 2020
I have a set of devices that handle network traffic and generate counter information as traffic information with timestamp.
This data becomes available periodically (once a few hours) to be able to provide to prometheus and not in real-time.
Flexibiliy of labels and promql is the key reason to use prometheus.
A means to feed these counters into prometheus with old timestamp is necessary to make such use-case work. I did go through the google doc that is referred to in the earlier discussions and the links referenced in it. I could not find a mechanism to address it.
It is OK if it is via web api or cli, if all counters must be grouped for their timestamp or can be a mix OR directly in tsdb format. Having "some means" is what I am trying to figure out.
kamazee commentedon Apr 30, 2020
I've been recently looking for a solution to instrument a web application; I thought about using Prometheus and eventually stumbled upon this issue. I needed to put timers around certain pieces of code and was willing to push this data into a Prometheus-like system (multiple timers from each HTTP call). Having one value per scraping doesn't really help here; neither histogram nor summary look like a good fit, either: the former needs absolute boundaries, the latter can't be aggregated and is calculated on the client, I rather needed a way to have every point from all over the cluster on a server and run occasional aggregation there.
I'll be considering VictoriaMetrics: at a glance it fills the gap for me. Maybe this hint will also help someone who goes down a similar path.
Well, I hope it doesn't look offensive to post links to other solutions here 🙄 Even though the issue is about bulk loading, as I understood from the discussion here, I'm not the only one who got here looking for a way to push values into a time series.
brian-brazil commentedon Apr 30, 2020
@kamazee That is a general usage question, you'd be best asking it on the prometheus-users mailing list as it sounds like you're looking for something that is not a metrics system at all.
TSDB data import tool
TSDB data import tool
codesome commentedon Nov 26, 2020
Closed by #8084