Skip to content
Snippets Groups Projects
Commit f73c9390 authored by Jan Pokorný's avatar Jan Pokorný :lifter_tone2:
Browse files

Merge branch 'M3-observability' into 'main'

M3 observability

See merge request !33
parents 86a2f2e0 ef3bbb42
No related branches found
No related tags found
1 merge request!33M3 observability
Pipeline #
Showing
with 133 additions and 41 deletions
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- Create a system for language school lecture management. Each lecture can occur on a given day and time and is related to some course. The course is defined by its (unique) name, language and proficiency level. However, each lecture will be independent. That means that each lecture can have a different topic. Different lecturers can give it, and an arbitrary number of students can enrol. Each lecturer will have a name, surname, and record of taught languages. In addition, the lecturer will indicate that they are a native speaker. Exercises can be prepared for each course to allow the students to learn the language. Each student can pick the exercises depending on the levels of difficulty. - Create a system for language school lecture management. Each lecture can occur on a given day and time and is related to some course. The course is defined by its (unique) name, language and proficiency level. However, each lecture will be independent. That means that each lecture can have a different topic. Different lecturers can give it, and an arbitrary number of students can enrol. Each lecturer will have a name, surname, and record of taught languages. In addition, the lecturer will indicate that they are a native speaker. Exercises can be prepared for each course to allow the students to learn the language. Each student can pick the exercises depending on the levels of difficulty.
- **Running the modules using docker-compose**: - **Running the modules with metrics and monitoring using docker-compose**:
```console ```console
cd ./application cd ./application
...@@ -26,15 +26,7 @@ ...@@ -26,15 +26,7 @@
docker-compose up docker-compose up
``` ```
- **Running the modules using podman-compose**: - **Running just the modules using docker**:
~~~console
cd ./application
mvn clean install
podman-compose build --parallel
podman-compose up
~~~
- **Running the modules using docker**:
~~~console ~~~console
sudo docker run -d -p 5001:5001 xpokorn8/sprachschulsystem:certificate && sudo docker run -d -p 5001:5001 xpokorn8/sprachschulsystem:certificate &&
sudo docker run -d -p 5002:5002 xpokorn8/sprachschulsystem:exercise && sudo docker run -d -p 5002:5002 xpokorn8/sprachschulsystem:exercise &&
...@@ -42,6 +34,32 @@ ...@@ -42,6 +34,32 @@
sudo docker run -d -p 5003:5003 xpokorn8/sprachschulsystem:mail sudo docker run -d -p 5003:5003 xpokorn8/sprachschulsystem:mail
~~~ ~~~
# Metrics and Monitoring Dashboards
Our application uses Prometheus and Grafana to collect metrics and display them.
When you use the above specified docker-compose commands to run the app, both Prometheus and Grafana containers are automatically launched alongside the app's modules.
You can find the **Prometheus** interface on
http://localhost:9090
You can find **Grafana** interface on http://localhost:3000<br />
The credentials are:<br />
**username:** admin <br />
**password:** admin <br />
In Grafana interface, you can import various dashboards. Our team used and tested https://grafana.com/grafana/dashboards/3662-prometheus-2-0-overview/ board.<br />
To import the dashboard, follow steps bellow:
![Import 1](https://gitlab.fi.muni.cz/xpokorn8/sprachschulsystem/-/raw/M3-observability/docs/grafana01.png)
Select **+** and **Import** in left menu of the Grafana interface.
![Import 2](https://gitlab.fi.muni.cz/xpokorn8/sprachschulsystem/-/raw/M3-observability/docs/grafana02.png)
Insert **3662** into **Import via grafana.com** and click **Load**.
![Prometheus Datasource](https://gitlab.fi.muni.cz/xpokorn8/sprachschulsystem/-/raw/M3-observability/docs/grafana03.png)
Select **Prometheus** in the **prometheus** combo box and click **Import**.
![Dashboard Displayed](https://gitlab.fi.muni.cz/xpokorn8/sprachschulsystem/-/raw/M3-observability/docs/grafana04.png)
The dashboard with metrics data will be displayed.
# Project Description # Project Description
......
version: '3' version: '3'
volumes:
prometheus_data:
grafana-data:
services: services:
certificate: certificate:
...@@ -27,4 +30,29 @@ services: ...@@ -27,4 +30,29 @@ services:
container_name: mail container_name: mail
image: xpokorn8/sprachschulsystem:mail image: xpokorn8/sprachschulsystem:mail
ports: ports:
- "5003:5003" - "5003:5003"
\ No newline at end of file
prometheus:
image: prom/prometheus:v2.43.0
container_name: prometheus
volumes:
- ./prometheus:/etc/prometheus
- prometheus_data:/prometheus
expose:
- 9090
ports:
- "9090:9090"
command:
- '--config.file=/etc/prometheus/prometheus.yml'
grafana:
image: grafana/grafana:7.5.7
ports:
- "3000:3000"
restart: unless-stopped
volumes:
- ./grafana/provisioning/datasources:/etc/grafana/provisioning/datasources
- grafana-data:/var/lib/grafana
datasources:
- name: Prometheus
access: proxy
type: prometheus
url: http://host.docker.internal:9090
isDefault: true
\ No newline at end of file
server.port=5001 server.port=5001
management.endpoints.web.exposure.include=health,metrics,prometheus
management.endpoint.health.show-details=always
management.health.defaults.enabled=true
management.endpoint.health.probes.enabled=true
spring.jpa.open-in-view=false spring.jpa.open-in-view=false
spring.datasource.url=jdbc:h2:mem:social-network;MODE=PostgreSQL spring.datasource.url=jdbc:h2:mem:social-network;MODE=PostgreSQL
spring.datasource.driverClassName=org.h2.Driver spring.datasource.driverClassName=org.h2.Driver
......
server.port=5002 server.port=5002
management.endpoints.web.exposure.include=health,metrics,prometheus
management.endpoint.health.show-details=always
management.health.defaults.enabled=true
management.endpoint.health.probes.enabled=true
spring.h2.console.enabled=true spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:exercices spring.datasource.url=jdbc:h2:mem:exercices
\ No newline at end of file
server.port=5000 server.port=5000
management.endpoints.web.exposure.include=health,metrics,prometheus
management.endpoint.health.show-details=always
management.health.defaults.enabled=true
management.endpoint.health.probes.enabled=true
spring.jpa.open-in-view=false spring.jpa.open-in-view=false
spring.h2.console.enabled=true spring.h2.console.enabled=true
spring.datasource.url=jdbc:h2:mem:school spring.datasource.url=jdbc:h2:mem:school
......
server.port=5003 server.port=5003
management.endpoints.web.exposure.include=health,metrics,prometheus
management.endpoint.health.show-details=always
management.health.defaults.enabled=true
management.endpoint.health.probes.enabled=true
spring.mail.host=smtp.gmail.com spring.mail.host=smtp.gmail.com
spring.mail.port=587 spring.mail.port=587
spring.mail.username=sprachschul@gmail.com spring.mail.username=sprachschul@gmail.com
......
version: '3'
services:
certificate:
build: ./module-certificate
container_name: certificate
image: xpokorn8/sprachschulsystem:certificate
ports:
- "5001:5001"
exercise:
build: ./module-exercise
container_name: exercise
image: xpokorn8/sprachschulsystem:exercise
ports:
- "5002:5002"
language-school:
build: ./module-language-school
container_name: language-school
image: xpokorn8/sprachschulsystem:language-school
ports:
- "5000:5000"
mail:
build: ./module-mail
container_name: mail
image: xpokorn8/sprachschulsystem:mail
ports:
- "5003:5003"
\ No newline at end of file
...@@ -94,6 +94,16 @@ ...@@ -94,6 +94,16 @@
<artifactId>mapstruct</artifactId> <artifactId>mapstruct</artifactId>
<version>${org.mapstruct.version}</version> <version>${org.mapstruct.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
global:
scrape_interval: 1s
external_labels:
monitor: 'my-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets:
- 'localhost:9090'
- job_name: 'module-certificate'
metrics_path: '/actuator/prometheus'
static_configs:
- targets:
- 'host.docker.internal:5001'
- 'docker.for.mac.localhost:5001'
- 'certificate:5001'
- job_name: 'module-exercise'
metrics_path: '/actuator/prometheus'
static_configs:
- targets:
- 'host.docker.internal:5002'
- 'docker.for.mac.localhost:5002'
- 'exercise:5002'
- job_name: 'module-language-school'
metrics_path: '/actuator/prometheus'
static_configs:
- targets:
- 'host.docker.internal:5000'
- 'docker.for.mac.localhost:5000'
- 'language-school:5000'
- job_name: 'module-mail'
metrics_path: '/actuator/prometheus'
static_configs:
- targets:
- 'host.docker.internal:5003'
- 'docker.for.mac.localhost:5003'
- 'mail:5003'
docs/grafana01.png

157 KiB

docs/grafana02.png

34.2 KiB

docs/grafana03.png

68.6 KiB

docs/grafana04.png

78.8 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment