add non-double-prefixed metrics (#14193)

This commit is contained in:
skpratt 2022-09-09 12:13:43 -05:00 committed by GitHub
parent b0218ea35b
commit b761589340
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 587 additions and 60 deletions

3
.changelog/14475.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
metrics: Add duplicate metrics that have only a single "consul_" prefix for all existing metrics with double ("consul_consul_") prefix, with the intent to standardize on single prefixes.
```

30
agent/cache/cache.go vendored
View File

@ -37,6 +37,10 @@ import (
var Gauges = []prometheus.GaugeDefinition{
{
Name: []string{"consul", "cache", "entries_count"},
Help: "Deprecated - please use cache_entries_count instead.",
},
{
Name: []string{"cache", "entries_count"},
Help: "Represents the number of entries in this cache.",
},
}
@ -45,18 +49,34 @@ var Gauges = []prometheus.GaugeDefinition{
var Counters = []prometheus.CounterDefinition{
{
Name: []string{"consul", "cache", "bypass"},
Help: "Deprecated - please use cache_bypass instead.",
},
{
Name: []string{"cache", "bypass"},
Help: "Counts how many times a request bypassed the cache because no cache-key was provided.",
},
{
Name: []string{"consul", "cache", "fetch_success"},
Help: "Deprecated - please use cache_fetch_success instead.",
},
{
Name: []string{"cache", "fetch_success"},
Help: "Counts the number of successful fetches by the cache.",
},
{
Name: []string{"consul", "cache", "fetch_error"},
Help: "Deprecated - please use cache_fetch_error instead.",
},
{
Name: []string{"cache", "fetch_error"},
Help: "Counts the number of failed fetches by the cache.",
},
{
Name: []string{"consul", "cache", "evict_expired"},
Help: "Deprecated - please use cache_evict_expired instead.",
},
{
Name: []string{"cache", "evict_expired"},
Help: "Counts the number of expired entries that are evicted.",
},
}
@ -397,6 +417,7 @@ func entryExceedsMaxAge(maxAge time.Duration, entry cacheEntry) bool {
func (c *Cache) getWithIndex(ctx context.Context, r getOptions) (interface{}, ResultMeta, error) {
if r.Info.Key == "" {
metrics.IncrCounter([]string{"consul", "cache", "bypass"}, 1)
metrics.IncrCounter([]string{"cache", "bypass"}, 1)
// If no key is specified, then we do not cache this request.
// Pass directly through to the backend.
@ -443,6 +464,7 @@ RETRY_GET:
meta := ResultMeta{Index: entry.Index}
if first {
metrics.IncrCounter([]string{"consul", "cache", r.TypeEntry.Name, "hit"}, 1)
metrics.IncrCounter([]string{"cache", r.TypeEntry.Name, "hit"}, 1)
meta.Hit = true
}
@ -496,6 +518,7 @@ RETRY_GET:
missKey = "miss_new"
}
metrics.IncrCounter([]string{"consul", "cache", r.TypeEntry.Name, missKey}, 1)
metrics.IncrCounter([]string{"cache", r.TypeEntry.Name, missKey}, 1)
}
// Set our timeout channel if we must
@ -588,6 +611,7 @@ func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ign
entry.Fetching = true
c.entries[key] = entry
metrics.SetGauge([]string{"consul", "cache", "entries_count"}, float32(len(c.entries)))
metrics.SetGauge([]string{"cache", "entries_count"}, float32(len(c.entries)))
tEntry := r.TypeEntry
// The actual Fetch must be performed in a goroutine.
@ -694,7 +718,9 @@ func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ign
labels := []metrics.Label{{Name: "result_not_modified", Value: strconv.FormatBool(result.NotModified)}}
// TODO(kit): move tEntry.Name to a label on the first write here and deprecate the second write
metrics.IncrCounterWithLabels([]string{"consul", "cache", "fetch_success"}, 1, labels)
metrics.IncrCounterWithLabels([]string{"cache", "fetch_success"}, 1, labels)
metrics.IncrCounterWithLabels([]string{"consul", "cache", tEntry.Name, "fetch_success"}, 1, labels)
metrics.IncrCounterWithLabels([]string{"cache", tEntry.Name, "fetch_success"}, 1, labels)
if result.Index > 0 {
// Reset the attempts counter so we don't have any backoff
@ -728,7 +754,9 @@ func (c *Cache) fetch(key string, r getOptions, allowNew bool, attempt uint, ign
// TODO(kit): Add tEntry.Name to label on fetch_error and deprecate second write
metrics.IncrCounterWithLabels([]string{"consul", "cache", "fetch_error"}, 1, labels)
metrics.IncrCounterWithLabels([]string{"cache", "fetch_error"}, 1, labels)
metrics.IncrCounterWithLabels([]string{"consul", "cache", tEntry.Name, "fetch_error"}, 1, labels)
metrics.IncrCounterWithLabels([]string{"cache", tEntry.Name, "fetch_error"}, 1, labels)
// Increment attempt counter
attempt++
@ -858,7 +886,9 @@ func (c *Cache) runExpiryLoop() {
// Set some metrics
metrics.IncrCounter([]string{"consul", "cache", "evict_expired"}, 1)
metrics.IncrCounter([]string{"cache", "evict_expired"}, 1)
metrics.SetGauge([]string{"consul", "cache", "entries_count"}, float32(len(c.entries)))
metrics.SetGauge([]string{"cache", "entries_count"}, float32(len(c.entries)))
c.entriesLock.Unlock()
}

View File

@ -21,7 +21,7 @@ import (
var IntentionSummaries = []prometheus.SummaryDefinition{
{
Name: []string{"consul", "intention", "apply"},
Help: "",
Help: "Deprecated - please use intention_apply",
},
{
Name: []string{"intention", "apply"},

View File

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"math"
"strings"
"time"
"github.com/armon/go-metrics"
@ -30,15 +31,25 @@ import (
"github.com/hashicorp/consul/proto/pbpeerstream"
)
var leaderExportedServicesCountKey = []string{"consul", "peering", "exported_services"}
var leaderHealthyPeeringKey = []string{"consul", "peering", "healthy"}
var leaderExportedServicesCountKeyDeprecated = []string{"consul", "peering", "exported_services"}
var leaderExportedServicesCountKey = []string{"peering", "exported_services"}
var leaderHealthyPeeringKeyDeprecated = []string{"consul", "peering", "healthy"}
var leaderHealthyPeeringKey = []string{"peering", "healthy"}
var LeaderPeeringMetrics = []prometheus.GaugeDefinition{
{
Name: leaderExportedServicesCountKeyDeprecated,
Help: fmt.Sprint("Deprecated - please use ", strings.Join(leaderExportedServicesCountKey, "_")),
},
{
Name: leaderExportedServicesCountKey,
Help: "A gauge that tracks how many services are exported for the peering. " +
"The labels are \"peer_name\", \"peer_id\" and, for enterprise, \"partition\". " +
"We emit this metric every 9 seconds",
},
{
Name: leaderHealthyPeeringKeyDeprecated,
Help: fmt.Sprint("Deprecated - please use ", strings.Join(leaderExportedServicesCountKey, "_")),
},
{
Name: leaderHealthyPeeringKey,
Help: "A gauge that tracks how if a peering is healthy (1) or not (0). " +
@ -75,6 +86,7 @@ func (s *Server) runPeeringMetrics(ctx context.Context) error {
// "Zero-out" the metric on exit so that when prometheus scrapes this
// metric from a non-leader, it does not get a stale value.
metrics.SetGauge(leaderExportedServicesCountKeyDeprecated, float32(0))
metrics.SetGauge(leaderExportedServicesCountKey, float32(0))
return nil
case <-ticker.C:
@ -105,11 +117,13 @@ func (s *Server) emitPeeringMetricsOnce(logger hclog.Logger, metricsImpl *metric
if found {
// exported services count metric
esc := status.GetExportedServicesCount()
metricsImpl.SetGaugeWithLabels(leaderExportedServicesCountKeyDeprecated, float32(esc), labels)
metricsImpl.SetGaugeWithLabels(leaderExportedServicesCountKey, float32(esc), labels)
}
// peering health metric
if status.NeverConnected {
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKeyDeprecated, float32(math.NaN()), labels)
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKey, float32(math.NaN()), labels)
} else {
healthy := s.peerStreamServer.Tracker.IsHealthy(status)
@ -118,6 +132,7 @@ func (s *Server) emitPeeringMetricsOnce(logger hclog.Logger, metricsImpl *metric
healthyInt = 1
}
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKeyDeprecated, float32(healthyInt), labels)
metricsImpl.SetGaugeWithLabels(leaderHealthyPeeringKey, float32(healthyInt), labels)
}
}

View File

@ -18,38 +18,74 @@ 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.",
},
}

View File

@ -17,6 +17,11 @@ func (u *UsageMetricsReporter) emitNodeUsage(nodeUsage state.NodeUsage) {
float32(nodeUsage.Nodes),
u.metricLabels,
)
metrics.SetGaugeWithLabels(
[]string{"state", "nodes"},
float32(nodeUsage.Nodes),
u.metricLabels,
)
}
func (u *UsageMetricsReporter) emitPeeringUsage(peeringUsage state.PeeringUsage) {
@ -25,6 +30,11 @@ func (u *UsageMetricsReporter) emitPeeringUsage(peeringUsage state.PeeringUsage)
float32(peeringUsage.Peerings),
u.metricLabels,
)
metrics.SetGaugeWithLabels(
[]string{"state", "peerings"},
float32(peeringUsage.Peerings),
u.metricLabels,
)
}
func (u *UsageMetricsReporter) emitMemberUsage(members []serf.Member) {
@ -46,12 +56,22 @@ func (u *UsageMetricsReporter) emitMemberUsage(members []serf.Member) {
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),
u.metricLabels,
)
}
func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage state.ServiceUsage) {
@ -60,12 +80,22 @@ func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage state.ServiceUsage)
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),
u.metricLabels,
)
for k, i := range serviceUsage.ConnectServiceInstances {
metrics.SetGaugeWithLabels(
@ -73,6 +103,11 @@ func (u *UsageMetricsReporter) emitServiceUsage(serviceUsage state.ServiceUsage)
float32(i),
append(u.metricLabels, metrics.Label{Name: "kind", Value: k}),
)
metrics.SetGaugeWithLabels(
[]string{"state", "connect_instances"},
float32(i),
append(u.metricLabels, metrics.Label{Name: "kind", Value: k}),
)
}
}
@ -82,6 +117,11 @@ func (u *UsageMetricsReporter) emitKVUsage(kvUsage state.KVUsage) {
float32(kvUsage.KVCount),
u.metricLabels,
)
metrics.SetGaugeWithLabels(
[]string{"state", "kv_entries"},
float32(kvUsage.KVCount),
u.metricLabels,
)
}
func (u *UsageMetricsReporter) emitConfigEntryUsage(configUsage state.ConfigEntryUsage) {
@ -91,5 +131,10 @@ func (u *UsageMetricsReporter) emitConfigEntryUsage(configUsage state.ConfigEntr
float32(i),
append(u.metricLabels, metrics.Label{Name: "kind", Value: k}),
)
metrics.SetGaugeWithLabels(
[]string{"state", "config_entries"},
float32(i),
append(u.metricLabels, metrics.Label{Name: "kind", Value: k}),
)
}
}

View File

@ -34,41 +34,71 @@ var baseCases = map[string]testCase{
"empty-state": {
expectedGauges: map[string]metrics.GaugeValue{
// --- node ---
"consul.usage.test.consul.state.nodes;datacenter=dc1": {
"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": {
"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": {
"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.consul.members.servers;datacenter=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": {
"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.consul.state.service_instances;datacenter=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": {
"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{
@ -76,7 +106,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "connect-proxy"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=terminating-gateway": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-proxy": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -84,7 +122,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "terminating-gateway"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=ingress-gateway": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=terminating-gateway": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -92,7 +138,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "ingress-gateway"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=mesh-gateway": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=ingress-gateway": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "ingress-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{
@ -100,7 +154,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "mesh-gateway"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-native": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=mesh-gateway": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -108,14 +170,27 @@ var baseCases = map[string]testCase{
{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,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "connect-native"},
},
},
// --- kv ---
"consul.usage.test.consul.state.kv_entries;datacenter=dc1": {
"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": {
"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{
@ -123,6 +198,22 @@ var baseCases = map[string]testCase{
{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,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "service-intentions"},
},
},
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-resolver": { // Legacy
Name: "consul.usage.test.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-resolver": {
Name: "consul.usage.test.consul.state.config_entries",
Value: 0,
@ -131,7 +222,7 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-resolver"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-router": {
"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{
@ -139,7 +230,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-router"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-defaults": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-router": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -147,7 +246,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-defaults"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=ingress-gateway": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-defaults": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -155,7 +262,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "ingress-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-splitter": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=ingress-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -163,7 +278,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-splitter"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=mesh": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-splitter": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -171,7 +294,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "mesh"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=proxy-defaults": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=mesh": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -179,7 +310,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "proxy-defaults"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=terminating-gateway": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=proxy-defaults": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -187,7 +326,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "terminating-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=terminating-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -195,6 +342,14 @@ var baseCases = map[string]testCase{
{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,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "exported-services"},
},
},
},
getMembersFunc: func() []serf.Member { return []serf.Member{} },
},
@ -219,41 +374,71 @@ var baseCases = map[string]testCase{
},
expectedGauges: map[string]metrics.GaugeValue{
// --- node ---
"consul.usage.test.consul.state.nodes;datacenter=dc1": {
"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": {
"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": {
"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.consul.members.clients;datacenter=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": {
"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.consul.state.service_instances;datacenter=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": {
"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{
@ -261,7 +446,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "connect-proxy"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=terminating-gateway": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-proxy": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -269,7 +462,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "terminating-gateway"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=ingress-gateway": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=terminating-gateway": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -277,7 +478,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "ingress-gateway"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=mesh-gateway": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=ingress-gateway": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "ingress-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{
@ -285,7 +494,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "mesh-gateway"},
},
},
"consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-native": {
"consul.usage.test.state.connect_instances;datacenter=dc1;kind=mesh-gateway": {
Name: "consul.usage.test.state.connect_instances",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -293,14 +510,27 @@ var baseCases = map[string]testCase{
{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,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "connect-native"},
},
},
// --- kv ---
"consul.usage.test.consul.state.kv_entries;datacenter=dc1": {
"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": {
"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{
@ -308,7 +538,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-intentions"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-resolver": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-intentions": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -316,7 +554,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-resolver"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-router": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-resolver": {
Name: "consul.usage.test.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{
@ -324,7 +570,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-router"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-defaults": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-router": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -332,7 +586,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-defaults"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=ingress-gateway": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-defaults": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -340,7 +602,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "ingress-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=service-splitter": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=ingress-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -348,7 +618,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "service-splitter"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=mesh": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=service-splitter": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -356,7 +634,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "mesh"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=proxy-defaults": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=mesh": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -364,7 +650,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "proxy-defaults"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=terminating-gateway": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=proxy-defaults": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -372,7 +666,15 @@ var baseCases = map[string]testCase{
{Name: "kind", Value: "terminating-gateway"},
},
},
"consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=exported-services": {
"consul.usage.test.state.config_entries;datacenter=dc1;kind=terminating-gateway": {
Name: "consul.usage.test.state.config_entries",
Value: 0,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -380,6 +682,14 @@ var baseCases = map[string]testCase{
{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,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "exported-services"},
},
},
},
},
}
@ -458,21 +768,36 @@ func TestUsageReporter_emitPeeringUsage_OSS(t *testing.T) {
},
}
}
peeringsCase.expectedGauges["consul.usage.test.consul.state.nodes;datacenter=dc1"] = metrics.GaugeValue{
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.consul.state.peerings;datacenter=dc1"] = metrics.GaugeValue{
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.consul.members.clients;datacenter=dc1"] = metrics.GaugeValue{
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,
Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}},
}
cases["peerings"] = peeringsCase
delete(cases, "nodes")
@ -571,27 +896,47 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
})
return baseCaseMembers
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.nodes;datacenter=dc1"] = metrics.GaugeValue{
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.consul.members.clients;datacenter=dc1"] = metrics.GaugeValue{
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.consul.state.services;datacenter=dc1"] = metrics.GaugeValue{
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: 7,
Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.service_instances;datacenter=dc1"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.services;datacenter=dc1"] = metrics.GaugeValue{
Name: "consul.usage.test.state.services",
Value: 7,
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: 9,
Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-proxy"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.service_instances;datacenter=dc1"] = metrics.GaugeValue{
Name: "consul.usage.test.state.service_instances",
Value: 9,
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{
@ -599,7 +944,15 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "connect-proxy"},
},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=terminating-gateway"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-proxy"] = metrics.GaugeValue{
Name: "consul.usage.test.state.connect_instances",
Value: 1,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -607,7 +960,15 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "terminating-gateway"},
},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=terminating-gateway"] = metrics.GaugeValue{
Name: "consul.usage.test.state.connect_instances",
Value: 1,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -615,7 +976,15 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "ingress-gateway"},
},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=mesh-gateway"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{
Name: "consul.usage.test.state.connect_instances",
Value: 1,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "ingress-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{
@ -623,7 +992,15 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "mesh-gateway"},
},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.connect_instances;datacenter=dc1;kind=connect-native"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=mesh-gateway"] = metrics.GaugeValue{
Name: "consul.usage.test.state.connect_instances",
Value: 1,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{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{
@ -631,7 +1008,15 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{Name: "kind", Value: "connect-native"},
},
}
nodesAndSvcsCase.expectedGauges["consul.usage.test.consul.state.config_entries;datacenter=dc1;kind=ingress-gateway"] = metrics.GaugeValue{
nodesAndSvcsCase.expectedGauges["consul.usage.test.state.connect_instances;datacenter=dc1;kind=connect-native"] = metrics.GaugeValue{
Name: "consul.usage.test.state.connect_instances",
Value: 1,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "connect-native"},
},
}
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{
@ -639,6 +1024,14 @@ func TestUsageReporter_emitServiceUsage_OSS(t *testing.T) {
{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,
Labels: []metrics.Label{
{Name: "datacenter", Value: "dc1"},
{Name: "kind", Value: "ingress-gateway"},
},
}
cases["nodes-and-services"] = nodesAndSvcsCase
delete(cases, "nodes")
@ -700,11 +1093,16 @@ func TestUsageReporter_emitKVUsage_OSS(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{
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,
Labels: []metrics.Label{{Name: "datacenter", Value: "dc1"}},
}
cases["nodes"] = nodesCase
for name, tcase := range cases {