Skip to content

Commit 6c75f40

Browse files
authored
Add Influxdb service (#39)
1 parent 7858b19 commit 6c75f40

File tree

6 files changed

+58
-2
lines changed

6 files changed

+58
-2
lines changed

.gitpod.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ ports:
1515
name: mongo-express
1616
description: "Database explorer (u: admin / p: pass)"
1717
onOpen: ignore
18+
- port: 8086
19+
name: influxdb
20+
description: "Monitoring (u: admin / p: password)"
21+
onOpen: ignore
1822
- port: 8089
1923
name: API docs
2024
onOpen: ignore

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Depending on which optional services you start:
7272
| API docs | http://localhost:8089/ |
7373
| Chessground | http://localhost:8090/demo.html |
7474
| PGN Viewer | http://localhost:8091/ |
75+
| InfluxDB | http://localhost:8086/ (admin/password) |
7576

7677
## Usage
7778

@@ -233,3 +234,16 @@ docker compose run --rm ui bash -c "cd /pgn-viewer && pnpm run sass-dev && pnpm
233234
```
234235

235236
See the changes on the PGN Viewer demo page: http://localhost:8091/
237+
238+
### InfluxDB Monitoring
239+
240+
To view the InfluxDB monitoring dashboard, start your environment with the `Monitoring` service enabled and then visit http://localhost:8086/ (admin/password)
241+
242+
You can also see all the metrics logged by running:
243+
244+
```bash
245+
curl --get http://localhost:8086/query \
246+
--header "Authorization: Token secret" \
247+
--data-urlencode "db=kamon" \
248+
--data-urlencode "q=show measurements;"
249+
```

command/src/main.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ struct Config {
1919
setup_database: bool,
2020
su_password: String,
2121
password: String,
22+
enable_monitoring: bool,
2223
}
2324

2425
impl Config {
@@ -29,6 +30,7 @@ impl Config {
2930
env.push_str(&format!("SETUP_DATABASE={}\n", self.setup_database));
3031
env.push_str(&format!("SU_PASSWORD={}\n", self.su_password));
3132
env.push_str(&format!("PASSWORD={}\n", self.password));
33+
env.push_str(&format!("ENABLE_MONITORING={}\n", self.enable_monitoring));
3234

3335
env
3436
}
@@ -134,6 +136,9 @@ fn setup() -> std::io::Result<()> {
134136
setup_database,
135137
su_password,
136138
password,
139+
enable_monitoring: services
140+
.iter()
141+
.any(|service| service.compose_profile == Some(vec!["monitoring"])),
137142
};
138143

139144
create_placeholder_dirs();
@@ -327,6 +332,14 @@ fn prompt_for_optional_services() -> Result<Vec<OptionalService<'static>>, Error
327332
"Berserk",
328333
"Python API client",
329334
)
335+
.item(
336+
OptionalService {
337+
compose_profile: vec!["monitoring"].into(),
338+
repositories: None,
339+
},
340+
"Monitoring",
341+
"Metric collection using InfluxDB",
342+
)
330343
.item(
331344
OptionalService {
332345
compose_profile: None,

conf/lila.conf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ swiss.bbpairing = "/opt/bbpPairings/bbpPairings.exe"
3232

3333
prismic.api_url = "https://lichess.cdn.prismic.io/api"
3434

35+
kamon.enabled = ${?ENABLE_MONITORING}
36+
kamon.influxdb.hostname = "influxdb"
37+
kamon.influxdb.authentication.token = "secret"
38+
3539
plan.stripe.keys.public = "pk_test_123"
3640
plan.stripe.keys.secret = "sk_test_123"
3741
plan.payPal.keys.public = "sb"

docker-compose.yml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ services:
2525
- SCHEME=${SCHEME:-http}
2626
- LILA_DOMAIN=${LILA_DOMAIN:-localhost:8080}
2727
- PICFIT_DOMAIN=${PICFIT_DOMAIN:-localhost:3001}
28+
- ENABLE_MONITORING=${ENABLE_MONITORING}
2829
volumes:
2930
- ./repos/lila:/lila
3031
- ./repos/chessground:/chessground
@@ -113,8 +114,7 @@ services:
113114
context: docker
114115
dockerfile: lila-fishnet.Dockerfile
115116
environment:
116-
- HTTP_API_LOGGER=true
117-
- REDIS_HOST=redis
117+
- KAMON_ENABLED=${ENABLE_MONITORING:-false}
118118
restart: unless-stopped
119119
networks:
120120
- lila-network
@@ -245,6 +245,23 @@ services:
245245
depends_on:
246246
- mongodb
247247

248+
influxdb:
249+
image: influxdb:2.7.4-alpine
250+
restart: unless-stopped
251+
ports:
252+
- 8086:8086
253+
environment:
254+
- DOCKER_INFLUXDB_INIT_MODE=setup
255+
- DOCKER_INFLUXDB_INIT_USERNAME=admin
256+
- DOCKER_INFLUXDB_INIT_PASSWORD=password
257+
- DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=secret
258+
- DOCKER_INFLUXDB_INIT_ORG=lila-docker
259+
- DOCKER_INFLUXDB_INIT_BUCKET=kamon
260+
networks:
261+
- lila-network
262+
profiles:
263+
- monitoring
264+
248265
networks:
249266
lila-network:
250267
driver: bridge

docker/lila-fishnet.Dockerfile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
FROM sbtscala/scala-sbt:eclipse-temurin-jammy-21.0.1_12_1.9.7_3.3.1
22

3+
ENV CONFIG_FORCE_kamon_influxdb_authentication_token="secret"
4+
ENV CONFIG_FORCE_kamon_influxdb_hostname="influxdb"
5+
ENV REDIS_HOST="redis"
6+
37
WORKDIR /lila-fishnet
48

59
ENTRYPOINT sbt app/run

0 commit comments

Comments
 (0)