Setup
The following section outlines the software requirements and steps to setup a grafana and prometheus instance using docker compose. This setup will be used to monitor the health of your rollapp. In the following sections we will also export a dashboard that will be used to connect alerts to key metrics.
Requirements
This guide assumes you've already setup your environment as outlined in the setup environment section.
Software Requirements
Docker
In order to run the explorer, you will need also to install Docker.
Setup the desired version of docker:
export DOCKER_API_VERSION=1.41
Setup docker repository:
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Install docker packages:
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
give permission to the current user to use the docker daemon:
sudo usermod -aG docker ${USER}
re-login to the user:
newgrp docker
Setup docker repository:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
Install docker packages:
sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Start docker:
sudo systemctl start docker
give permission to the current user to use the docker daemon:
sudo usermod -aG docker ${USER}
re-login the user:
newgrp docker
Grafana and Prometheus Quickstart
In the following section provides all you need to run a grafana and prometheus instances using docker compose. In the following section will export a dashboard that will be used to monitor the health of your rollapp.
First lets by start by creating the prometheus and graphana configuration files. Later we will connect the files to the docker compose file using volumes.
Grafana Configuration
should reside in ./grafana/provisioning/datasources/prometheus.yaml
apiVersion: 1
datasources:
- name: Prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
version: 1
editable: false
Prometheus Configuration
should reside in ./prometheus-config.yaml
global:
scrape_interval: 15s
evaluation_interval: 15s
scrape_configs:
- job_name: 'rollapp'
static_configs:
- targets: ['host.docker.internal:2112']
Docker Compose
Connecting all the files together using docker compose. create a docker-compose.yaml
file in the same directory as the configuration files:
version: '3'
services:
prometheus:
image: prom/prometheus
volumes:
- ./prometheus-config.yaml:/etc/prometheus/prometheus.yml
ports:
- 9092:9090
extra_hosts:
- "host.docker.internal:host-gateway"
grafana:
image: grafana/grafana
ports:
- 3002:3000
volumes:
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
environment:
- GF_SECURITY_ADMIN_USER=admin
- GF_SECURITY_ADMIN_PASSWORD=admin
Now all you need to do is run the docker compose file:
docker compose up -d
After the containers are running you should be able to access grafana at http://localhost:3002
and prometheus at http://localhost:9092
.
Next we will export a dashboard that will be used to monitor the health of your rollapp.