Skip to content

Commit

Permalink
Add a counter for root token creation (#7172)
Browse files Browse the repository at this point in the history
It would be useful to be able to page on root token creation. This PR
adds a counter which increments on this event.
  • Loading branch information
jackkleeman authored and briankassouf committed Oct 28, 2019
1 parent 1af7050 commit 026ada0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vault/token_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ func (ts *TokenStore) create(ctx context.Context, entry *logical.TokenEntry) err
}

entry.Policies = policyutil.SanitizePolicies(entry.Policies, policyutil.DoNotAddDefaultPolicy)
if len(entry.Policies) == 1 && entry.Policies[0] == "root" {
metrics.IncrCounter([]string{"token", "create-root"}, 1)
}

switch entry.Type {
case logical.TokenTypeDefault, logical.TokenTypeService:
Expand Down

0 comments on commit 026ada0

Please sign in to comment.