-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Prometheus metrics for authentication attempts
Signed-off-by: Matt Rogers <mrogers@redhat.com>
- Loading branch information
Matt Rogers
committed
Aug 16, 2017
1 parent
e2c9b75
commit 37befe7
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package prometheus | ||
|
||
import ( | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
const ( | ||
AuthSubsystem = "auth_subsystem" | ||
) | ||
|
||
var ( | ||
authCounterTotal = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Subsystem: AuthSubsystem, | ||
Name: "auth_count_total", | ||
Help: "Counts total authentication attempts", | ||
}, []string{}, | ||
) | ||
authCounterResult = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Subsystem: AuthSubsystem, | ||
Name: "auth_count_result", | ||
Help: "Counts authentication attempts by result", | ||
}, []string{"result"}, | ||
) | ||
) | ||
|
||
func init() { | ||
prometheus.MustRegister(authCounterTotal) | ||
prometheus.MustRegister(authCounterResult) | ||
} | ||
|
||
func UpdateAuthCounters(result string) { | ||
authCounterTotal.WithLabelValues().Inc() | ||
authCounterResult.WithLabelValues(result).Inc() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters