0

I use grafana to show metrics from prometheus.

But when I restart prometheus server, grafana will not draw data that scraped before.

How make grafana draw all data that scraped from prometheus?

LWH
  • 97
  • 3
  • 11

2 Answers2

3

Don't think Grafana know or care about Prometheus restarts. Are you running Prometheus in a docker? Do you have the Prometheus storage set to a persistent storage. Grafana will just graph the data it gets from the respective data store.

Anshu Prateek
  • 3,011
  • 1
  • 18
  • 33
  • Thank for your reply.I run Prometheus in a docker.When I run it in host, Grafana will draw all data. – LWH Mar 08 '17 at 07:11
  • 2
    You're probably saving the Prometheus data INSIDE the docker, so when you're restarting it, all data is lost. You *should* set Prometheus to store its data OUTSIDE the docker. that way you can still have it run inside docker, and keep the data even after restarts. – FuzzyAmi Mar 09 '17 at 07:26
  • 1
    Correct. Just mount a volume for default data dir /prometheus and you should be good. – Riccardo Jan 31 '21 at 11:02
0

The correct answer should be addressed here: How to persist data in Prometheus running in a Docker container?

In a nutshell, you need to launch prometheus docker by mounting its volume data (/prometheus/ by default) in a persistent way, so you don't lose data upon restart. I smashed my head over it a week, and finally I got it to work :)

Riccardo
  • 1,104
  • 13
  • 22