From 13cee03fc9e77558353103bb8a0b910e8a107d0a Mon Sep 17 00:00:00 2001 From: Jeff Hodges Date: Tue, 14 Jan 2025 14:59:08 -0800 Subject: [PATCH] add direct-to-prometheus metric for signer requests (#1095) We could have misunderstood what the problem is by looking at a metric that only changed before the first scrape. Updates AUT-393 Updates AUT-199 --- handlers.go | 8 ++++++++ stats.go | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/handlers.go b/handlers.go index 16a23b043..4ce9fee43 100644 --- a/handlers.go +++ b/handlers.go @@ -17,9 +17,11 @@ import ( "net/url" "os" "path" + "strconv" "time" "github.com/gorilla/mux" + "github.com/prometheus/client_golang/prometheus" "github.com/mozilla-services/autograph/formats" "github.com/mozilla-services/autograph/signer" @@ -217,6 +219,12 @@ func (a *autographer) handleSignature(w http.ResponseWriter, r *http.Request) { } requestedSignerConfig := requestedSigner.Config() a.stats.Incr("signer.requests", []string{"keyid:" + requestedSignerConfig.ID, "user:" + userid, usedDefaultSignerTag(sigreq)}, 1.0) + signerRequestsCounter.With(prometheus.Labels{ + "keyid": requestedSignerConfig.ID, + "user": userid, + // TODO(AUT-206): remove this when we've migrate everyone off of the default keyid + "used_default_signer": strconv.FormatBool(sigreq.KeyID == ""), + }).Inc() sigresps[i] = formats.SignatureResponse{ Ref: id(), diff --git a/stats.go b/stats.go index 9218bc12b..426e7ca1e 100644 --- a/stats.go +++ b/stats.go @@ -23,6 +23,11 @@ var ( Name: "prom_only_foobar_test", Help: "A counter used for testing how prometheus and statsd metrics differ", }) + + signerRequestsCounter = prometheus.NewCounterVec(prometheus.CounterOpts{ + Name: "signer_requests", + Help: "A counter for how many authenticated and authorized requests are made to a given signer", + }, []string{"keyid", "user", "used_default_signer"}) ) func loadStatsd(conf configuration) (*statsd.Client, error) {