2020-02-19 21:47:53 +00:00
---
layout: api
page_title: /sys/internal/counters - HTTP API
sidebar_title: <code>/sys/internal/counters</code>
description: >-
The `/sys/internal/counters` endpoints are used to return data about Vault usage.
---
# `/sys/internal/counters`
The `/sys/internal/counters` endpoints are used to return data about the number of Http Requests, Tokens, and Entities in Vault.
2020-05-21 17:18:17 +00:00
~> **NOTE**: This endpoint is only available in Vault version 1.3+. Backwards compatibility is not guaranteed. These endpoints are subject to change or may disappear without notice.
2020-02-19 21:47:53 +00:00
## Http Requests
This endpoint lists the number of Http Requests made per month.
2020-05-21 17:18:17 +00:00
| Method | Path |
| :----- | :-------------------------------- |
| `GET` | `/sys/internal/counters/requests` |
2020-02-19 21:47:53 +00:00
### Sample Request
2020-05-21 17:18:17 +00:00
```shell-session
2020-02-19 21:47:53 +00:00
$ curl \
--header "X-Vault-Token: ..." \
--request GET \
http://127.0.0.1:8200/v1/sys/internal/counters/requests
```
### Sample Response
```json
{
"request_id": "75cbaa46-e741-3eba-2be2-325b1ba8f03f",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
"counters": [
{
"start_time": "2019-05-01T00:00:00Z",
"total": 50
},
{
"start_time": "2019-04-01T00:00:00Z",
"total": 45
}
]
},
"wrap_info": null,
"warnings": null,
"auth": null
}
```
## Entities
This endpoint returns the total number of Entities.
2020-05-21 17:18:17 +00:00
| Method | Path |
| :----- | :-------------------------------- |
| `GET` | `/sys/internal/counters/entities` |
2020-02-19 21:47:53 +00:00
### Sample Request
2020-05-21 17:18:17 +00:00
```shell-session
2020-02-19 21:47:53 +00:00
$ curl \
--header "X-Vault-Token: ..." \
--request GET \
http://127.0.0.1:8200/v1/sys/internal/counters/entities
```
### Sample Response
```json
{
"request_id": "75cbaa46-e741-3eba-2be2-325b1ba8f03f",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
"counters": {
"entities": {
"total": 1
}
}
},
"wrap_info": null,
"warnings": null,
"auth": null
}
```
## Tokens
This endpoint returns the total number of Tokens.
2020-05-21 17:18:17 +00:00
| Method | Path |
| :----- | :------------------------------ |
| `GET` | `/sys/internal/counters/tokens` |
2020-02-19 21:47:53 +00:00
### Sample Request
2020-05-21 17:18:17 +00:00
```shell-session
2020-02-19 21:47:53 +00:00
$ curl \
--header "X-Vault-Token: ..." \
--request GET \
http://127.0.0.1:8200/v1/sys/internal/counters/tokens
```
### Sample Response
```json
{
"request_id": "75cbaa46-e741-3eba-2be2-325b1ba8f03f",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
"counters": {
"service_tokens": {
"total": 1
}
}
},
"wrap_info": null,
"warnings": null,
"auth": null
}
```
2020-11-05 17:47:48 +00:00
## Client Count
This endpoint returns the number of clients per namespace, as the sum of active entities and non-entity tokens.
An "active entity" is a distinct entity that has created one or more tokens in the given time period.
A "non-entity token" is a token with no attached entity ID.
A time period may be specified; otherwise it reports on a default reporting period, such as the
previous twelve calendar months. Reports are only available with month granularity, after each month
has completed. The response includes the actual time period covered, which may not exactly match
the query parameters due to the monthly granularity of the data, or missing months in the requested
time range.
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
2020-12-17 21:53:33 +00:00
period for which client counts will be reported. If no start time is specified, the `default_report_months`
prior to the `end_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.
2020-11-05 17:47:48 +00:00
### Sample Request
```shell-session
$ curl \
--header "X-Vault-Token: ..." \
--request GET \
http://127.0.0.1:8200/v1/sys/internal/counters/activity
```
### Sample Response
```json
{
"request_id": "26be5ab9-dcac-9237-ec12-269a8ca647d5",
"lease_id": "",
"renewable": false,
"lease_duration": 0,
"data": {
"start_time": "2019-11-01T00:00:00Z",
"end_time": "2020-10-31T23:59:59Z",
"total": {
"distinct_entities": 90,
"non_entity_tokens": 130,
"clients": 220
},
"by_namespace": [
{
"namespace_id": "root",
"namespace_path": "",
"counts": {
"distinct_entities": 85,
"non_entity_tokens": 15,
"clients": 100
}
},
{
"namespace_id": "DochC",
"namespace_path": "ns2/",
"counts": {
"distinct_entities": 0,
"non_entity_tokens": 100,
"clients": 100
}
},
{
"namespace_id": "RtgpW",
"namespace_path": "ns1/",
"counts": {
"distinct_entities": 5,
"non_entity_tokens": 15,
"clients": 20
}
2020-12-17 21:53:33 +00:00
}
]
2020-11-05 17:47:48 +00:00
},
"wrap_info": null,
"warnings": null,
"auth": null
}
```
### Sample request for a single month
```shell-session
$ curl \
--header "X-Vault-Token: ..." \
--request GET \
2020-12-17 21:53:33 +00:00
http://127.0.0.1:8200/v1/sys/internal/counters/activity?end_time=2020-06-30T00%3A00%3A00Z&start_time=2020-06-01T00%3A00%3A00Z
2020-11-05 17:47:48 +00:00
```
## Update the Client Count Configuration
The `/sys/internal/counters/config` endpoint is used to configure logging of active clients.
2020-12-17 21:53:33 +00:00
| Method | Path |
| :----- | :------------------------------ |
| `POST` | `/sys/internal/counters/config` |
2020-11-05 17:47:48 +00:00
### Parameters
- `default_report_months` `(integer: 12)` - The number of months to report if no `start_time` is specified in a query.
- `enabled` `(string: enable, disable, default)` - Enable or disable counting of client activity. When set to `default`, the client
2020-12-17 21:53:33 +00:00
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.
2020-11-05 17:47:48 +00:00
- `retention_months` `(integer: 24)` - The number of months of history to retain.
Any missing parameters are left at their existing value.
### Sample Payload
```json
{
2020-12-17 21:53:33 +00:00
"enabled": "enable",
"default_report_months": 3,
"retention_months": 12
2020-11-05 17:47:48 +00:00
}
```
### Sample Request
```shell-session
$ curl \
--request POST
--header "X-Vault-Token: ..." \
--data @payload.json
http://127.0.0.1:8200/v1/sys/internal/counters/config
```
## Read the Client Count Configuration
2020-12-17 21:53:33 +00:00
Reading the configuration shows the current settings, as well as a flag as to whether any data can be queried.
2020-11-05 17:47:48 +00:00
- `enabled` `(string)` - returns `default-enabled` or `default-disabled` if the configuration is `default`.
2020-12-17 21:53:33 +00:00
- `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.
2020-11-05 17:47:48 +00:00
### Sample Request
```shell-session
$ curl \
--request GET
--header "X-Vault-Token: ..." \
http://127.0.0.1:8200/v1/sys/internal/counters/config
```
### Sample Response
```json
{
"request_id": "25a94b99-b49a-c4ac-cb7b-5ba0eb390a25",
"lease_id": "",
"lease_duration": 0,
"renewable": false,
"data": {
"default_report_months": 12,
"enabled": "default-enabled",
"queries_available": true,
"retention_months": 24
},
"warnings": null
}
```