Skip to content

Commit fc8e5d5

Browse files
Add identity num_entities gauge metric (#8816) (#8834)
Signed-off-by: Dustin Decker <[email protected]> Co-authored-by: Dustin Decker <[email protected]>
1 parent cb47167 commit fc8e5d5

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

vault/core.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2069,6 +2069,7 @@ func stopReplicationImpl(c *Core) error {
20692069
func (c *Core) emitMetrics(stopCh chan struct{}) {
20702070
emitTimer := time.Tick(time.Second)
20712071
writeTimer := time.Tick(c.counters.syncInterval)
2072+
identityCountTimer := time.Tick(time.Minute * 10)
20722073

20732074
for {
20742075
select {
@@ -2094,6 +2095,17 @@ func (c *Core) emitMetrics(stopCh chan struct{}) {
20942095
}
20952096
}
20962097
c.stateLock.RUnlock()
2098+
case <-identityCountTimer:
2099+
go func() {
2100+
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
2101+
defer cancel()
2102+
entities, err := c.countActiveEntities(ctx)
2103+
if err != nil {
2104+
c.logger.Error("error counting identity entities", "err", err)
2105+
} else {
2106+
metrics.SetGauge([]string{"identity", "num_entities"}, float32(entities.Entities.Total))
2107+
}
2108+
}()
20972109

20982110
case <-stopCh:
20992111
return

0 commit comments

Comments
 (0)