Skip to content

Commit 366243f

Browse files
authored
Merge pull request #29 from omnia-network/lorenzo
Implementation of required Dashboards and Integration with Grafana Prometheus Cloud
2 parents 087495f + f191ed5 commit 366243f

19 files changed

+1147
-35
lines changed

.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@ GRAFANA_TEMPO_ENDPOINT=https://your_tempo_endpoint
2727
# Set this to the access token obtained from Grafana Tempo
2828
GRAFANA_TEMPO_ACCESS_TOKEN=your_tempo_basic_auth_token
2929
GRAFANA_TEMPO_LOCAL=false
30+
31+
GRAFANA_PROMETHEUS_ENDPOINT=https://your_grafana_prometheus_cloud_enpoint
32+
GRAFANA_PROMETHEUS_USERNAME=your_grafana_prometheus_cloud_username
33+
GRAFANA_PROMETHEUS_TOKEN=your_grafana_prometheus_cloud_token

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ scripts/gateway_test.log
1212

1313
.env
1414
.idea
15+
16+
prometheus-prod.yml

README.md

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,24 @@ To run the gateway in a prod environment with Docker Compose, follow these steps
9191

9292
2. To run the [docker-compose-prod.yml](./docker-compose-prod.yml) file you need a public domain (that you will put in the `DOMAIN_NAME` environment variable) and a TLS certificate for that domain (because it is configured to make the gateway run with TLS enabled). See [Obtain a TLS certificate](#obtain-a-tls-certificate) for more details.
9393
3. Open the `443` port (or the port that you set in the `LISTEN_PORT` environment variable) on your server and make it reachable from the Internet.
94-
4. Run the gateway:
95-
94+
4. To run all the required production structure you can execute the [start_prod_docker_environment.sh](./scripts/start_prod_docker_environment.sh) with the command:
95+
96+
```
97+
./scripts/start_prod_docker_environment.sh
98+
```
99+
100+
This script firstly generated the `telemetry/prometheus/prometheus-prod.yml` config file starting from the `telemetry/prometheus/prometheus-template.yml` (step required to perform the variable substitution) and then simply run the gateway with the following command:
101+
96102
```
97-
docker compose -f docker-compose.yml -f docker-compose-prod.yml up
103+
docker compose -f docker-compose.yml -f docker-compose-prod.yml --env-file .env up -d --build
98104
```
99105

100-
This command, similar to the local one, allows you to run a docker compose generated from 2 different docker compose files.
101-
5. The Gateway will print its principal in the container logs, just as explained above.
106+
5. To stop and clean all the local environment a bash script [stop_prod_docker_environment.sh](./scripts/stop_prod_docker_environment.sh) is provided. You can execute it with the command:
107+
108+
```
109+
./scripts/stop_prod_docker_environment.sh
110+
```
111+
6. The Gateway will print its principal in the container logs, just as explained above.
102112

103113
### Obtain a TLS certificate
104114

@@ -185,7 +195,11 @@ After installing Node.js and dfx, you can run the integration tests as follows:
185195
```
186196
./scripts/prepare_integration_tests.sh
187197
```
188-
2. The `tests/.env` file should now contain some variables created by `dfx`. Add the variables from the [.env.example](./tests/.env.example) file to the `.env` file and leave them unchanged.
198+
2. Set the environment variables:
199+
```
200+
cp tests/.env.example tests/.env
201+
```
202+
When running the tests, the `tests/.env` file is modified by dfx, which will add some variables.
189203
3. Run integration tests using the Rust test canister:
190204
```
191205
./scripts/integration_test_rs.sh

docker-compose-local.yml

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@ services:
5959
- ic-ws-gateway-network
6060

6161
prometheus:
62-
image: prom/prometheus
63-
container_name: prometheus
64-
ports:
65-
- "9090:9090"
6662
volumes:
67-
- "./telemetry/prometheus.yml:/etc/prometheus/prometheus.yml"
68-
networks:
69-
- ic-ws-gateway-network
63+
- "./telemetry/prometheus/prometheus-local.yml:/etc/prometheus/prometheus.yml"
7064

7165
networks:
7266
ic-ws-gateway-network:

docker-compose-prod.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,7 @@ services:
2121
otlp_collector:
2222
env_file:
2323
- .env
24+
25+
prometheus:
26+
volumes:
27+
- "./telemetry/prometheus/prometheus-prod.yml:/etc/prometheus/prometheus.yml"

docker-compose.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,23 @@ services:
2222
networks:
2323
- ic-ws-gateway-network
2424

25+
# https://grafana.com/docs/grafana-cloud/send-data/metrics/metrics-prometheus/
26+
prometheus:
27+
image: prom/prometheus
28+
# If you want to build from local customized Dockerfile enabling the config file (prometheus.yml) environment variable substitution directly
29+
# inside the image and not outside it, you can use the provided Dockerfile image. (telemetry/prometheus/Dockerfile)
30+
# image: local/prometheus
31+
# build:
32+
# context: ./
33+
# dockerfile: ./telemetry/prometheus/Dockerfile
34+
container_name: prometheus
35+
ports:
36+
- "9090:9090"
37+
env_file:
38+
- .env
39+
networks:
40+
- ic-ws-gateway-network
41+
2542
networks:
2643
ic-ws-gateway-network:
2744
name: ic-ws-gateway-network

scripts/run_test_canister.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ dfx deploy test_canister_rs --no-wallet
77

88
echo "Running integration test"
99
npm run integration:test
10-
11-
dfx stop

scripts/start_local_docker_environment.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
echo "Starting local replica"
44
dfx start --clean --background
55

6-
echo "Removing previous local image"
6+
echo "Removing previous local websocket image"
77
docker rmi local/ic-websocket-gateway
88

99
echo "Starting docker environment"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
echo "Creating the telemetry/prometheus/prometheus-prod.yml file"
4+
# Load and export variables from .env file
5+
set -a # Automatically export all variables
6+
source .env
7+
set +a # Stop automatically exporting
8+
9+
# Run envsubst
10+
envsubst < ./telemetry/prometheus/prometheus-template.yml > ./telemetry/prometheus/prometheus-prod.yml
11+
echo "File telemetry/prometheus/prometheus-prod.yml successfully created"
12+
13+
echo "Starting docker environment"
14+
docker compose -f docker-compose.yml -f docker-compose-prod.yml --env-file .env up -d
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
echo "Stopping docker environment"
4+
docker compose -f docker-compose.yml -f docker-compose-prod.yml down

0 commit comments

Comments
 (0)