diff --git a/pkg/api/entries.go b/pkg/api/entries.go index 4efba7ba3..c04df49cc 100644 --- a/pkg/api/entries.go +++ b/pkg/api/entries.go @@ -23,6 +23,8 @@ import ( "fmt" "net/http" "net/url" + "strconv" + "time" "github.com/cyberphone/json-canonicalization/go/src/webpki.org/jsoncanonicalizer" "github.com/go-openapi/runtime" @@ -246,6 +248,14 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl if indexStorageClient != nil { go func() { + start := time.Now() + var err error + defer func() { + labels := map[string]string{ + "success": strconv.FormatBool(err == nil), + } + metricIndexStorageLatency.With(labels).Observe(float64(time.Since(start))) + }() keys, err := entry.IndexKeys() if err != nil { log.ContextLogger(ctx).Errorf("getting entry index keys: %v", err) diff --git a/pkg/api/metrics.go b/pkg/api/metrics.go index 64c91b493..56b97788b 100644 --- a/pkg/api/metrics.go +++ b/pkg/api/metrics.go @@ -34,6 +34,11 @@ var ( Help: "The status of publishing events to Pub/Sub", }, []string{"event", "content_type", "status"}) + metricIndexStorageLatency = promauto.NewSummaryVec(prometheus.SummaryOpts{ + Name: "rekor_index_storage_latency_summary", + Help: "Latency of backend index insertion by success/failure", + }, []string{"success"}) + MetricLatency = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "rekor_api_latency", Help: "Api Latency on calls",