Skip to content

Commit 5152edd

Browse files
committed
add prometheus support + prometheus/grafana docker compose
1 parent bd4c887 commit 5152edd

10 files changed

Lines changed: 1111 additions & 20 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ out/
3636

3737
### Other ###
3838
other/cassandra/data
39+
other/monitoring/data
3940
logs

build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,13 @@ dependencies {
5555

5656
// metrics
5757
implementation("org.springframework.boot:spring-boot-starter-actuator")
58+
implementation("io.micrometer:micrometer-registry-prometheus") // prometheus
5859

5960
// kafka
6061
// see compatibility matrix at https://spring.io/projects/spring-kafka
6162
implementation("org.springframework.kafka:spring-kafka")
6263

64+
6365
// for XML support
6466
// implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml")
6567

other/monitoring/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Monitoring with Prometheus + Grafana
2+
3+
This folder contains a docker compose to monitor BBData API instances using Prometheus + Grafana.
4+
5+
**IMPORTANT**: for this to work, the BBData API instances must be launched with the property `management.endpoint.prometheus.enabled=true`.
6+
7+
## Setup and Run
8+
9+
First, edit the file `config/prometheus.yml`:
10+
* set the different target instances, that is the list of `<HOST|IP>:<PORT>` where your applications are running
11+
(when development on Mac, use `host.docker.internal` to access bbdata-api running on localhost)
12+
* change the scraping interval, if you want to
13+
14+
Once done, simply run from this directory the command:
15+
```bash
16+
docker-compose up -d
17+
```
18+
19+
If you get an error of type **permission denied**, such as
20+
```text
21+
You may have issues with file permissions, [...]
22+
mkdir: cannot create directory '/var/lib/grafana/plugins': Permission denied
23+
```
24+
look at the permissions of the `data` folder (chown if needed), and use the `user: 'sid'` directive in `docker-compose.yml`.
25+
On linux, you can get you user sid by running `id -u`.
26+
27+
## prometheus
28+
29+
Prometheus can be accessed on port `9090`.
30+
31+
32+
## Grafana
33+
34+
Grafana can be accessed on port `3000`.
35+
36+
### First use
37+
38+
* use default username/password: *admin/admin* (change it to admin/bbdata or whatever)
39+
* add prometheus data source: *Configuration* > *Add data source* > *Prometheus*, and set URL=`http://prometheus:9090`
40+
* add an open-source Spring Boot dashboard: *"+"* > *Import*: https://grafana.com/grafana/dashboards/10280
41+
* add the custom BBData dashboard using the same import wizard and load (or copy-paste) the JSON file `bbdata-dashboard-grafana.json`

0 commit comments

Comments
 (0)