From 297a60d238bbc544b381848f0e828cca608e49c5 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Fri, 29 Oct 2021 13:19:43 +0100 Subject: [PATCH] cloudapi: record error metrics Hook up the compose error metric for the prometheus alerts and grafana dashboard. --- internal/cloudapi/v2/errors.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/internal/cloudapi/v2/errors.go b/internal/cloudapi/v2/errors.go index fa73fe3f0..1740424e1 100644 --- a/internal/cloudapi/v2/errors.go +++ b/internal/cloudapi/v2/errors.go @@ -3,8 +3,10 @@ package v2 import ( "fmt" "net/http" + "strings" "github.com/labstack/echo/v4" + "github.com/osbuild/osbuild-composer/internal/prometheus" ) const ( @@ -249,6 +251,12 @@ func (s *Server) HTTPErrorHandler(echoError error, c echo.Context) { return } + if he.Code == http.StatusInternalServerError { + if strings.HasSuffix(c.Path(), "/compose") { + prometheus.ComposeFailures.Inc() + } + } + sec, ok := he.Message.(ServiceErrorCode) if !ok { // No service code was set, so Echo threw this error