prometheus: export count of unreachable peers (#3119)
* prometheus: export count of unreachable peers * extracted part of printIPAMRanges
This commit is contained in:
1 parent
a362bf68bb
commit
ab1cbcbbf8
3 files changed
+31
-17
No files matched your search
+20
-17
@@ -34,23 +34,7 @@ var rootTemplate = template.New("root").Funcs(map[string]interface{}{
|
|||||||
},
|
},
|
||||||
"printIPAMRanges": func(router weave.NetworkRouterStatus, status ipam.Status) string {
|
"printIPAMRanges": func(router weave.NetworkRouterStatus, status ipam.Status) string {
|
||||||
var buffer bytes.Buffer
|
var buffer bytes.Buffer
|
||||||
|
peerStats := summariseIpamStats(&status)
|
||||||
type stats struct {
|
|
||||||
ips uint32
|
|
||||||
nickname string
|
|
||||||
reachable bool
|
|
||||||
}
|
|
||||||
|
|
||||||
peerStats := make(map[string]*stats)
|
|
||||||
|
|
||||||
for _, entry := range status.Entries {
|
|
||||||
s, found := peerStats[entry.Peer]
|
|
||||||
if !found {
|
|
||||||
s = &stats{nickname: entry.Nickname, reachable: entry.IsKnownPeer}
|
|
||||||
peerStats[entry.Peer] = s
|
|
||||||
}
|
|
||||||
s.ips += entry.Size
|
|
||||||
}
|
|
||||||
|
|
||||||
printOwned := func(name string, nickName string, info string, ips uint32) {
|
printOwned := func(name string, nickName string, info string, ips uint32) {
|
||||||
percentageRanges := float32(ips) * 100.0 / float32(status.RangeNumIPs)
|
percentageRanges := float32(ips) * 100.0 / float32(status.RangeNumIPs)
|
||||||
@@ -116,6 +100,25 @@ var rootTemplate = template.New("root").Funcs(map[string]interface{}{
|
|||||||
"trimSuffix": strings.TrimSuffix,
|
"trimSuffix": strings.TrimSuffix,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
type ipamStats struct {
|
||||||
|
ips uint32
|
||||||
|
nickname string
|
||||||
|
reachable bool
|
||||||
|
}
|
||||||
|
|
||||||
|
func summariseIpamStats(status *ipam.Status) map[string]*ipamStats {
|
||||||
|
peerStats := make(map[string]*ipamStats)
|
||||||
|
for _, entry := range status.Entries {
|
||||||
|
s, found := peerStats[entry.Peer]
|
||||||
|
if !found {
|
||||||
|
s = &ipamStats{nickname: entry.Nickname, reachable: entry.IsKnownPeer}
|
||||||
|
peerStats[entry.Peer] = s
|
||||||
|
}
|
||||||
|
s.ips += entry.Size
|
||||||
|
}
|
||||||
|
return peerStats
|
||||||
|
}
|
||||||
|
|
||||||
func countDNSEntries(entries []nameserver.EntryStatus) int {
|
func countDNSEntries(entries []nameserver.EntryStatus) int {
|
||||||
count := 0
|
count := 0
|
||||||
for _, entry := range entries {
|
for _, entry := range entries {
|
||||||
|
|||||||
@@ -82,6 +82,16 @@ var metrics = []metric{
|
|||||||
ch <- intGauge(desc, metrics.Flows)
|
ch <- intGauge(desc, metrics.Flows)
|
||||||
}
|
}
|
||||||
}},
|
}},
|
||||||
|
{desc("weave_ipam_unreachable_count", "Number of unreachable peers."),
|
||||||
|
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
|
||||||
|
var count int
|
||||||
|
for _, entry := range summariseIpamStats(s.IPAM) {
|
||||||
|
if !entry.reachable {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ch <- intGauge(desc, count)
|
||||||
|
}},
|
||||||
{desc("weave_ipam_pending_allocates", "Number of pending allocates."),
|
{desc("weave_ipam_pending_allocates", "Number of pending allocates."),
|
||||||
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
|
func(s WeaveStatus, desc *prometheus.Desc, ch chan<- prometheus.Metric) {
|
||||||
if s.IPAM != nil {
|
if s.IPAM != nil {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ exposed:
|
|||||||
* `weave_max_ips` - Size of IP address space used by allocator.
|
* `weave_max_ips` - Size of IP address space used by allocator.
|
||||||
* `weave_dns_entries` - Number of DNS entries.
|
* `weave_dns_entries` - Number of DNS entries.
|
||||||
* `weave_flows` - Number of FastDP flows.
|
* `weave_flows` - Number of FastDP flows.
|
||||||
|
* `weave_ipam_unreachable_coun` - Number of unreachable peers.
|
||||||
* `weave_ipam_pending_allocates` - Number of pending allocates.
|
* `weave_ipam_pending_allocates` - Number of pending allocates.
|
||||||
* `weave_ipam_pending_claims` - Number of pending claims.
|
* `weave_ipam_pending_claims` - Number of pending claims.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user