Metrics
The replay-server
is configured with support for prometheus metrics which can be reported and scraped from the /metrics
endpoint.
curl http://localhost/metrics
# HELP promhttp_metric_handler_requests_in_flight Current number of scrapes being served.
# TYPE promhttp_metric_handler_requests_in_flight gauge
promhttp_metric_handler_requests_in_flight 1
# HELP promhttp_metric_handler_requests_total Total number of scrapes by HTTP status code.
# TYPE promhttp_metric_handler_requests_total counter
promhttp_metric_handler_requests_total{code="200"} 4
promhttp_metric_handler_requests_total{code="500"} 0
promhttp_metric_handler_requests_total{code="503"} 0
# HELP go_threads Number of OS threads created.
# TYPE go_threads gauge
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 0.000143874
go_gc_duration_seconds{quantile="0.25"} 0.000143874
go_gc_duration_seconds{quantile="0.5"} 0.000224583
go_gc_duration_seconds{quantile="0.75"} 0.000224583
go_gc_duration_seconds{quantile="1"} 0.000224583
go_gc_duration_seconds_sum 0.000368457
go_gc_duration_seconds_count 2
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 10
# HELP go_info Information about the Go environment.
# TYPE go_info gauge
go_info{version="go1.20.6"} 1
Creating New Metrics
You can create custom metrics using a simialar pattern as the following example which will track a success metric counter for the health check endpoint.
var (
healthCheckCount = promauto.NewCounterVec(prometheus.CounterOpts{
Name: "health_check_count_total",
Help: "Total count of health checks",
}, []string{"status"})
)
func (s *Server) handleHealthCheck(w http.ResponseWriter, r *http.Request, _ httprouter.Params) int {
{%- if values.database.enabled %}
err := s.Db.Ping()
if err != nil {
healthCheckCount.WithLabelValues("failure").Inc()
w.WriteHeader(http.StatusInternalServerError)
return http.StatusInternalServerError
}
{% endif %}
healthCheckCount.WithLabelValues("success").Inc()
w.WriteHeader(http.StatusOK)
return http.StatusOK
}
Dashboards