Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is any way to store Prometheus Data to External Database like mysql or postgreSQL

Currently I am working with the Prometheus and getting a good result, I difficulty I am facing is that if the service restart my whole old data will lose. Is there any way to permanently store the Prometheus data in databases like mysql or PostgreSQL?

like image 333
Anish Varghese Avatar asked Dec 23 '22 05:12

Anish Varghese


2 Answers

You can't write Prometheus data directly to a relational db (or any db for that matter). You have two choices:

  1. mount an external disk on your machine and configure Prometheus to write the data to whatever that mount location was
  2. Write a tiny web script which translates the Prometheus export format to whatever storage format you want. Then configure Prometheus to send data to the web script.

Information can be found on the Prometheus docs.

like image 75
tazer84 Avatar answered Dec 28 '22 21:12

tazer84


Traditiomal databases like MySQL and PostgreSQL aren't optimized for time series data which is collected by Prometheus. There are better solutions exist, which require less storage space and work faster with both inserts and selects.

Prometheus supports remote storage. When enabled, it stores all the new data in both local storage and remote strorage. There are multiple choices exist for the remote storage db with various tradeoffs. I'd recommend trying VictoriaMetrics. It natively supports Prometheus' query language - PromQL, so may be easily used as Prometheus datasource in Grafana.

like image 30
valyala Avatar answered Dec 28 '22 20:12

valyala