-
Notifications
You must be signed in to change notification settings - Fork 10
How to set up Prometheus and Grafana
You will need a Linux distribution, I will show you a clean Ubuntu 22.04 image in a virtual machine.
After the normal installation method, you need to set the network adapter type to bridge.
After that you can see a new device in your router - this is our Ubuntu.
We can see ip of this machine ( in my example it's 192.168.1.106), it will help us later
Git Docker
You can install git with the command apt-get install git
or sudo apt-get install git
You can check the installation with git --version
.
You should see a message like this
You can clone our project with the command git clone https://github.com/ita-social-projects/TeachUA
.
The folder we are mostly interested in is the scripts folder, because that's where our dockers will be located
First, update your existing list of packages:
sudo apt update
.
Next, install a few prerequisite packages which let apt use packages over HTTPS:
``sudo apt install apt-transport-https ca-certificates curl software-properties-common
.
Then add the GPG key for the official Docker repository to your system:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"
This will also update our package database with the Docker packages from the newly added repo.
Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
apt-cache policy docker-ce
.
You'll see output like this, although the version number for Docker may be different:
Finally, install Docker:
sudo apt install docker-ce
.
And install Docker-compose
sudo apt install docker-compose
.
Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it's running:
sudo systemctl status docker
!
After cloning the project, you will see the following files and folders in the scripts folder
In file usage.txt you will find a brief explanation how to start and configure Grafana and Prometheus
In the config/prometheus.yml file you can configure the host address, endpoint, and authentication data to collect metrics.
Basically you should only config prometheus.yml file, and after pasting needed data, it should look something like this
In the scripts folder (where the docker-compose file is) you open a terminal and write sudo docker-compose up --build
.
How to open the Grafana and Prometheus GUI
On the host machine we type in the ip address of Ubuntu (192.168.1.106 in my case) and then :port, specifying the port of the application we want to open, with the default settings Prometheus = 9090, Grafana = 3030
Our address should look something like this: 192.168.1.106:3030 or 192.168.1.106:9090
Prometheus Startup screen
In Status -> Targets , we can see if everything is OK
Grafana work screen
Default login and password is admin admin
Here, you can see premade dashboards that you can use
If you created dashboard, and want to share it in project Click desired dashboard -> Gear Icon - Json Model -> Copy everythig -> paste it in scripts/grafana/provisioning/dashboards in new file yourName.json -> commit and create pull request for changes