forked from quic-go/quic-go
metrics: add a basic setup, collect metrics for the server
This commit is contained in:
25
metrics/dashboards/README.md
Normal file
25
metrics/dashboards/README.md
Normal file
@@ -0,0 +1,25 @@
|
||||
# quic-go Prometheus / Grafana setup
|
||||
|
||||
Expose a Grafana endpoint on `http://localhost:5001/prometheus`:
|
||||
```go
|
||||
import "github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
|
||||
go func() {
|
||||
http.Handle("/prometheus", promhttp.Handler())
|
||||
log.Fatal(http.ListenAndServe(":5001", nil))
|
||||
}()
|
||||
```
|
||||
|
||||
Set a metrics tracer on the `Transport`:
|
||||
```go
|
||||
quic.Transport{
|
||||
Tracer: metrics.NewTracer(),
|
||||
}
|
||||
```
|
||||
|
||||
When using multiple `Transport`s, it is recommended to use the metrics tracer struct for all of them.
|
||||
|
||||
Running:
|
||||
```shell
|
||||
docker-compose up
|
||||
```
|
||||
13
metrics/dashboards/datasources.yml
Normal file
13
metrics/dashboards/datasources.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: 1
|
||||
|
||||
deleteDatasources:
|
||||
- name: Prometheus
|
||||
orgId: 1
|
||||
|
||||
datasources:
|
||||
- name: Prometheus
|
||||
orgId: 1
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
editable: false
|
||||
25
metrics/dashboards/docker-compose.yml
Normal file
25
metrics/dashboards/docker-compose.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
version: '3.8'
|
||||
|
||||
volumes:
|
||||
prometheus_data: {}
|
||||
grafana_data: {}
|
||||
|
||||
services:
|
||||
prometheus:
|
||||
image: prom/prometheus:latest
|
||||
container_name: prometheus
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml
|
||||
- prometheus_data:/prometheus
|
||||
command:
|
||||
- '--config.file=/etc/prometheus/prometheus.yml'
|
||||
expose:
|
||||
- 9090
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: grafana
|
||||
volumes:
|
||||
- grafana_data:/var/lib/grafana
|
||||
- ./datasources.yml:/etc/grafana/provisioning/datasources/prom.yml
|
||||
ports:
|
||||
- "3000:3000"
|
||||
9
metrics/dashboards/prometheus.yml
Normal file
9
metrics/dashboards/prometheus.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
|
||||
scrape_configs:
|
||||
- job_name: 'quic-go'
|
||||
scrape_interval: 15s
|
||||
static_configs:
|
||||
- targets: ['host.docker.internal:5001']
|
||||
metrics_path: '/prometheus'
|
||||
Reference in New Issue
Block a user