Skip to content

Commit 74e1d08

Browse files
committed
update READMEs
1 parent 40272af commit 74e1d08

3 files changed

Lines changed: 189 additions & 136 deletions

File tree

README.md

Lines changed: 95 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,28 @@ This repository is the cornerstone of BBData. It contains:
88
2. dockerfiles and docker-compose for local testing, including: MySQL, Cassandra, Kafka
99
3. the definition of the two databases at the center of BBData: MySQL & Cassandra
1010

11-
12-
1311
- [Development setup](#development-setup)
14-
* [Prerequisites](#prerequisites)
15-
* [Setup](#setup)
16-
* [Cassandra, MySQL and Kafka](#cassandra-mysql-and-kafka)
17-
* [Profiles](#profiles)
18-
* [Hidden system variables](#hidden-system-variables)
12+
* [Prerequisites](#prerequisites)
13+
* [Setup](#setup)
14+
* [Cassandra, MySQL and Kafka](#cassandra--mysql-and-kafka)
15+
* [Profiles](#profiles)
16+
* [Hidden system variables](#hidden-system-variables)
1917
- [Production](#production)
20-
* [Minimal properties to provide](#minimal-properties-to-provide)
21-
* [Executing the jar](#executing-the-jar)
22-
* [Caching](#caching)
23-
* [Async](#async)
24-
* [Logging](#logging)
25-
* [Monitoring](#monitoring)
18+
* [Minimal properties to provide](#minimal-properties-to-provide)
19+
* [Executing the jar](#executing-the-jar)
20+
* [Caching](#caching)
21+
* [Async](#async)
22+
* [Logging](#logging)
23+
* [Monitoring](#monitoring)
2624
- [Permission system](#permission-system)
27-
- [Actuators](#actuators)
28-
* [Management interface (Spring Boot Admin)](#management-interface-spring-boot-admin)
29-
* [Customizing the `/info` endpoint](#customizing-the-about-info-endpoint)
30-
* [Task executor monitoring](#task-executor-monitoring)
31-
* [Changing exposed actuators](#changing-exposed-actuators)
25+
- [Actuators and metrics](#actuators-and-metrics)
26+
* [Customizing the `/about` (`/info`) endpoint](#customizing-the---about-----info---endpoint)
27+
* [Task executor actuator](#task-executor-actuator)
28+
* [Custom metrics](#custom-metrics)
29+
* [Changing exposed actuators](#changing-exposed-actuators)
30+
- [Monitoring](#monitoring)
31+
* [Spring Boot Admin](#spring-boot-admin)
32+
* [Prometheus + Graffana](#prometheus---graffana)
3233

3334
## Development setup
3435

@@ -311,10 +312,6 @@ To deal with tabs, new lines and special characters, also define the following p
311312
$EscapeControlCharactersOnReceive off
312313
```
313314

314-
### Monitoring
315-
316-
See [Spring Boot Admin](#management-interface-spring-boot-admin).
317-
318315
## Permission system
319316

320317
‼️ **tldr; IMPORTANT** Ensure that the `userGroup` with ID 1 has a meaningful name in the database (e.g. "admin") and that
@@ -336,7 +333,9 @@ This is the equivalent of `SUDO`: any admin of this group has read/write access
336333

337334
(see the documentation for more info)
338335

339-
## Actuators
336+
## Actuators and metrics
337+
338+
See [Spring Boot Actuator: Production-ready Features](https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html).
340339

341340
Actuators are a way to monitor the API. They can leak sensitive information, so the management interface should
342341
run on another port as the API, which only administrators have access to.
@@ -352,26 +351,8 @@ or by disabling unsecure actuators, e.g.:
352351
management.endpoints.web.exposure.include=info
353352
```
354353

355-
### Management interface (Spring Boot Admin)
356-
357-
In production, the best would be to use [Spring Boot Admin](https://codecentric.github.io/spring-boot-admin/2.3.0/).
358-
The client is already included in the bbdata-api jar. What you need to do:
359-
360-
1. run a Spring Boot Admin server (see the doc),
361-
2. set the properties below in your application.properties
362-
363-
````properties
364-
## Spring Boot Admin
365-
366-
# expose every actuator available, but ensure it runs on another (secured) port !
367-
management.server.port=8111
368-
management.endpoints.web.exposure.include=*
369-
370-
# enable spring boot admin client, and provide the server's URL
371-
spring.boot.admin.client.enabled=true
372-
spring.boot.admin.client.url=<URL OF THE ADMIN SERVER>
373-
spring.boot.admin.client.instance.name=BBData test Instance
374-
````
354+
Note that if you want to use one or more monitoring systems (see [Monitoring](#monitoring)), you will need to expose
355+
all metrics.
375356

376357
### Customizing the `/about` (`/info`) endpoint
377358

@@ -399,20 +380,88 @@ dynamic.info.<JSON-KEY-NAME-WITHOUT-DOTS>=<ANOTHER PROPERTY>
399380

400381
To hide a dynamic property that is displayed, simply redefine it with an empty value, e.g. `dynamic.info.cache-type=`.
401382

402-
### task executor monitoring
383+
### Task executor actuator
403384

404385
By default, and if `sync.enabled=true`, there is a custom `/tasks` actuator that returns statistics about the task executor
405386
(core size, active threads) and the tasks. To disable this endpoint, change exposed actuators (`id=tasks`).
406387

388+
### Custom metrics
389+
390+
Custom metrics are:
391+
392+
* Task Executor:
393+
- `async.executor`
394+
- `async.executor.active`
395+
- `async.executor.completed`
396+
- `async.executor.idle`
397+
- `async.executor.pool.core`
398+
- `async.executor.pool.max`
399+
- `async.executor.pool.size`
400+
- `async.executor.queue.remaining`
401+
- `async.executor.queued`
402+
403+
* Input:
404+
- `ch.derlin.input.rejected`
405+
- `ch.derlin.login.failed`
406+
- `ch.derlin.auth.failed`
407+
408+
409+
**IMPORTANT**: as long as there is no value, the metric won't appear / doesn't exist.
410+
This means `/metrics/ch.derlin.login.failed` will return `404` as long as no failed login occurred.
411+
Likewise, `metrics/async_*` won't appear if `sync.enabled=false` and/or no value has ever been submitted.
412+
407413
### Changing exposed actuators
408414

409415
[Spring Boot Actuator](https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-features.html#production-ready)
410416

411417
By default, the exposed actuators are defined in `application.properties`, using the key
412-
`management.endpoints.web.exposure.include=`. Feel free to change this list as you see fit.
418+
`management.endpoints.web.exposure.include=`. Feel free to change this list as you see fit, or enable all using `*`.
413419

414420
To **turn off** all endpoints, simply add:
415421
```properties
416422
management.server.port=
417423
management.endpoints.web.exposure.include=none
418-
```
424+
```
425+
426+
## Monitoring
427+
428+
There are two (complementary?) supported monitoring systems:
429+
430+
* [Spring Boot Admin](https://codecentric.github.io/spring-boot-admin/2.3.0/),
431+
which lets you interact with the actuators from a UI (clear the cache, change logging levels, etc.);
432+
* [Prometheus](https://prometheus.io/) + [Graffana](https://grafana.com/),
433+
which lets you graph and monitor different metrics.
434+
435+
### Spring Boot Admin
436+
437+
Spring Boot Admin needs a server running, as well as a client embedded into the API.
438+
439+
For a basic server implementation, see https://github.com/big-building-data/spring-boot-admin
440+
([nightly release](https://github.com/big-building-data/spring-boot-admin/releases/tag/nightly)).
441+
442+
The client is already included in the bbdata-api jar. What you need to do:
443+
444+
1. run a Spring Boot Admin server,
445+
2. set the properties below in your application.properties
446+
447+
````properties
448+
## Spring Boot Admin
449+
450+
# expose every actuator available, but ensure it runs on another (secured) port !
451+
management.server.port=8111
452+
management.endpoints.web.exposure.include=*
453+
454+
# enable spring boot admin client, and provide the server's URL
455+
spring.boot.admin.client.enabled=true
456+
spring.boot.admin.client.url=<URL OF THE ADMIN SERVER>
457+
spring.boot.admin.client.instance.name=BBData test Instance
458+
````
459+
460+
### Prometheus + Graffana
461+
462+
The BBData API ships with `io.micrometer:micrometer-registry-prometheus`.
463+
If the property `management.endpoint.prometheus.enabled=true` and `prometheus` is exposed (see `management.endpoints.web.exposure.include`),
464+
you can see every available metric at http://localhost:8111/prometheus.
465+
466+
See the [other/monitoring's README](https://github.com/big-building-data/bbdata-api/tree/master/other/monitoring) for more info
467+
on how to setup Prometheus and Graffana.

other/monitoring/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,33 @@
22

33
This folder contains a docker compose to monitor BBData API instances using Prometheus + Grafana.
44

5-
**IMPORTANT**: for this to work, the BBData API instances must be launched with the property `management.endpoint.prometheus.enabled=true`.
5+
**IMPORTANT**: for this to work, the BBData API instances must be launched with the prometheus endpoint enabled (see [prerequisites](#prerequisites)).
6+
7+
- [Prerequisites](#prerequisites)
8+
- [Setup and Run](#setup-and-run)
9+
- [prometheus](#prometheus)
10+
- [Grafana](#grafana)
11+
* [First use](#first-use)
12+
* [Tips](#tips)
13+
- [Resources](#resources)
14+
15+
16+
## Prerequisites
17+
18+
The BBData-API must expose all the metrics, as well as the `/prometheus` endpoint.
19+
The best way to do so is to set the following properties:
20+
```properties
21+
# IMPORTANT: actuators may be dangerous, so ensure you run it on another port, that is only available to administrators !
22+
# (in this case, the regular API runs on port 8080 and port 8111 is NOT available from the outside)
23+
24+
# enable ALL actuators and metrics
25+
management.endpoints.web.exposure.include=*
26+
management.endpoint.health.show-components=always
27+
# run management interface on a different port
28+
management.server.port=8111
29+
# remove the default /actuator path prefix
30+
management.endpoints.web.base-path=/
31+
```
632

733
## Setup and Run
834

0 commit comments

Comments
 (0)