add the service name in the agent rather than in the definitions themselves

This commit is contained in:
Kit Patella 2020-11-13 13:18:04 -08:00
parent 9533372ded
commit b486c1bce8
19 changed files with 141 additions and 119 deletions

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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.",
},
}

View File

@ -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: "",
},
}

View File

@ -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.",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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())

View File

@ -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.",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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: "",
},
}

View File

@ -34,7 +34,7 @@ import (
var HTTPSummaries = []prometheus.SummaryDefinition{
{
Name: []string{"consul", "api", "http"},
Name: []string{"api", "http"},
Help: "",
},
}

View File

@ -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: "",
},
}

View File

@ -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{