From 4a0d3f6036b78f60437d81257a3b6f2bc7a536b2 Mon Sep 17 00:00:00 2001 From: seanjfellows <34144035+seanjfellows@users.noreply.github.com> Date: Wed, 7 Feb 2018 12:57:00 -0800 Subject: [PATCH] Create audit failure metrics unconditionally (#3937) --- vault/audit.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/vault/audit.go b/vault/audit.go index b446d21b35e0..ad9fbf2c7290 100644 --- a/vault/audit.go +++ b/vault/audit.go @@ -525,10 +525,11 @@ func (a *AuditBroker) LogRequest(ctx context.Context, auth *logical.Auth, req *l } ret = retErr.ErrorOrNil() - + failure := float32(0.0) if ret != nil { - metrics.IncrCounter([]string{"audit", "log_request_failure"}, 1.0) + failure = 1.0 } + metrics.IncrCounter([]string{"audit", "log_request_failure"}, failure) }() // All logged requests must have an identifier @@ -588,9 +589,11 @@ func (a *AuditBroker) LogResponse(ctx context.Context, auth *logical.Auth, req * ret = retErr.ErrorOrNil() + failure := float32(0.0) if ret != nil { - metrics.IncrCounter([]string{"audit", "log_response_failure"}, 1.0) + failure = 1.0 } + metrics.IncrCounter([]string{"audit", "log_response_failure"}, failure) }() headers := req.Headers