diff --git a/README.md b/README.md index 5efc8883f466bd00bda094d710f7c5ccae622d89..a4e5a368aa09a136b6180e40551bfe5c0f5d729d 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 d4372cec7f40ba30d83b85d5a9ff1ad11de071a3..912bc8b9f023e457dd29dcc39b1cf683e3c5cd34 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"