Prometheus and Grafana

Installation and first step

Salohy Miarisoa
Jun 18, 2018 · 2 min read

As time series database, prometheus is often used in the world of monitoring system in combination with grafana, which is at the very basic a visualization tool for time series data. I will show you, how to get them up and running with the easiest way.


Grafana documentation is awesome, please check out there for several installation possibilities, I will use the installation with docker for simplicity. Because I want to change some of the default configs for later use, I will mount the configuration file with the docker run.


As well for prometheus, I will take the simple path and install it with docker, again we are using volumes in order to keep persistence and to be able to change the configuration without diving in the container.

But before we can run the docker container, we have to prepare the following configs:

Grafana configuration

Create a file called grafana.ini and copy&past official default configuration in there. It is good to run the config file as volume because of future changes, that you might want to do.

Prometheus configuration

In order to tell prometheus, where to take the metrics, we need to write a config file as well.

  • create a file called prometheus.yml
  • Paste this very basic code example in it, note that at this time you should have an application running, that exposes metrics to prometheus. In my example on localhost using port 8080, check out here the code. You can take localhost:9090, which exposes metrics about the prometheus application itself.
  • Please change this file according to your need
basic prometheus config

We can now start running the container

run prometheus and grafana

Now visit:

Now we have grafana and prometheus installed, but grafana has no idea, where to get the data to show. So, Let us tell grafana to use prometheus.

Connect Grafana and Prometheus using Grafana UI

  1. Open http://your-server-ip:3000
  2. Login with username admin and password admin
  3. On the left side, open the configuration menu and choose datasource
Image for post
Image for post
add prometheus as data source for grafana

Connect Grafana and Prometheus using Grafana provisioning

This is my favourite one :) … We can directly tell grafana to connect to prometheus using the new provisioning system available for v5.0. We just need to create a datasource.yaml file and while running the container, just mount it to /etc/grafana/provisioning/datasources/datasource.yml

You can as well choose to run both Prometheus and Grafana at once, using docker-compose depending on your needs.

Run prometheus and Grafana using docker-compose

And that’s it, you can know create your dashboard and use the metrics you get from your prometheus.

The rest is up to you, for more input you can check these links

So that’s it, I hope it helped you go faster during the installation.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store