mirror of
https://github.com/gravitational/teleport.git
synced 2026-10-12 02:15:01 +00:00
Added Prometheus metric for created access requests (#29761)
This commit is contained in:
@@ -36,6 +36,7 @@ import (
|
||||
insecurerand "math/rand"
|
||||
"os"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
@@ -530,11 +531,21 @@ var (
|
||||
[]string{teleport.TagUpgrader},
|
||||
)
|
||||
|
||||
accessRequestsCreatedMetric = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: teleport.MetricNamespace,
|
||||
Name: teleport.MetricAccessRequestsCreated,
|
||||
Help: "Tracks the number of created access requests",
|
||||
},
|
||||
[]string{teleport.TagRoles, teleport.TagResources},
|
||||
)
|
||||
|
||||
prometheusCollectors = []prometheus.Collector{
|
||||
generateRequestsCount, generateThrottledRequestsCount,
|
||||
generateRequestsCurrent, generateRequestsLatencies, UserLoginCount, heartbeatsMissedByAuth,
|
||||
registeredAgents, migrations,
|
||||
totalInstancesMetric, enrolledInUpgradesMetric, upgraderCountsMetric,
|
||||
accessRequestsCreatedMetric,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -4013,6 +4024,10 @@ func (a *Server) CreateAccessRequestV2(ctx context.Context, req types.AccessRequ
|
||||
if err != nil {
|
||||
log.WithError(err).Warn("Failed to emit access request create event.")
|
||||
}
|
||||
|
||||
accessRequestsCreatedMetric.WithLabelValues(
|
||||
strconv.Itoa(len(req.GetRoles())),
|
||||
strconv.Itoa(len(req.GetRequestedResourceIDs()))).Inc()
|
||||
return req, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,13 @@ const (
|
||||
|
||||
// TagUpgrader is a metric tag for upgraders.
|
||||
TagUpgrader = "upgrader"
|
||||
|
||||
// MetricsAccessRequestsCreated provides total number of created access requests.
|
||||
MetricAccessRequestsCreated = "access_requests_created"
|
||||
// TagRoles is a number of roles requested as a part of access request.
|
||||
TagRoles = "roles"
|
||||
// TagResources is a number of resources requested as a part of access request.
|
||||
TagResources = "resources"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user