Merge pull request #2579 from weaveworks/issues/2557-improve-metric-naming

Improve metric naming
This commit is contained in:
Martynas Pumputis authored and GitHub committed 2016-11-02 11:02:23 +00:00
commit ec5f7033a4
2 files changed
+16 -12

No files matched your search

+3 -1
View File
@@ -19,6 +19,8 @@ import (
weave "github.com/weaveworks/weave/router"
)
var allConnectionStates = []string{"established", "pending", "retrying", "failed", "connecting"}
var rootTemplate = template.New("root").Funcs(map[string]interface{}{
"countDNSEntries": countDNSEntries,
"printList": func(list []string) string {
@@ -87,7 +89,7 @@ var rootTemplate = template.New("root").Funcs(map[string]interface{}{
for _, conn := range conns {
counts[conn.State]++
}
return printCounts(counts, []string{"established", "pending", "retrying", "failed", "connecting"})
return printCounts(counts, allConnectionStates)
},
"printPeerConnectionCounts": func(peers []mesh.PeerStatus) string {
counts := make(map[string]int)
+13 -11
View File
@@ -46,15 +46,13 @@ func uint64Counter(desc *prometheus.Desc, val uint64, labels ...string) promethe
var metrics []metric = []metric{
{desc("weave_connections", "Number of peer-to-peer connections.", "state"),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
established := 0
counts := make(map[string]int)
for _, conn := range s.Router.Connections {
if conn.State == "established" {
established++
}
counts[conn.State]++
}
for _, state := range allConnectionStates {
ch <- intGauge(desc, counts[state], state)
}
ch <- intGauge(desc, len(s.Router.Connections)-established, "non-established")
ch <- intGauge(desc, established, "established")
}},
{desc("weave_connection_terminations_total", "Number of peer-to-peer connections terminated."),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
@@ -63,15 +61,19 @@ var metrics []metric = []metric{
{desc("weave_ips", "Number of IP addresses.", "state"),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
if s.IPAM != nil {
ch <- intGauge(desc, s.IPAM.RangeNumIPs, "total")
ch <- intGauge(desc, s.IPAM.ActiveIPs, "local-used")
}
}},
{desc("weave_dns_entries", "Number of DNS entries.", "state"),
{desc("weave_max_ips", "Size of IP address space used by allocator."),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
if s.IPAM != nil {
ch <- intGauge(desc, s.IPAM.RangeNumIPs)
}
}},
{desc("weave_dns_entries", "Number of DNS entries."),
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
if s.DNS != nil {
ch <- intGauge(desc, countDNSEntries(s.DNS.Entries), "total")
ch <- intGauge(desc, countDNSEntriesForPeer(s.Router.Name, s.DNS.Entries), "local")
ch <- intGauge(desc, countDNSEntriesForPeer(s.Router.Name, s.DNS.Entries))
}
}},
{desc("weave_flows", "Number of FastDP flows."),