Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add audit metric #55

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.",
})
Loading