/sys/internal/counters
The /sys/internal/counters
endpoints are used to return data about the number of Tokens and Entities in Vault. They return information for the entire cluster.
NOTE: These endpoints are only available in Vault version 1.3+. Backwards compatibility is not guaranteed. These endpoints are subject to change or may disappear without notice.
Entities
This endpoint returns the total number of Entities.
Method | Path |
---|---|
GET | /sys/internal/counters/entities |
Sample request
Sample response
Tokens
This endpoint returns the total number of Tokens.
Method | Path |
---|---|
GET | /sys/internal/counters/tokens |
Sample request
Sample response
Client count
This endpoint returns client activity information for a given billing
period, which is represented by the start_time
and end_time
parameters.
There are a few things to keep in mind while using this API.
For Vault versions before 1.11, the activity information only accounts for the activity of the latest contiguous months in the billing period. For example, if the billing period is from Jan 2022 to June 2022, and the activity subsystem in Vault was not capturing data for the months Jan to March, the response will only include information for May and June. Note that if no
start_time
andend_time
parameters are specified, the billing period defaults to 12 months, so the endpoint will return activity information from the end of the previous month to the start of 12 months prior to that date.As of 1.11, this behavior has been modified to return all available data within the specified billing period.
The response contains the total activity for the billing period and the attributions of the total activity against specific components in Vault. This helps in understanding the total activity better by knowing which components in Vault lead to that top-level activity count. First-level of attribution breakdowns are by namespaces and months, under the
by_namespaces
andmonths
JSON block, respectively.
by_namespaces
breakdowns provide attributions of each namespace to the total activity count. Mount level attributions further break down these namespaces attributions, wherein information can be found on the attributions of each mount path within a given namespace to the overall activity of the namespace.
months
breakdowns provide attributions of each month to the total activity count. These month-level attributions are further broken down into namespace and mount level attributions for each month.
Each entry in the
months
breakdown contains anew_clients
block. When a token is first used within a billing period, it is considered a new client for that billing period. This means that all the active clients in the first month of the billing period will be considered new clients for that billing period. While these tokens could be generated and counted in the previous billing period, they are still considered new clients in the context of the given billing period. For each subsequent month in the same billing period, the tokens used in those months that were unused in previous months of the same billing period are considered new clients for that month. Hence, the computation of new clients differs for each combination ofstart_time
andend_time
.The
new_clients
block within themonths
breakdown will also be further broken down by namespaces and mounts for visibility into which components in Vault lead to the new clients for each month.
The
distinct_entities
field name has been deprecated since Vault 1.10. Refer toentity_clients
field instead. Thedistinct_entities
field is currently returned by the API for backward compatibility and it may be removed in the future.The
non_entity_tokens
field name has been deprecated since Vault 1.10. Refer tonon_entity_clients
field instead. Thenon_entity_tokens
field is currently returned by the API for backward compatibility, and it may be removed in the future.If the
end_date
supplied to the API is for the current month, the activity information returned by this API will only be till the previous month. The activity system is designed to process the accumulated activity only at the end of the month. Since the system does not fully process the current month's information, it will not be added to the API response.The response includes the actual time period covered, which may not exactly match the query parameters due to the month granularity of data or missing months in the requested time range.
Please visit the client count concepts page for more information on how clients map to these client IDs and how they are counted.
The response will include all child namespaces of the namespace in which the request was made. If some namespace has subsequently been deleted, its path will be listed as "deleted namespace :ID:." Deleted namespaces are reported only for queries in the root namespace because the information about the namespace path is unknown.
This endpoint was added in Vault 1.6.
Method | Path |
---|---|
GET | /sys/internal/counters/activity |
Parameters
start_time
(string, optional)
- An RFC3339 timestamp or Unix epoch time. Specifies the start of the period for which client counts will be reported. If no start time is specified, thedefault_report_months
prior to theend_time
will be used.end_time
(string, optional)
- An RFC3339 timestamp or Unix epoch time. Specifies the end of the period for which client counts will be reported. If no end time is specified, the end of the previous calendar month will be used.limit_namespaces
(int, optional)
- Controls the total number of by_namespace data returned. This can be used to return the client counts for the specified number of namespaces having highest activity. If nolimit_namespaces
parameter is specified, client counts for all namespaces in specified usage period is returned.current_billing_period
(bool, optional)
- Uses the builtin billing start timestamp asstart_time
and the current time as theend_time
, returning a response with the current billing period information without having to explicitly provide a start and end time.
Sample request
Sample response
Sample request for a single month
Sample request to get client counts for top 2 namespaces with highest activity for a usage period
Partial month client count
This endpoint returns the client activity in the current month. The response will have activity attributions per namespace, per mount within each namespaces, and new clients information.
The time period is from the start of the current month, up until the time that this request was made.
Note: the client count may be inaccurate in the moments following a Vault reboot, or leadership change. The estimate will stabilize when background loading of client data has completed.
This endpoint was added in Vault 1.7.
Method | Path |
---|---|
GET | /sys/internal/counters/activity/monthly |
Sample request
Sample response
Update the client count configuration
The /sys/internal/counters/config
endpoint is used to configure logging of active clients.
Method | Path |
---|---|
POST | /sys/internal/counters/config |
Parameters
default_report_months
(integer: 12)
- The number of months to report if nostart_time
is specified in a query.enabled
(string: enable, disable, default)
- Enable or disable counting of client activity. When set todefault
, the client counts are enabled on Enterprise builds and disabled on OSS builds. Disabling the feature during the middle of a month will discard any data recorded for that month, but does not delete previous months.retention_months
(integer: 24)
- The number of months of history to retain.
Any missing parameters are left at their existing value.
Sample payload
Sample request
Read the client count configuration
Reading the configuration shows the current settings, as well as a flag as to whether any data can be queried.
enabled
(string)
- returnsdefault-enabled
ordefault-disabled
if the configuration isdefault
.queries_available
(bool)
- indicates whether any usage report is available. This will initially be false until the end of the first calendar month after the feature is enabled.
Sample request
Sample response
Activity export
This endpoint returns an export of the clients that had activity within the provided start and end times. The returned set of client information will be deduplicated over the time window and will show the earliest activity logged for each client. The output will be ordered chronologically by month of activity.
NOTE: This endpoint is currently in tech preview status.
There are a few things to keep in mind while using this API.
The response includes the actual time period covered, which may not exactly match the query parameters due to the month granularity of data or missing months in the requested time range.
If the
end_date
supplied to the API is for the current month, the activity information returned by this API will include activity for this month, however it may be up to 20 minutes delayed.
This endpoint was added in Vault 1.11.
Method | Path |
---|---|
GET | /sys/internal/counters/activity/export |
Parameters
start_time
(string, optional)
- An RFC3339 timestamp or Unix epoch time. Specifies the start of the period for which client counts will be reported. If no start time is specified, thedefault_report_months
prior to theend_time
will be used.end_time
(string, optional)
- An RFC3339 timestamp or Unix epoch time. Specifies the end of the period for which client counts will be reported. If no end time is specified, the end of the previous calendar month will be used.format
(string, optional)
- The desired format of the output file. Allowed values arecsv
andjson
. If no format is provided a default ofjson
will be used.
Sample request
Sample response