Skip to content

Commit

Permalink
add audit metric
Browse files Browse the repository at this point in the history
  • Loading branch information
andersonvcv committed Sep 23, 2024
1 parent 7eec31f commit cb1ecf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/audit/audit_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
11 changes: 11 additions & 0 deletions pkg/audit/audit_metrics.go
Original file line number Diff line number Diff line change
@@ -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.",
})

0 comments on commit cb1ecf8

Please sign in to comment.