Skip to content
Snippets Groups Projects

Security

Merged Jitka Viceníková requested to merge security into develop
Compare and Show latest version
1 file
+ 4
1
Compare changes
  • Side-by-side
  • Inline
+ 33
48
# Formula team management
## Navigation
- [About Project](#about-project)
- [Build and run the app](#build-and-run-the-app)
- [Seed and clear DB](#seed-and-clear-db)
- [Build and run the app with Docker](#build-and-run-the-app-with-docker)
- [Collecting Metrics](#collecting-and-displaying-metrics)
- [Grafana](#grafana-setup)
## About Project
- **Name**: Formula One Team
@@ -33,9 +41,14 @@
via their REST api's.
2) Notifications module:
<br>Notifications module sends e-mail (or other) notifications to team members.
<br>
- Receives e-mails are determined based on provided e-mail during the creation of new applications and e-mails defined in
**application.properties** in **core** and **application modules**.
3) Visualisation module:
<br>Visualization module provides a visualization of given JSON data in readable HTML (or other) format. Team manager
will be able to visualize current state of both cars.
- The result can be downloaded via Swagger UI or directly accessed in the module's folder **output-data**, which is created
in case of missing.
4) Applications module:
<br>Applications module allows people to send an application to this team. Manager can view these applications and
hire new drivers for his team.
@@ -84,12 +97,12 @@ mvn spring-boot:run
```
To see the running REST api's in action, use CURL or swagger UI:
http://localhost:8080/swagger-ui/index.html
http://localhost:8090/swagger-ui/index.html
Just note that each module runs on a different port by default, so care where you send your requests.<br>
**Default ports:**
- core module: 8080
- core module: 8090
- notifications module: 8083
- visualization module: 8082
- applications module: 8081
@@ -115,48 +128,32 @@ is required, steps to do so are not provided here.
### Building Docker images
To build images you will need `alpine` image
you can get it by running
```bash
docker pull registry.hub.docker.com/library/eclipse-temurin:17-jdk-alpine
```
After successful pull, run
To build individual docker images
```bash
mvn clean install
docker build -t pa165-formula-team-management-<module> --target pa165-formula-team-management-<module> .
```
in root directory to build `jar` file for every module.
*Note: You can use flag `-Dskiptests` to save some time.*
For every module listed above you need to run:
```bash
cd <module>
docker build -t pa165/formula-team-management/<module>-image .
```
*Note: make sure you are in root directory of this project*
### Running Docker images
To run specific docker image use command
To run specific built docker image use command
```bash
docker run -p 8080:8080 pa165/formula-team-management/<module>-image
docker run -p 8090:8090 -e DOCKER='1' pa165-formula-team-management-<module>
```
To avoid confusion the best way is to be consistent with ports listed above,
e.g. for running `application` image use:
```bash
docker run -p 8081:8081 pa165/formula-team-management/application-image
docker run -p 8081:8081 -e DOCKER='1' pa165-formula-team-management-application
```
### Docker compose
To run all modules at once in one container, you can run in root directory
To run all modules at once in one container, you can run (in root directory)
```bash
docker-compose up
@@ -171,31 +168,19 @@ To stop container run
docker-compose down
```
## Collecting Metrics
Create network for being able to communicate between two separate
docker images
```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:
## Collecting and displaying Metrics
```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
```
To collect the metrics in an automated way we use Prometheus,
Grafana is used for displaying the most useful metrics.
## Grafana
Both services are running in docker container together with modules.<br>
You can check prometheus UI at http://localhost:9090.<br>
You can see grafana at http://localhost:3000
Run Grafana in separate container:
### Grafana setup
```bash
docker run --rm --name grafana --network grafana-prometheus -p 3000:3000 grafana/grafana:9.1.7
```
Credentials to log into Grafana are:
- user `admin`
- password `admin`
1. Log into Grafana with default user and password is `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))
Two dashboards are imported automatically, but feel free to experiment and see different metrics.
\ No newline at end of file
Loading