Skip to content

Commit

Permalink
feat: provide default grafana dashboard (#101)
Browse files Browse the repository at this point in the history
* feat: provide default grafana dashboard

* docs: update README.md to point to config/README.md
  • Loading branch information
SgtPooki authored Apr 10, 2024
1 parent d8fd1c6 commit a9bb04f
Show file tree
Hide file tree
Showing 10 changed files with 3,889 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,10 @@ debugging/test-gateways.log
permutation-logs
*.csv
*.log

# grafana/prometheus files
config/grafana/alerting
config/grafana/grafana.db
.DS_Store
*.log
.env*
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ $ npm run test:e2e-flame # Run the dev server with clinicjs flame, execute e2e t
Running with `METRICS=true` will enable collecting Fastify/libp2p metrics and
will expose a prometheus collection endpoint at <http://localhost:8080/metrics>

js-libp2p metrics are collected by default, but can be disabled by setting `USE_LIBP2P_METRICS=false`. Find out more details at https://github.com/libp2p/js-libp2p/tree/main/packages/metrics-prometheus

### Viewing metrics

See [Metrics config](./config/README.md#metrics) for more information on how to view the generated metrics.

# Install

```console
Expand Down
19 changes: 19 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Configuration

This folder is intended to contain various configuration files for the project.

## Metrics

### Using our provided grafana dashboard with prometheus and grafana

From inside this directory, you can run the following command to start up a grafana and prometheus instance with some default dashboards and datasources set up.

```sh
docker compose -f docker-compose.yml up -d
```

Then visit <http://localhost:3000/d/helia-http-gateway-default/helia-http-gateway-default-dashboard?orgId=1&refresh=5s> and login with the default credentials (admin:admin). The prometheus datasource and the dashboard should be automatically set up.

If you want to generate some metrics quickly, you can run `npm run debug:until-death` and you should start seeing metrics in the dashboard for the results of querying the gateway for the websites listed by <https://probelab.io/websites/>

If you need to reset the grafana database for whatever reason, you can try this command: `cd config && docker compose down && rm grafana/grafana.db && docker compose rm -fsv && docker compose up -d`
21 changes: 21 additions & 0 deletions config/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
version: '3'
services:
prometheus:
image: prom/prometheus
ports:
- 9090:9090
volumes:
- ./prometheus:/etc/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
restart: unless-stopped

grafana:
image: grafana/grafana
ports:
- 3000:3000
volumes:
- ./grafana/datasources:/etc/grafana/provisioning/datasources
- ./grafana/dashboard.yaml:/etc/grafana/provisioning/dashboards/main.yaml
- ./grafana:/var/lib/grafana
restart: unless-stopped
13 changes: 13 additions & 0 deletions config/grafana/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# from https://stackoverflow.com/a/74995091/592760
apiVersion: 1

providers:
- name: "Dashboard provider"
orgId: 1
type: file
disableDeletion: false
updateIntervalSeconds: 10
allowUiUpdates: true
options:
path: /var/lib/grafana/dashboards
foldersFromFilesStructure: true
Loading

0 comments on commit a9bb04f

Please sign in to comment.