Add common metrics * add common metrics and sample for using * updates * attempt integration * wip * working stubs generate * docs * comments * Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/common-metrics * runner metrics all * exclude generated from the coverage * fix lint * refactor metrics * change .gen filename * new gen * Merge branch 'main' of bitbucket.org:aarete/query-orchestration into feature/common-metrics * docs * main merge * refactor * add to generate * merge main
Prometheus sample code
This is a sample main that will use the custom doczy prometheus library to expose some typical metrics.
task compose:up:test (to start prometheus)
Then run
go run ./cmd/metricsExample_test/main.go
to start the metrics example server.
Prometheus console is at http://localhost:9090/
Example queries for the
Use these queries in the prometheus console to see the metrics from the sample main.go
Total requests per endpoint (rate over 5m)
rate(myapp_api_api_requests_total[5m])
Request rate by status code
sum by (status) (rate(myapp_api_api_requests_total[5m]))
Request rate by method
sum by (method) (rate(myapp_api_api_requests_total[5m]))
Current active users by type
myapp_api_active_users
Total active users across all types
sum(myapp_api_active_users)
Histograms
95th percentile request duration by endpoint
histogram_quantile(0.95, sum(rate(myapp_api_request_duration_seconds_bucket[5m])) by (endpoint, le))
Average request duration
rate(myapp_api_request_duration_seconds_sum[5m]) / rate(myapp_api_request_duration_seconds_count[5m])
Request duration heatmap (if you have Grafana)
myapp_api_request_duration_seconds_bucket