From 556d365b2aca50fa6aa2e6302ccd3545cffc822d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Al=C5=BEbeta=20Hajn=C3=A1?= <xhajna@fi.muni.cz> Date: Fri, 5 May 2023 10:59:38 +0200 Subject: [PATCH] feat: added grafana and prometheus to docker compose + reflected in README --- README.md | 30 +++++++----------------------- docker-compose.yaml | 27 ++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5efc888..a4e5a36 100644 --- a/README.md +++ b/README.md @@ -155,31 +155,15 @@ To stop container run docker-compose down ``` -## Collecting Metrics +## Collecting and displaying Metrics -Create network for being able to communicate between two separate -docker images +To collect the metrics in an automated way we use Prometheus, +Grafana is used for displaying the most useful metrics. -```bash -docker network create grafana-prometheus -``` - -To collect the metrics in an automated way we use Prometheus. -First, make sure that every service you want to observe is running on predefined port. -Then run Prometheus in docker with respect to location of `prometheus.yml` file: - -```bash -docker run --rm --name prometheus --network grafana-prometheus --network-alias prometheus -p 9090:9090 -v ${PWD}/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus:v2.43.0 --config.file=/etc/prometheus/prometheus.yml -``` - -## Grafana - -Run Grafana in separate container: +Both services are running in docker container together with modules. -```bash -docker run --rm --name grafana --network grafana-prometheus -p 3000:3000 grafana/grafana:9.1.7 -``` +### Grafana setup -1. Log into Grafana with default user and password is `admin`. +1. Log into Grafana with default user and password `admin`. 2. Add data source in Configuration -> Data sources (http://prometheus:9090) -3. Import Dashboard as JSON file (two options - [simple](https://gitlab.fi.muni.cz/xvicenik/formula-team-management/-/blob/11-actuator/grafana.json), [advanced](https://gitlab.fi.muni.cz/xvicenik/formula-team-management/-/blob/11-actuator/justai-system-monitor_rev2.json)) +3. Import Dashboard as JSON file (two options - [simple](https://gitlab.fi.muni.cz/xvicenik/formula-team-management/-/blob/develop/grafana.json), [advanced](https://gitlab.fi.muni.cz/xvicenik/formula-team-management/-/blob/develop/justai-system-monitor_rev2.json)) diff --git a/docker-compose.yaml b/docker-compose.yaml index d4372ce..912bc8b 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,5 +1,9 @@ version: "3.9" +networks: + grafana-prometheus: + driver: bridge + services: application: build: @@ -28,4 +32,25 @@ services: context: . target: pa165-formula-team-management-visualization ports: - - "8082:8082" \ No newline at end of file + - "8082:8082" + + prometheus: + image: prom/prometheus:v2.43.0 + container_name: prometheus + volumes: + - ./prometheus.yml:/etc/prometheus/prometheus.yml + command: --config.file=/etc/prometheus/prometheus.yml + networks: + grafana-prometheus: + aliases: + - prometheus + ports: + - "9090:9090" + + grafana: + image: grafana/grafana:9.1.7 + container_name: grafana + networks: + - grafana-prometheus + ports: + - "3000:3000" -- GitLab