From b486c1bce863f7079a4ab3a43925b07e172402fc Mon Sep 17 00:00:00 2001 From: Kit Patella Date: Fri, 13 Nov 2020 13:18:04 -0800 Subject: [PATCH] add the service name in the agent rather than in the definitions themselves --- agent/catalog_endpoint.go | 56 +++++++++++------------ agent/consul/acl.go | 10 ++-- agent/consul/acl_endpoint.go | 32 ++++++------- agent/consul/autopilot.go | 4 +- agent/consul/catalog_endpoint.go | 20 ++++---- agent/consul/client.go | 6 +-- agent/consul/config_endpoint.go | 12 ++--- agent/consul/federation_state_endpoint.go | 8 ++-- agent/consul/intention_endpoint.go | 5 +- agent/consul/kvs_endpoint.go | 2 +- agent/consul/prepared_query_endpoint.go | 8 ++-- agent/consul/rpc.go | 16 +++---- agent/consul/session_ttl.go | 8 ++-- agent/consul/txn_endpoint.go | 4 +- agent/consul/usagemetrics/usagemetrics.go | 6 +-- agent/grpc/stats.go | 16 +++---- agent/http.go | 2 +- agent/local/state.go | 10 ++-- agent/setup.go | 35 ++++++++++---- 19 files changed, 141 insertions(+), 119 deletions(-) diff --git a/agent/catalog_endpoint.go b/agent/catalog_endpoint.go index 7e0ee9571..df78384ea 100644 --- a/agent/catalog_endpoint.go +++ b/agent/catalog_endpoint.go @@ -14,115 +14,115 @@ import ( // TODO(kit): Add help strings for each var CatalogCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "client", "api", "catalog_register"}, + Name: []string{"client", "api", "catalog_register"}, Help: "Increments whenever a Consul agent receives a catalog register request.", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_register"}, + Name: []string{"client", "rpc", "error", "catalog_register"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_register"}, + Name: []string{"client", "api", "success", "catalog_register"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_deregister"}, + Name: []string{"client", "api", "catalog_deregister"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_datacenters"}, + Name: []string{"client", "api", "catalog_datacenters"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_deregister"}, + Name: []string{"client", "rpc", "error", "catalog_deregister"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_nodes"}, + Name: []string{"client", "api", "success", "catalog_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_nodes"}, + Name: []string{"client", "rpc", "error", "catalog_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_deregister"}, + Name: []string{"client", "api", "success", "catalog_deregister"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_datacenters"}, + Name: []string{"client", "rpc", "error", "catalog_datacenters"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_datacenters"}, + Name: []string{"client", "api", "success", "catalog_datacenters"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_nodes"}, + Name: []string{"client", "api", "catalog_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_services"}, + Name: []string{"client", "api", "catalog_services"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_services"}, + Name: []string{"client", "rpc", "error", "catalog_services"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_services"}, + Name: []string{"client", "api", "success", "catalog_services"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_service_nodes"}, + Name: []string{"client", "api", "catalog_service_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_service_nodes"}, + Name: []string{"client", "rpc", "error", "catalog_service_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_service_nodes"}, + Name: []string{"client", "api", "success", "catalog_service_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "api", "error", "catalog_service_nodes"}, + Name: []string{"client", "api", "error", "catalog_service_nodes"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_node_services"}, + Name: []string{"client", "api", "catalog_node_services"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_node_services"}, + Name: []string{"client", "api", "success", "catalog_node_services"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_node_services"}, + Name: []string{"client", "rpc", "error", "catalog_node_services"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_node_service_list"}, + Name: []string{"client", "api", "catalog_node_service_list"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_node_service_list"}, + Name: []string{"client", "rpc", "error", "catalog_node_service_list"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_node_service_list"}, + Name: []string{"client", "api", "success", "catalog_node_service_list"}, Help: "", }, { - Name: []string{"consul", "client", "api", "catalog_gateway_services"}, + Name: []string{"client", "api", "catalog_gateway_services"}, Help: "", }, { - Name: []string{"consul", "client", "rpc", "error", "catalog_gateway_services"}, + Name: []string{"client", "rpc", "error", "catalog_gateway_services"}, Help: "", }, { - Name: []string{"consul", "client", "api", "success", "catalog_gateway_services"}, + Name: []string{"client", "api", "success", "catalog_gateway_services"}, Help: "", }, } diff --git a/agent/consul/acl.go b/agent/consul/acl.go index d99b588e4..1ec7bc419 100644 --- a/agent/consul/acl.go +++ b/agent/consul/acl.go @@ -18,26 +18,26 @@ import ( var ACLCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "acl", "token", "cache_hit"}, + Name: []string{"acl", "token", "cache_hit"}, Help: "", }, { - Name: []string{"consul", "acl", "token", "cache_miss"}, + Name: []string{"acl", "token", "cache_miss"}, Help: "", }, } var ACLSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "acl", "resolveTokenLegacy"}, + Name: []string{"acl", "resolveTokenLegacy"}, Help: "", }, { - Name: []string{"consul", "acl", "ResolveToken"}, + Name: []string{"acl", "ResolveToken"}, Help: "", }, { - Name: []string{"consul", "acl", "ResolveTokenToIdentity"}, + Name: []string{"acl", "ResolveTokenToIdentity"}, Help: "", }, } diff --git a/agent/consul/acl_endpoint.go b/agent/consul/acl_endpoint.go index 10c879467..b8ba08e0b 100644 --- a/agent/consul/acl_endpoint.go +++ b/agent/consul/acl_endpoint.go @@ -33,67 +33,67 @@ const ( var ACLEndpointSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "acl", "token", "clone"}, + Name: []string{"acl", "token", "clone"}, Help: "", }, { - Name: []string{"consul", "acl", "token", "upsert"}, + Name: []string{"acl", "token", "upsert"}, Help: "", }, { - Name: []string{"consul", "acl", "token", "delete"}, + Name: []string{"acl", "token", "delete"}, Help: "", }, { - Name: []string{"consul", "acl", "policy", "upsert"}, + Name: []string{"acl", "policy", "upsert"}, Help: "", }, { - Name: []string{"consul", "acl", "policy", "delete"}, + Name: []string{"acl", "policy", "delete"}, Help: "", }, { - Name: []string{"consul", "acl", "policy", "delete"}, + Name: []string{"acl", "policy", "delete"}, Help: "", }, { - Name: []string{"consul", "acl", "role", "upsert"}, + Name: []string{"acl", "role", "upsert"}, Help: "", }, { - Name: []string{"consul", "acl", "role", "delete"}, + Name: []string{"acl", "role", "delete"}, Help: "", }, { - Name: []string{"consul", "acl", "bindingrule", "upsert"}, + Name: []string{"acl", "bindingrule", "upsert"}, Help: "", }, { - Name: []string{"consul", "acl", "bindingrule", "delete"}, + Name: []string{"acl", "bindingrule", "delete"}, Help: "", }, { - Name: []string{"consul", "acl", "authmethod", "upsert"}, + Name: []string{"acl", "authmethod", "upsert"}, Help: "", }, { - Name: []string{"consul", "acl", "authmethod", "delete"}, + Name: []string{"acl", "authmethod", "delete"}, Help: "", }, { - Name: []string{"consul", "acl", "login"}, + Name: []string{"acl", "login"}, Help: "", }, { - Name: []string{"consul", "acl", "login"}, + Name: []string{"acl", "login"}, Help: "", }, { - Name: []string{"consul", "acl", "logout"}, + Name: []string{"acl", "logout"}, Help: "", }, { - Name: []string{"consul", "acl", "logout"}, + Name: []string{"acl", "logout"}, Help: "", }, } diff --git a/agent/consul/autopilot.go b/agent/consul/autopilot.go index 7bd8bc258..22f50259c 100644 --- a/agent/consul/autopilot.go +++ b/agent/consul/autopilot.go @@ -15,11 +15,11 @@ import ( var AutopilotGauges = []prometheus.GaugeDefinition{ { - Name: []string{"consul", "autopilot", "failure_tolerance"}, + Name: []string{"autopilot", "failure_tolerance"}, Help: "", }, { - Name: []string{"consul", "autopilot", "healthy"}, + Name: []string{"autopilot", "healthy"}, Help: "This tracks the overall health of the local server cluster. 1 if all servers are healthy, 0 if one or more are unhealthy.", }, } diff --git a/agent/consul/catalog_endpoint.go b/agent/consul/catalog_endpoint.go index f8b41c97d..151367cf4 100644 --- a/agent/consul/catalog_endpoint.go +++ b/agent/consul/catalog_endpoint.go @@ -20,46 +20,46 @@ import ( var CatalogCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "catalog", "service", "query"}, + Name: []string{"catalog", "service", "query"}, Help: "", }, { - Name: []string{"consul", "catalog", "connect", "query"}, + Name: []string{"catalog", "connect", "query"}, Help: "", }, { - Name: []string{"consul", "catalog", "service", "query-tag"}, + Name: []string{"catalog", "service", "query-tag"}, Help: "", }, { - Name: []string{"consul", "catalog", "connect", "query-tag"}, + Name: []string{"catalog", "connect", "query-tag"}, Help: "", }, { - Name: []string{"consul", "catalog", "service", "query-tags"}, + Name: []string{"catalog", "service", "query-tags"}, Help: "", }, { - Name: []string{"consul", "catalog", "connect", "query-tags"}, + Name: []string{"catalog", "connect", "query-tags"}, Help: "", }, { - Name: []string{"consul", "catalog", "service", "not-found"}, + Name: []string{"catalog", "service", "not-found"}, Help: "", }, { - Name: []string{"consul", "catalog", "connect", "not-found"}, + Name: []string{"catalog", "connect", "not-found"}, Help: "", }, } var CatalogSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "catalog", "deregister"}, + Name: []string{"catalog", "deregister"}, Help: "", }, { - Name: []string{"consul", "catalog", "register"}, + Name: []string{"catalog", "register"}, Help: "", }, } diff --git a/agent/consul/client.go b/agent/consul/client.go index 6f20d6a02..d2ae9a1ed 100644 --- a/agent/consul/client.go +++ b/agent/consul/client.go @@ -24,15 +24,15 @@ import ( var ClientCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "client", "rpc"}, + Name: []string{"client", "rpc"}, Help: "Increments whenever a Consul agent in client mode makes an RPC request to a Consul server.", }, { - Name: []string{"consul", "client", "rpc", "exceeded"}, + Name: []string{"client", "rpc", "exceeded"}, Help: "Increments whenever a Consul agent in client mode makes an RPC request to a Consul server gets rate limited by that agent's limits configuration.", }, { - Name: []string{"consul", "client", "rpc", "failed"}, + Name: []string{"client", "rpc", "failed"}, Help: "Increments whenever a Consul agent in client mode makes an RPC request to a Consul server and fails.", }, } diff --git a/agent/consul/config_endpoint.go b/agent/consul/config_endpoint.go index 41cf16dc2..96e43e5c4 100644 --- a/agent/consul/config_endpoint.go +++ b/agent/consul/config_endpoint.go @@ -16,27 +16,27 @@ import ( var ConfigSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "config_entry", "apply"}, + Name: []string{"config_entry", "apply"}, Help: "", }, { - Name: []string{"consul", "config_entry", "get"}, + Name: []string{"config_entry", "get"}, Help: "", }, { - Name: []string{"consul", "config_entry", "list"}, + Name: []string{"config_entry", "list"}, Help: "", }, { - Name: []string{"consul", "config_entry", "listAll"}, + Name: []string{"config_entry", "listAll"}, Help: "", }, { - Name: []string{"consul", "config_entry", "delete"}, + Name: []string{"config_entry", "delete"}, Help: "", }, { - Name: []string{"consul", "config_entry", "resolve_service_config"}, + Name: []string{"config_entry", "resolve_service_config"}, Help: "", }, } diff --git a/agent/consul/federation_state_endpoint.go b/agent/consul/federation_state_endpoint.go index 2a71ed3f8..88111364c 100644 --- a/agent/consul/federation_state_endpoint.go +++ b/agent/consul/federation_state_endpoint.go @@ -15,19 +15,19 @@ import ( var FederationStateSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "federation_state", "apply"}, + Name: []string{"federation_state", "apply"}, Help: "", }, { - Name: []string{"consul", "federation_state", "get"}, + Name: []string{"federation_state", "get"}, Help: "", }, { - Name: []string{"consul", "federation_state", "list"}, + Name: []string{"federation_state", "list"}, Help: "", }, { - Name: []string{"consul", "federation_state", "list_mesh_gateways"}, + Name: []string{"federation_state", "list_mesh_gateways"}, Help: "", }, } diff --git a/agent/consul/intention_endpoint.go b/agent/consul/intention_endpoint.go index 592ba3492..ca93239dc 100644 --- a/agent/consul/intention_endpoint.go +++ b/agent/consul/intention_endpoint.go @@ -22,6 +22,10 @@ var IntentionSummaries = []prometheus.SummaryDefinition{ Name: []string{"consul", "intention", "apply"}, Help: "", }, + { + Name: []string{"intention", "apply"}, + Help: "", + }, } var ( @@ -260,7 +264,6 @@ func (s *Intention) Apply( if done, err := s.srv.ForwardRPC("Intention.Apply", args, args, reply); done { return err } - // TODO(Kit): Why do we have summaries for intentions both with and without the consul namespace? defer metrics.MeasureSince([]string{"consul", "intention", "apply"}, time.Now()) defer metrics.MeasureSince([]string{"intention", "apply"}, time.Now()) diff --git a/agent/consul/kvs_endpoint.go b/agent/consul/kvs_endpoint.go index 8ded7366a..400397fca 100644 --- a/agent/consul/kvs_endpoint.go +++ b/agent/consul/kvs_endpoint.go @@ -17,7 +17,7 @@ import ( var KVSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "kvs", "apply"}, + Name: []string{"kvs", "apply"}, Help: "This measures the time it takes to complete an update to the KV store.", }, } diff --git a/agent/consul/prepared_query_endpoint.go b/agent/consul/prepared_query_endpoint.go index df484b2af..d796c6f6c 100644 --- a/agent/consul/prepared_query_endpoint.go +++ b/agent/consul/prepared_query_endpoint.go @@ -18,19 +18,19 @@ import ( var PreparedQuerySummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "prepared-query", "apply"}, + Name: []string{"prepared-query", "apply"}, Help: "", }, { - Name: []string{"consul", "prepared-query", "explain"}, + Name: []string{"prepared-query", "explain"}, Help: "", }, { - Name: []string{"consul", "prepared-query", "execute"}, + Name: []string{"prepared-query", "execute"}, Help: "", }, { - Name: []string{"consul", "prepared-query", "execute_remote"}, + Name: []string{"prepared-query", "execute_remote"}, Help: "", }, } diff --git a/agent/consul/rpc.go b/agent/consul/rpc.go index 58e7e8210..775d311bd 100644 --- a/agent/consul/rpc.go +++ b/agent/consul/rpc.go @@ -34,41 +34,41 @@ import ( var RPCCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "rpc", "accept_conn"}, + Name: []string{"rpc", "accept_conn"}, Help: "", }, { - Name: []string{"consul", "rpc", "raft_handoff"}, + Name: []string{"rpc", "raft_handoff"}, Help: "", }, { - Name: []string{"consul", "rpc", "request_error"}, + Name: []string{"rpc", "request_error"}, Help: "", }, { - Name: []string{"consul", "rpc", "request"}, + Name: []string{"rpc", "request"}, Help: "", }, { - Name: []string{"consul", "rpc", "cross-dc"}, + Name: []string{"rpc", "cross-dc"}, Help: "", }, { - Name: []string{"consul", "rpc", "query"}, + Name: []string{"rpc", "query"}, Help: "", }, } var RPCGauges = []prometheus.GaugeDefinition{ { - Name: []string{"consul", "rpc", "queries_blocking"}, + Name: []string{"rpc", "queries_blocking"}, Help: "", }, } var RPCSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "rpc", "consistentRead"}, + Name: []string{"rpc", "consistentRead"}, Help: "", }, } diff --git a/agent/consul/session_ttl.go b/agent/consul/session_ttl.go index db4447c50..7387e42a9 100644 --- a/agent/consul/session_ttl.go +++ b/agent/consul/session_ttl.go @@ -12,22 +12,22 @@ import ( var SessionGauges = []prometheus.GaugeDefinition{ { - Name: []string{"consul", "session_ttl", "active"}, + Name: []string{"session_ttl", "active"}, Help: "", }, { - Name: []string{"consul", "raft", "applied_index"}, + Name: []string{"raft", "applied_index"}, Help: "", }, { - Name: []string{"consul", "raft", "last_index"}, + Name: []string{"raft", "last_index"}, Help: "", }, } var SessionSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "session_ttl", "invalidate"}, + Name: []string{"session_ttl", "invalidate"}, Help: "", }, } diff --git a/agent/consul/txn_endpoint.go b/agent/consul/txn_endpoint.go index 42539a991..50a57f9e1 100644 --- a/agent/consul/txn_endpoint.go +++ b/agent/consul/txn_endpoint.go @@ -14,11 +14,11 @@ import ( var TxnSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "txn", "apply"}, + Name: []string{"txn", "apply"}, Help: "This measures the time spent applying a transaction operation.", }, { - Name: []string{"consul", "txn", "read"}, + Name: []string{"txn", "read"}, Help: "", }, } diff --git a/agent/consul/usagemetrics/usagemetrics.go b/agent/consul/usagemetrics/usagemetrics.go index fc8d9ce90..7f2207fa6 100644 --- a/agent/consul/usagemetrics/usagemetrics.go +++ b/agent/consul/usagemetrics/usagemetrics.go @@ -15,15 +15,15 @@ import ( var Gauges = []prometheus.GaugeDefinition{ { - Name: []string{"consul", "state", "nodes"}, + Name: []string{"state", "nodes"}, Help: "", }, { - Name: []string{"consul", "state", "services"}, + Name: []string{"state", "services"}, Help: "", }, { - Name: []string{"consul", "state", "service_instances"}, + Name: []string{"state", "service_instances"}, Help: "", }, } diff --git a/agent/grpc/stats.go b/agent/grpc/stats.go index 7f732316f..b1a0c5a23 100644 --- a/agent/grpc/stats.go +++ b/agent/grpc/stats.go @@ -13,37 +13,37 @@ import ( var defaultMetrics = metrics.Default() var StatsGauges = []prometheus.GaugeDefinition{ { - Name: []string{"consul", "grpc", "server", "connections"}, + Name: []string{"grpc", "server", "connections"}, Help: "", }, { - Name: []string{"consul", "grpc", "client", "connections"}, + Name: []string{"grpc", "client", "connections"}, Help: "", }, { - Name: []string{"consul", "grpc", "server", "streams"}, + Name: []string{"grpc", "server", "streams"}, Help: "", }, } var StatsCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "grpc", "client", "request", "count"}, + Name: []string{"grpc", "client", "request", "count"}, Help: "", }, { - Name: []string{"consul", "grpc", "server", "request", "count"}, + Name: []string{"grpc", "server", "request", "count"}, Help: "", }, { - Name: []string{"consul", "grpc", "client", "connection", "count"}, + Name: []string{"grpc", "client", "connection", "count"}, Help: "", }, { - Name: []string{"consul", "grpc", "server", "connection", "count"}, + Name: []string{"grpc", "server", "connection", "count"}, Help: "", }, { - Name: []string{"consul", "grpc", "server", "stream", "count"}, + Name: []string{"grpc", "server", "stream", "count"}, Help: "", }, } diff --git a/agent/http.go b/agent/http.go index 244b9522b..9b5fcf5e3 100644 --- a/agent/http.go +++ b/agent/http.go @@ -34,7 +34,7 @@ import ( var HTTPSummaries = []prometheus.SummaryDefinition{ { - Name: []string{"consul", "api", "http"}, + Name: []string{"api", "http"}, Help: "", }, } diff --git a/agent/local/state.go b/agent/local/state.go index d145f97d0..5ca827607 100644 --- a/agent/local/state.go +++ b/agent/local/state.go @@ -22,23 +22,23 @@ import ( var StateCounters = []prometheus.CounterDefinition{ { - Name: []string{"consul", "acl", "blocked", "service", "deregistration"}, + Name: []string{"acl", "blocked", "service", "deregistration"}, Help: "", }, { - Name: []string{"consul", "acl", "blocked", "check", "deregistration"}, + Name: []string{"acl", "blocked", "check", "deregistration"}, Help: "", }, { - Name: []string{"consul", "acl", "blocked", "service", "registration"}, + Name: []string{"acl", "blocked", "service", "registration"}, Help: "", }, { - Name: []string{"consul", "acl", "blocked", "check", "registration"}, + Name: []string{"acl", "blocked", "check", "registration"}, Help: "", }, { - Name: []string{"consul", "acl", "blocked", "node", "registration"}, + Name: []string{"acl", "blocked", "node", "registration"}, Help: "", }, } diff --git a/agent/setup.go b/agent/setup.go index 4297a3089..c3f4dbf08 100644 --- a/agent/setup.go +++ b/agent/setup.go @@ -185,6 +185,7 @@ func registerWithGRPC(b grpcresolver.Builder) { // getPrometheusDefs reaches into every slice of prometheus defs we've defined in each part of the agent, and appends // all of our slices into one nice slice of definitions per metric type for the Consul agent to pass to go-metrics. func getPrometheusDefs() lib.PrometheusDefs { + serviceName := []string{"consul"} var gauges = [][]prometheus.GaugeDefinition{ consul.AutopilotGauges, consul.RPCGauges, @@ -194,7 +195,13 @@ func getPrometheusDefs() lib.PrometheusDefs { } var gaugeDefs []prometheus.GaugeDefinition for _, g := range gauges { - gaugeDefs = append(gaugeDefs, g...) + // Set Consul to each definition's namespace + var withService []prometheus.GaugeDefinition + for _, gauge := range g { + gauge.Name = append(serviceName, gauge.Name...) + withService = append(withService, gauge) + } + gaugeDefs = append(gaugeDefs, withService...) } raftCounters := []prometheus.CounterDefinition{ @@ -202,15 +209,15 @@ func getPrometheusDefs() lib.PrometheusDefs { // package within. In the mean time, we're going to define them here because it's important that they're always // present for Consul users setting up dashboards. { - Name: []string{"consul", "raft", "apply"}, + Name: []string{"raft", "apply"}, Help: "This counts the number of Raft transactions occurring over the interval.", }, { - Name: []string{"consul", "raft", "state", "candidate"}, + Name: []string{"raft", "state", "candidate"}, Help: "This increments whenever a Consul server starts an election.", }, { - Name: []string{"consul", "raft", "state", "leader"}, + Name: []string{"raft", "state", "leader"}, Help: "This increments whenever a Consul server becomes a leader.", }, } @@ -227,7 +234,13 @@ func getPrometheusDefs() lib.PrometheusDefs { } var counterDefs []prometheus.CounterDefinition for _, c := range counters { - counterDefs = append(counterDefs, c...) + // Set Consul to each definition's namespace + var withService []prometheus.CounterDefinition + for _, counter := range c { + counter.Name = append(serviceName, counter.Name...) + withService = append(withService, counter) + } + counterDefs = append(counterDefs, withService...) } raftSummaries := []prometheus.SummaryDefinition{ @@ -235,11 +248,11 @@ func getPrometheusDefs() lib.PrometheusDefs { // package within. In the mean time, we're going to define them here because it's important that they're always // present for Consul users setting up dashboards. { - Name: []string{"consul", "raft", "commitTime"}, + Name: []string{"raft", "commitTime"}, Help: "This measures the time it takes to commit a new entry to the Raft log on the leader.", }, { - Name: []string{"consul", "raft", "leader", "lastContact"}, + Name: []string{"raft", "leader", "lastContact"}, Help: "Measures the time since the leader was last able to contact the follower nodes when checking its leader lease.", }, } @@ -260,7 +273,13 @@ func getPrometheusDefs() lib.PrometheusDefs { } var summaryDefs []prometheus.SummaryDefinition for _, s := range summaries { - summaryDefs = append(summaryDefs, s...) + // Set Consul to each definition's namespace + var withService []prometheus.SummaryDefinition + for _, summary := range s { + summary.Name = append(serviceName, summary.Name...) + withService = append(withService, summary) + } + summaryDefs = append(summaryDefs, withService...) } return lib.PrometheusDefs{