Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport of Add docs for usage endpoint and command into release/1.15.x #16382

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
backport of commit a97ccea
  • Loading branch information
kyhavlov committed Feb 22, 2023
commit dea66f01aab278b7c6cd8c1be1ebf2452dabd378
153 changes: 78 additions & 75 deletions website/content/api-docs/operator/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ description: |-
datacenter.
---

# Operator Usage HTTP API
# Usage Operator HTTP API

The `/operator/usage` endpoint returns usage information about the number of
services, service instances and Connect-enabled service instances by datacenter.
Expand All @@ -30,11 +30,11 @@ The corresponding CLI command is [`consul operator usage instances`](/consul/com

### Query Parameters

- `global` `(bool: false)` - If present, will return usage information for all
known datacenters. By default, only the local datacenter's usage information
is returned.
- `global` `(bool: false)` - If present, usage information for all
known datacenters will be returned. By default, only the local datacenter's
usage information is returned.

- `stale` `(bool: false)` - If the cluster does not currently have a leader an
- `stale` `(bool: false)` - If the cluster does not currently have a leader, an
error will be returned. You can use the `?stale` query parameter to read the
Raft configuration from any of the Consul servers.

Expand All @@ -47,85 +47,88 @@ $ curl \

### Sample Response

<Tabs>
<Tab heading="OSS">
```json
{
"Usage":{
"dc1":{
"Services":1,
"ServiceInstances":1,
"ConnectServiceInstances":{
"connect-native":0,
"connect-proxy":0,
"ingress-gateway":0,
"mesh-gateway":0,
"terminating-gateway":0
},
"BillableServiceInstances":0
}
},
"Index":13,
"LastContact":0,
"KnownLeader":true,
"ConsistencyLevel":"leader",
"NotModified":false,
"Backend":0,
"ResultsFilteredByACLs":false
"Usage": {
"dc1": {
"Services": 1,
"ServiceInstances": 1,
"ConnectServiceInstances": {
"connect-native": 0,
"connect-proxy": 0,
"ingress-gateway": 0,
"mesh-gateway": 0,
"terminating-gateway": 0
},
"BillableServiceInstances": 0
}
},
"Index": 13,
"LastContact": 0,
"KnownLeader": true,
"ConsistencyLevel": "leader",
"NotModified": false,
"Backend": 0,
"ResultsFilteredByACLs": false
}
```

### Sample Response (Enterprise)

</Tab>
<Tab heading="Enterprise">
```json
{
"Usage":{
"dc1":{
"Services":1,
"ServiceInstances":1,
"ConnectServiceInstances":{
"connect-native":0,
"connect-proxy":0,
"ingress-gateway":0,
"mesh-gateway":0,
"terminating-gateway":0
},
"BillableServiceInstances":0,
"PartitionNamespaceServices":{
"default":{
"default":1
}
},
"PartitionNamespaceServiceInstances":{
"default":{
"default":1
}
},
"PartitionNamespaceBillableServiceInstances":{
"default":{
"default":1
}
},
"PartitionNamespaceConnectServiceInstances":{
"default":{
"default":{
"connect-native":0,
"connect-proxy":0,
"ingress-gateway":0,
"mesh-gateway":0,
"terminating-gateway":0
}
}
}
"Usage": {
"dc1": {
"Services": 1,
"ServiceInstances": 1,
"ConnectServiceInstances": {
"connect-native": 0,
"connect-proxy": 0,
"ingress-gateway": 0,
"mesh-gateway": 0,
"terminating-gateway": 0
},
"BillableServiceInstances": 0,
"PartitionNamespaceServices": {
"default": {
"default": 1
}
},
"PartitionNamespaceServiceInstances": {
"default": {
"default": 1
}
},
"PartitionNamespaceBillableServiceInstances": {
"default": {
"default": 1
}
},
"PartitionNamespaceConnectServiceInstances": {
"default": {
"default": {
"connect-native": 0,
"connect-proxy": 0,
"ingress-gateway": 0,
"mesh-gateway": 0,
"terminating-gateway": 0
}
}
}
},
"Index":13,
"LastContact":0,
"KnownLeader":true,
"ConsistencyLevel":"leader",
"NotModified":false,
"Backend":0,
"ResultsFilteredByACLs":false
}
},
"Index": 13,
"LastContact": 0,
"KnownLeader": true,
"ConsistencyLevel": "leader",
"NotModified": false,
"Backend": 0,
"ResultsFilteredByACLs": false
}
```
</Tab>
</Tabs>

- `Services` is the total number of unique service names registered in the
datacenter.
Expand Down
4 changes: 3 additions & 1 deletion website/content/commands/operator/usage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Subcommands:

Corresponding HTTP API Endpoint: [\[GET\] /v1/operator/usage](/consul/api-docs/operator/usage#operator-usage)

Retrieves usage information about the number of services registered in a given
This command retrieves usage information about the number of services registered in a given
datacenter. By default, the datacenter of the local agent is queried.

The table below shows this command's [required ACLs](/consul/api-docs/api-structure#authentication). Configuration of
Expand All @@ -42,6 +42,7 @@ Usage: `consul operator usage instances`
The output looks like this:

```text
$ consul operator usage instances
Billable Service Instances Total: 3
dc1 Billable Service Instances: 3

Expand All @@ -61,6 +62,7 @@ terminating-gateway 0
With the `-all-datacenters` flag:

```text
$ consul operator usage instances -all-datacenters
Billable Service Instances Total: 4
dc1 Billable Service Instances: 3
dc2 Billable Service Instances: 1
Expand Down