|
| 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