diff --git a/agent/consul/state/usage.go b/agent/consul/state/usage.go index b3794105508ad..0893d25288b68 100644 --- a/agent/consul/state/usage.go +++ b/agent/consul/state/usage.go @@ -424,6 +424,11 @@ func (s *Store) ServiceUsage(ws memdb.WatchSet) (uint64, structs.ServiceUsage, e return 0, structs.ServiceUsage{}, fmt.Errorf("failed services lookup: %s", err) } + nodes, err := firstUsageEntry(ws, tx, tableNodes) + if err != nil { + return 0, structs.ServiceUsage{}, fmt.Errorf("failed nodes lookup: %s", err) + } + serviceKindInstances := make(map[string]int) for _, kind := range allConnectKind { usage, err := firstUsageEntry(ws, tx, connectUsageTableName(kind)) @@ -443,6 +448,7 @@ func (s *Store) ServiceUsage(ws memdb.WatchSet) (uint64, structs.ServiceUsage, e Services: services.Count, ConnectServiceInstances: serviceKindInstances, BillableServiceInstances: billableServiceInstances.Count, + Nodes: nodes.Count, } results, err := compileEnterpriseServiceUsage(ws, tx, usage) if err != nil { diff --git a/agent/operator_endpoint_oss_test.go b/agent/operator_endpoint_oss_test.go index 90f0e7d0cd149..f4de46f9050c9 100644 --- a/agent/operator_endpoint_oss_test.go +++ b/agent/operator_endpoint_oss_test.go @@ -65,6 +65,7 @@ func TestOperator_Usage(t *testing.T) { }, // 4 = 6 total service instances - 1 connect proxy - 1 consul service BillableServiceInstances: 4, + Nodes: 2, }, } require.Equal(t, expected, raw.(structs.Usage).Usage) diff --git a/agent/structs/structs.go b/agent/structs/structs.go index c1f6d07606eb9..59385fa5ba448 100644 --- a/agent/structs/structs.go +++ b/agent/structs/structs.go @@ -2324,6 +2324,7 @@ type ServiceUsage struct { ServiceInstances int ConnectServiceInstances map[string]int BillableServiceInstances int + Nodes int EnterpriseServiceUsage } diff --git a/website/content/api-docs/operator/usage.mdx b/website/content/api-docs/operator/usage.mdx index b1dc75c39e088..093ccf7362cc8 100644 --- a/website/content/api-docs/operator/usage.mdx +++ b/website/content/api-docs/operator/usage.mdx @@ -64,7 +64,8 @@ $ curl \ "mesh-gateway": 0, "terminating-gateway": 0 }, - "BillableServiceInstances": 0 + "BillableServiceInstances": 0, + "Nodes": 1 } }, "Index": 13,