diff --git a/pkg/audit/audit_client.go b/pkg/audit/audit_client.go index 2f60842d63..2603dfde23 100644 --- a/pkg/audit/audit_client.go +++ b/pkg/audit/audit_client.go @@ -123,11 +123,13 @@ func (c *Client) createAuditEntry(ss *sessions.SessionState, appURL string, tena auditMessage, err := json.Marshal(auditObject) if err != nil { logger.Errorf("%s: could not marshal the audit object: %v", ErrPersitAuditEvent.Error(), err) + AuditErrorMetricCounter.Inc() return } err = c.send(string(auditMessage)) if err != nil { logger.Errorf("%s: could not send the audit message to the url '%s': %v", ErrPersitAuditEvent.Error(), c.opts.URL, err) + AuditErrorMetricCounter.Inc() return } } diff --git a/pkg/audit/audit_metrics.go b/pkg/audit/audit_metrics.go new file mode 100644 index 0000000000..6522681679 --- /dev/null +++ b/pkg/audit/audit_metrics.go @@ -0,0 +1,11 @@ +package audit + +import ( + "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/promauto" +) + +var AuditErrorMetricCounter = promauto.NewCounter(prometheus.CounterOpts{ + Name: "oauth2_proxy_audit_errors_requests_total", + Help: "Total number of failed audit requests.", +})