diff --git a/.changelog/20674.txt b/.changelog/20674.txt new file mode 100644 index 0000000000..233391aa9b --- /dev/null +++ b/.changelog/20674.txt @@ -0,0 +1,7 @@ +```release-note:breaking-change +telemetry: State store usage metrics with a double `consul` element in the metric name have been removed. Please use the same metric without the second `consul` instead. As an example instead of `consul.consul.state.config_entries` use `consul.state.config_entries` +``` + +```release-note: improvement +telemetry: Improved the performance usage metrics emission by not outputting redundant metrics. +``` diff --git a/agent/consul/usagemetrics/usagemetrics.go b/agent/consul/usagemetrics/usagemetrics.go index ec20295bb5..e55408f514 100644 --- a/agent/consul/usagemetrics/usagemetrics.go +++ b/agent/consul/usagemetrics/usagemetrics.go @@ -20,74 +20,38 @@ import ( ) var Gauges = []prometheus.GaugeDefinition{ - { - Name: []string{"consul", "state", "nodes"}, - Help: "Deprecated - please use state_nodes instead.", - }, { Name: []string{"state", "nodes"}, Help: "Measures the current number of nodes registered with Consul. It is only emitted by Consul servers. Added in v1.9.0.", }, - { - Name: []string{"consul", "state", "peerings"}, - Help: "Deprecated - please use state_peerings instead.", - }, { Name: []string{"state", "peerings"}, Help: "Measures the current number of peerings registered with Consul. It is only emitted by Consul servers. Added in v1.13.0.", }, - { - Name: []string{"consul", "state", "services"}, - Help: "Deprecated - please use state_services instead.", - }, { Name: []string{"state", "services"}, Help: "Measures the current number of unique services registered with Consul, based on service name. It is only emitted by Consul servers. Added in v1.9.0.", }, - { - Name: []string{"consul", "state", "service_instances"}, - Help: "Deprecated - please use state_service_instances instead.", - }, { Name: []string{"state", "service_instances"}, Help: "Measures the current number of unique services registered with Consul, based on service name. It is only emitted by Consul servers. Added in v1.9.0.", }, - { - Name: []string{"consul", "members", "clients"}, - Help: "Deprecated - please use members_clients instead.", - }, { Name: []string{"members", "clients"}, Help: "Measures the current number of client agents registered with Consul. It is only emitted by Consul servers. Added in v1.9.6.", }, - { - Name: []string{"consul", "members", "servers"}, - Help: "Deprecated - please use members_servers instead.", - }, { Name: []string{"members", "servers"}, Help: "Measures the current number of server agents registered with Consul. It is only emitted by Consul servers. Added in v1.9.6.", }, - { - Name: []string{"consul", "state", "kv_entries"}, - Help: "Deprecated - please use kv_entries instead.", - }, { Name: []string{"state", "kv_entries"}, Help: "Measures the current number of entries in the Consul KV store. It is only emitted by Consul servers. Added in v1.10.3.", }, - { - Name: []string{"consul", "state", "connect_instances"}, - Help: "Deprecated - please use state_connect_instances instead.", - }, { Name: []string{"state", "connect_instances"}, Help: "Measures the current number of unique connect service instances registered with Consul, labeled by Kind. It is only emitted by Consul servers. Added in v1.10.4.", }, - { - Name: []string{"consul", "state", "config_entries"}, - Help: "Deprecated - please use state_config_entries instead.", - }, { Name: []string{"state", "config_entries"}, Help: "Measures the current number of unique configuration entries registered with Consul, labeled by Kind. It is only emitted by Consul servers. Added in v1.10.4.", diff --git a/agent/consul/usagemetrics/usagemetrics_ce.go b/agent/consul/usagemetrics/usagemetrics_ce.go index 71457cbb48..db11cb3353 100644 --- a/agent/consul/usagemetrics/usagemetrics_ce.go +++ b/agent/consul/usagemetrics/usagemetrics_ce.go @@ -15,11 +15,6 @@ import ( ) func (u *UsageMetricsReporter) emitNodeUsage(nodeUsage state.NodeUsage) { - metrics.SetGaugeWithLabels( - []string{"consul", "state", "nodes"}, - float32(nodeUsage.Nodes), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"state", "nodes"}, float32(nodeUsage.Nodes), @@ -28,11 +23,6 @@ func (u *UsageMetricsReporter) emitNodeUsage(nodeUsage state.NodeUsage) { } func (u *UsageMetricsReporter) emitPeeringUsage(peeringUsage state.PeeringUsage) { - metrics.SetGaugeWithLabels( - []string{"consul", "state", "peerings"}, - float32(peeringUsage.Peerings), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"state", "peerings"}, float32(peeringUsage.Peerings), @@ -54,22 +44,12 @@ func (u *UsageMetricsReporter) emitMemberUsage(members []serf.Member) { } } - metrics.SetGaugeWithLabels( - []string{"consul", "members", "clients"}, - float32(clients), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"members", "clients"}, float32(clients), u.metricLabels, ) - metrics.SetGaugeWithLabels( - []string{"consul", "members", "servers"}, - float32(servers), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"members", "servers"}, float32(servers), @@ -78,22 +58,12 @@ func (u *UsageMetricsReporter) emitMemberUsage(members []serf.Member) { } func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage structs.ServiceUsage) { - metrics.SetGaugeWithLabels( - []string{"consul", "state", "services"}, - float32(serviceUsage.Services), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"state", "services"}, float32(serviceUsage.Services), u.metricLabels, ) - metrics.SetGaugeWithLabels( - []string{"consul", "state", "service_instances"}, - float32(serviceUsage.ServiceInstances), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"state", "service_instances"}, float32(serviceUsage.ServiceInstances), @@ -106,11 +76,6 @@ func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage structs.ServiceUsag ) for k, i := range serviceUsage.ConnectServiceInstances { - metrics.SetGaugeWithLabels( - []string{"consul", "state", "connect_instances"}, - float32(i), - append(u.metricLabels, metrics.Label{Name: "kind", Value: k}), - ) metrics.SetGaugeWithLabels( []string{"state", "connect_instances"}, float32(i), @@ -120,11 +85,6 @@ func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage structs.ServiceUsag } func (u *UsageMetricsReporter) emitKVUsage(kvUsage state.KVUsage) { - metrics.SetGaugeWithLabels( - []string{"consul", "state", "kv_entries"}, - float32(kvUsage.KVCount), - u.metricLabels, - ) metrics.SetGaugeWithLabels( []string{"state", "kv_entries"}, float32(kvUsage.KVCount), @@ -134,11 +94,6 @@ func (u *UsageMetricsReporter) emitKVUsage(kvUsage state.KVUsage) { func (u *UsageMetricsReporter) emitConfigEntryUsage(configUsage state.ConfigEntryUsage) { for k, i := range configUsage.ConfigByKind { - metrics.SetGaugeWithLabels( - []string{"consul", "state", "config_entries"}, - float32(i), - append(u.metricLabels, metrics.Label{Name: "kind", Value: k}), - ) metrics.SetGaugeWithLabels( []string{"state", "config_entries"}, float32(i), diff --git a/agent/consul/usagemetrics/usagemetrics_ce_test.go b/agent/consul/usagemetrics/usagemetrics_ce_test.go index d0b7587d06..8048641d2e 100644 --- a/agent/consul/usagemetrics/usagemetrics_ce_test.go +++ b/agent/consul/usagemetrics/usagemetrics_ce_test.go @@ -38,78 +38,40 @@ var baseCases = map[string]testCase{ "empty-state": { expectedGauges: map[string]metrics.GaugeValue{ // --- node --- - "consul.usage.test.consul.state.nodes;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.nodes", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.nodes;datacenter=dc1": { Name: "consul.usage.test.state.nodes", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- peering --- - "consul.usage.test.consul.state.peerings;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.peerings", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.peerings;datacenter=dc1": { Name: "consul.usage.test.state.peerings", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- member --- - "consul.usage.test.consul.members.clients;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.members.clients", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.members.clients;datacenter=dc1": { Name: "consul.usage.test.members.clients", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, - "consul.usage.test.consul.members.servers;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.members.servers", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.members.servers;datacenter=dc1": { Name: "consul.usage.test.members.servers", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- service --- - "consul.usage.test.consul.state.services;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.services", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.services;datacenter=dc1": { Name: "consul.usage.test.state.services", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, - "consul.usage.test.consul.state.service_instances;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.service_instances", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.service_instances;datacenter=dc1": { Name: "consul.usage.test.state.service_instances", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- service mesh --- - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-proxy": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "connect-proxy"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-proxy": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -118,14 +80,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "connect-proxy"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=terminating-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "terminating-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=terminating-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -134,14 +88,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "terminating-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=ingress-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "ingress-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=ingress-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -150,14 +96,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "ingress-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=api-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "api-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=api-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -166,14 +104,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "api-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=mesh-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "mesh-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=mesh-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -182,14 +112,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "mesh-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-native": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "connect-native"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-native": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -206,25 +128,12 @@ var baseCases = map[string]testCase{ }, }, // --- kv --- - "consul.usage.test.consul.state.kv_entries;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.kv_entries", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.kv_entries;datacenter=dc1": { Name: "consul.usage.test.state.kv_entries", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- config entries --- - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-intentions": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-intentions"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-intentions": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -233,7 +142,7 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-intentions"}, }, }, - "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-resolver": { // Legacy + "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-resolver": { Name: "consul.usage.test.state.config_entries", Value: 0, Labels: []metrics.Label{ @@ -241,22 +150,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-resolver"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-resolver": { - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-resolver"}, - }, - }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-router": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-router"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-router": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -265,14 +158,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-router"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-defaults": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-defaults"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-defaults": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -281,14 +166,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-defaults"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=ingress-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "ingress-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=ingress-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -297,14 +174,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "ingress-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-splitter": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-splitter"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-splitter": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -313,14 +182,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-splitter"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=mesh": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "mesh"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=mesh": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -329,14 +190,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "mesh"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=proxy-defaults": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "proxy-defaults"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=proxy-defaults": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -345,14 +198,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "proxy-defaults"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=terminating-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "terminating-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=terminating-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -361,14 +206,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "terminating-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "exported-services"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=exported-services": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -377,14 +214,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "exported-services"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=sameness-group": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "sameness-group"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=sameness-group": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -393,14 +222,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "sameness-group"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=api-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "api-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=api-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -409,14 +230,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "api-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=bound-api-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "bound-api-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=bound-api-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -425,14 +238,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "bound-api-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=inline-certificate": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "inline-certificate"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=inline-certificate": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -441,14 +246,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "inline-certificate"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=http-route": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "http-route"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=http-route": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -457,14 +254,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "http-route"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=tcp-route": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "tcp-route"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=tcp-route": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -473,14 +262,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "tcp-route"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=jwt-provider": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "jwt-provider"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=jwt-provider": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -489,14 +270,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "jwt-provider"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=control-plane-request-limit": { - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "control-plane-request-limit"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=control-plane-request-limit": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -538,78 +311,40 @@ var baseCases = map[string]testCase{ }, expectedGauges: map[string]metrics.GaugeValue{ // --- node --- - "consul.usage.test.consul.state.nodes;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.nodes", - Value: 2, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.nodes;datacenter=dc1": { Name: "consul.usage.test.state.nodes", Value: 2, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- peering --- - "consul.usage.test.consul.state.peerings;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.peerings", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.peerings;datacenter=dc1": { Name: "consul.usage.test.state.peerings", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- member --- - "consul.usage.test.consul.members.servers;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.members.servers", - Value: 2, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.members.servers;datacenter=dc1": { Name: "consul.usage.test.members.servers", Value: 2, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, - "consul.usage.test.consul.members.clients;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.members.clients", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.members.clients;datacenter=dc1": { Name: "consul.usage.test.members.clients", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- service --- - "consul.usage.test.consul.state.services;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.services", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.services;datacenter=dc1": { Name: "consul.usage.test.state.services", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, - "consul.usage.test.consul.state.service_instances;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.service_instances", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.service_instances;datacenter=dc1": { Name: "consul.usage.test.state.service_instances", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- service mesh --- - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-proxy": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "connect-proxy"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-proxy": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -618,14 +353,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "connect-proxy"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=terminating-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "terminating-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=terminating-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -634,14 +361,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "terminating-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=ingress-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "ingress-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=ingress-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -650,14 +369,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "ingress-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=api-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "api-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=api-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -666,14 +377,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "api-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=mesh-gateway": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "mesh-gateway"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=mesh-gateway": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -682,14 +385,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "mesh-gateway"}, }, }, - "consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-native": { // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "connect-native"}, - }, - }, "consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-native": { Name: "consul.usage.test.state.connect_instances", Value: 0, @@ -706,25 +401,12 @@ var baseCases = map[string]testCase{ }, }, // --- kv --- - "consul.usage.test.consul.state.kv_entries;datacenter=dc1": { // Legacy - Name: "consul.usage.test.consul.state.kv_entries", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - }, "consul.usage.test.state.kv_entries;datacenter=dc1": { Name: "consul.usage.test.state.kv_entries", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, }, // --- config entries --- - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-intentions": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-intentions"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-intentions": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -733,14 +415,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-intentions"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-resolver": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-resolver"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-resolver": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -749,14 +423,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-resolver"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-router": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-router"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-router": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -765,14 +431,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-router"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-defaults": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-defaults"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-defaults": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -781,14 +439,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-defaults"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=ingress-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "ingress-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=ingress-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -797,14 +447,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "ingress-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-splitter": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "service-splitter"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=service-splitter": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -813,14 +455,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "service-splitter"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=mesh": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "mesh"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=mesh": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -829,14 +463,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "mesh"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=proxy-defaults": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "proxy-defaults"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=proxy-defaults": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -845,14 +471,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "proxy-defaults"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=terminating-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "terminating-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=terminating-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -861,14 +479,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "terminating-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "exported-services"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=exported-services": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -877,14 +487,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "exported-services"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=sameness-group": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "sameness-group"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=sameness-group": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -893,14 +495,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "sameness-group"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=api-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "api-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=api-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -909,14 +503,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "api-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=bound-api-gateway": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "bound-api-gateway"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=bound-api-gateway": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -925,14 +511,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "bound-api-gateway"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=inline-certificate": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "inline-certificate"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=inline-certificate": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -941,14 +519,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "inline-certificate"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=http-route": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "http-route"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=http-route": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -957,14 +527,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "http-route"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=tcp-route": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "tcp-route"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=tcp-route": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -973,14 +535,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "tcp-route"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=jwt-provider": { // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "jwt-provider"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=jwt-provider": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -989,14 +543,6 @@ var baseCases = map[string]testCase{ {Name: "kind", Value: "jwt-provider"}, }, }, - "consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=control-plane-request-limit": { - Name: "consul.usage.test.consul.state.config_entries", - Value: 0, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "control-plane-request-limit"}, - }, - }, "consul.usage.test.state.config_entries;datacenter=dc1;kind=control-plane-request-limit": { Name: "consul.usage.test.state.config_entries", Value: 0, @@ -1092,31 +638,16 @@ func TestUsageReporter_emitPeeringUsage_CE(t *testing.T) { }, } } - peeringsCase.expectedGauges["consul.usage.test.consul.state.nodes;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.nodes", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } peeringsCase.expectedGauges["consul.usage.test.state.nodes;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.state.nodes", Value: 0, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, } - peeringsCase.expectedGauges["consul.usage.test.consul.state.peerings;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.peerings", - Value: 3, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } peeringsCase.expectedGauges["consul.usage.test.state.peerings;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.state.peerings", Value: 3, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, } - peeringsCase.expectedGauges["consul.usage.test.consul.members.clients;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.members.clients", - Value: 0, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } peeringsCase.expectedGauges["consul.usage.test.members.clients;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.members.clients", Value: 0, @@ -1224,54 +755,26 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { }) return baseCaseMembers } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.nodes;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.nodes", - Value: 4, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.nodes;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.state.nodes", Value: 4, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.members.clients;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.members.clients", - Value: 2, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.members.clients;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.members.clients", Value: 2, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.services;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.services", - Value: 8, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.services;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.state.services", Value: 8, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.service_instances;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.service_instances", - Value: 10, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.service_instances;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.state.service_instances", Value: 10, Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-proxy"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 1, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "connect-proxy"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-proxy"] = metrics.GaugeValue{ Name: "consul.usage.test.state.connect_instances", Value: 1, @@ -1280,14 +783,6 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { {Name: "kind", Value: "connect-proxy"}, }, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=terminating-gateway"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 1, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "terminating-gateway"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=terminating-gateway"] = metrics.GaugeValue{ Name: "consul.usage.test.state.connect_instances", Value: 1, @@ -1296,14 +791,6 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { {Name: "kind", Value: "terminating-gateway"}, }, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 1, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "ingress-gateway"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{ Name: "consul.usage.test.state.connect_instances", Value: 1, @@ -1312,14 +799,6 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { {Name: "kind", Value: "ingress-gateway"}, }, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=api-gateway"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 1, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "api-gateway"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=api-gateway"] = metrics.GaugeValue{ Name: "consul.usage.test.state.connect_instances", Value: 1, @@ -1328,14 +807,6 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { {Name: "kind", Value: "api-gateway"}, }, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=mesh-gateway"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 1, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "mesh-gateway"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=mesh-gateway"] = metrics.GaugeValue{ Name: "consul.usage.test.state.connect_instances", Value: 1, @@ -1344,14 +815,6 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { {Name: "kind", Value: "mesh-gateway"}, }, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-native"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.connect_instances", - Value: 1, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "connect-native"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-native"] = metrics.GaugeValue{ Name: "consul.usage.test.state.connect_instances", Value: 1, @@ -1367,14 +830,6 @@ func TestUsageReporter_emitServiceUsage_CE(t *testing.T) { {Name: "datacenter", Value: "dc1"}, }, } - nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.config_entries", - Value: 3, - Labels: []metrics.Label{ - {Name: "datacenter", Value: "dc1"}, - {Name: "kind", Value: "ingress-gateway"}, - }, - } nodesAndSvcsCase.expectedGauges["consul.usage.test.state.config_entries;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{ Name: "consul.usage.test.state.config_entries", Value: 3, @@ -1444,11 +899,6 @@ func TestUsageReporter_emitKVUsage_CE(t *testing.T) { require.NoError(t, s.KVSSet(10, &structs.DirEntry{Key: "e", Value: []byte{1}})) require.NoError(t, s.KVSSet(11, &structs.DirEntry{Key: "f", Value: []byte{1}})) } - nodesCase.expectedGauges["consul.usage.test.consul.state.kv_entries;datacenter=dc1"] = metrics.GaugeValue{ // Legacy - Name: "consul.usage.test.consul.state.kv_entries", - Value: 4, - Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}}, - } nodesCase.expectedGauges["consul.usage.test.state.kv_entries;datacenter=dc1"] = metrics.GaugeValue{ Name: "consul.usage.test.state.kv_entries", Value: 4, diff --git a/agent/consul/usagemetrics/usagemetrics_test.go b/agent/consul/usagemetrics/usagemetrics_test.go index 4e48beb0a3..efe561acd0 100644 --- a/agent/consul/usagemetrics/usagemetrics_test.go +++ b/agent/consul/usagemetrics/usagemetrics_test.go @@ -4,13 +4,21 @@ package usagemetrics import ( + "fmt" "testing" + "time" "github.com/armon/go-metrics" + "github.com/armon/go-metrics/prometheus" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/hashicorp/consul/agent/consul/state" + "github.com/hashicorp/consul/agent/structs" + "github.com/hashicorp/consul/lib" + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/serf/serf" ) type mockStateProvider struct { @@ -39,3 +47,75 @@ func assertEqualGaugeMaps(t *testing.T, expectedMap, foundMap map[string]metrics assert.Equal(t, expected, foundMap[key], "gauge key mismatch on %q", key) } } + +func BenchmarkRunOnce(b *testing.B) { + const index = 123 + + store := state.NewStateStore(nil) + + // This loop generates: + // + // 4 (service kind) * 100 (service) * 5 * (node) = 2000 proxy services. And 500 non-proxy services. + for _, kind := range []structs.ServiceKind{ + // These will be included in the count. + structs.ServiceKindConnectProxy, + structs.ServiceKindIngressGateway, + structs.ServiceKindTerminatingGateway, + structs.ServiceKindMeshGateway, + + // This one will not. + structs.ServiceKindTypical, + } { + for i := 0; i < 100; i++ { + serviceName := fmt.Sprintf("%s-%d", kind, i) + + for j := 0; j < 5; j++ { + nodeName := fmt.Sprintf("%s-node-%d", serviceName, j) + + require.NoError(b, store.EnsureRegistration(index, &structs.RegisterRequest{ + Node: nodeName, + Service: &structs.NodeService{ + ID: serviceName, + Service: serviceName, + Kind: kind, + }, + })) + } + } + } + + benchmarkRunOnce(b, store) +} + +func benchmarkRunOnce(b *testing.B, store *state.Store) { + b.Helper() + + config := lib.TelemetryConfig{ + MetricsPrefix: "consul", + FilterDefault: true, + PrometheusOpts: prometheus.PrometheusOpts{ + Expiration: time.Second * 30, + Name: "consul", + }, + } + + lib.InitTelemetry(config, hclog.NewNullLogger()) + + um, err := NewUsageMetricsReporter(&Config{ + stateProvider: benchStateProvider(func() *state.Store { return store }), + logger: hclog.NewNullLogger(), + getMembersFunc: func() []serf.Member { return nil }, + }) + require.NoError(b, err) + + b.ResetTimer() + for i := 0; i < b.N; i++ { + um.runOnce() + } +} + +type benchStateProvider func() *state.Store + +func (b benchStateProvider) State() *state.Store { + return b() +} diff --git a/website/content/docs/upgrading/upgrade-specific.mdx b/website/content/docs/upgrading/upgrade-specific.mdx index 36eaf0b942..cd98a95006 100644 --- a/website/content/docs/upgrading/upgrade-specific.mdx +++ b/website/content/docs/upgrading/upgrade-specific.mdx @@ -14,6 +14,17 @@ provided for their upgrades as a result of new features or changed behavior. This page is used to document those details separately from the standard upgrade flow. +## Consul v1.19.x + +### Metrics removal + +In previous versions, Consul emitted redundant state store usage metrics that contained two instances of `consul` in the metric name. As an example, config entry usage counts were emitted as both: + +- `consul.state.config_entries` +- `consul.consul.state.config_entries` + +As of Consul v1.19, Consul does not emit the redundant metric with the double `consul.consul` in its name. Any monitoring alerts and dashboards that you may have utilizing these metrics may require edits to update to the simplified metric name. + ## Consul 1.17.x ### Known issues