add audit metric

This commit is contained in:
Anderson Valério 2024-09-23 15:48:29 -03:00
parent 7eec31f837
commit cb1ecf8886
No known key found for this signature in database
GPG Key ID: 92D38E56BFF005A0
2 changed files with 13 additions and 0 deletions

View File

@ -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
}
}

View File

@ -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.",
})