diff --git a/pkg/api/apikey.go b/pkg/api/apikey.go index 7a3372a78f9..dcabb191f95 100644 --- a/pkg/api/apikey.go +++ b/pkg/api/apikey.go @@ -47,6 +47,7 @@ func (hs *HTTPServer) GetAPIKeys(c *contextmodel.ReqContext) response.Response { Name: t.Name, Role: t.Role, Expiration: expiration, + LastUsedAt: t.LastUsedAt, } } diff --git a/pkg/api/dtos/apikey.go b/pkg/api/dtos/apikey.go index 6540bf02dc5..eb7288771bd 100644 --- a/pkg/api/dtos/apikey.go +++ b/pkg/api/dtos/apikey.go @@ -22,5 +22,6 @@ type ApiKeyDTO struct { Name string `json:"name"` Role org.RoleType `json:"role"` Expiration *time.Time `json:"expiration,omitempty"` + LastUsedAt *time.Time `json:"lastUsedAt,omitempty"` AccessControl accesscontrol.Metadata `json:"accessControl,omitempty"` } diff --git a/public/app/features/api-keys/ApiKeysTable.tsx b/public/app/features/api-keys/ApiKeysTable.tsx index fa449cc73b4..2b39ed5edd0 100644 --- a/public/app/features/api-keys/ApiKeysTable.tsx +++ b/public/app/features/api-keys/ApiKeysTable.tsx @@ -26,6 +26,7 @@ export const ApiKeysTable: FC = ({ apiKeys, timeZone, onDelete, onMigrate Name Role Expires + Last used at @@ -47,6 +48,7 @@ export const ApiKeysTable: FC = ({ apiKeys, timeZone, onDelete, onMigrate )} + {formatLastUsedAtDate(timeZone, key.lastUsedAt)}