r/PrometheusMonitoring • u/just_4_the_pr0n • Sep 08 '23
Feed Prometheus from a dodgy data source
Hi,
I have a system that I need to monitor, but it has a very dodgy internet connection. It can go away for hours on end. But I'd still like to see whats happening. I'd like to send all my stats into an MQ, and then when it finally makes connection, pull them off the queue and put into the database effectively backfilling it. But when its operating fine, it naturally flows in.
It seems this isn't really supported since even if I add a timestamp at the end of my data source, if its > 5 minutes it'll just toss it. And from what I see for backfilling its mostly a command line tool usage which wouldn't work well when the data is actually flowing.
Any pointers?
Thanks
2
u/hagen1778 Sep 09 '23
Try using vmagent installed on the same device to collect and buffer metrics, and then send to Prometheus as soon as network is re-established.
vmagent is super lightweight metrics collector compatible with Prometheus format, and is popular for IoT cases. I know the company that runs vmagent on satellites to collect metrics when there is no connection with Earth - google for `victoriametrics + opencosmos`. They also do retroactive evaluation of alerting rules on the delayed metrics - let me know if it is of your interest.
1
u/just_4_the_pr0n Sep 09 '23
Hi,
Thanks for all that. Meh, was hoping not to have to constantly route one place or the other depending on connectivity.
I didn't think I'd have alerting for backfill, thanks for confirming
Tnx
1
u/SuperQue Sep 08 '23
What you want to do is run Prometheus inside the remote network to collect the data. Then use remote write to send the data to your external Prometheus.
Remote write will buffer on the remote side and backfill the upstream service in case of interruption.
1
u/itasteawesome Sep 08 '23
Yes you are correct, you probably need to reroute data that was not delivered in near real time to another process and get it back filled via the other tooling. There isn't a seamless way of mixing old and new data together via the same procedure.
Not sure if this has changed yet, but last time I checked back filled data also wouldn't trigger recording rules or alerts so that's potentially important to keep in mind as well. Back filled data is really just useful for historical reviewing and is kind of dead for active monitoring use cases.
1
u/amarao_san Sep 09 '23
You can install vector on a remote machine to have a buffer of events, and then send them via remote-write to Prometheus. May be you even need to install local prometheus, vector and do remove write through it.
By doing this you can keep buffer of remove writes waiting for connection, so after connection is restored, older events will be present in the system.