diff --git a/prog/weaver/http.go b/prog/weaver/http.go index ed628033..1d87255e 100644 --- a/prog/weaver/http.go +++ b/prog/weaver/http.go @@ -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) diff --git a/prog/weaver/metrics.go b/prog/weaver/metrics.go index 4f6a5a64..296dd620 100644 --- a/prog/weaver/metrics.go +++ b/prog/weaver/metrics.go @@ -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."),