Merge pull request #1953 from prometheus/superq/fix_network_route
Fix network_route collector naming
This commit is contained in:
commit
a2b556a0ce
|
@ -27,9 +27,9 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type networkRouteCollector struct {
|
type networkRouteCollector struct {
|
||||||
routeDesc *prometheus.Desc
|
routeInfoDesc *prometheus.Desc
|
||||||
routesTotalDesc *prometheus.Desc
|
routesDesc *prometheus.Desc
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -40,19 +40,19 @@ func init() {
|
||||||
func NewNetworkRouteCollector(logger log.Logger) (Collector, error) {
|
func NewNetworkRouteCollector(logger log.Logger) (Collector, error) {
|
||||||
const subsystem = "network"
|
const subsystem = "network"
|
||||||
|
|
||||||
routeDesc := prometheus.NewDesc(
|
routeInfoDesc := prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, subsystem, "route"),
|
prometheus.BuildFQName(namespace, subsystem, "route_info"),
|
||||||
"network routing table", []string{"if", "src", "dest", "gw", "priority", "proto", "weight"}, nil,
|
"network routing table information", []string{"device", "src", "dest", "gw", "priority", "proto", "weight"}, nil,
|
||||||
)
|
)
|
||||||
routeTotalDesc := prometheus.NewDesc(
|
routesDesc := prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(namespace, subsystem, "routes_total"),
|
prometheus.BuildFQName(namespace, subsystem, "routes"),
|
||||||
"network total routes", []string{"if"}, nil,
|
"network routes by interface", []string{"device"}, nil,
|
||||||
)
|
)
|
||||||
|
|
||||||
return &networkRouteCollector{
|
return &networkRouteCollector{
|
||||||
routeDesc: routeDesc,
|
routeInfoDesc: routeInfoDesc,
|
||||||
routesTotalDesc: routeTotalDesc,
|
routesDesc: routesDesc,
|
||||||
logger: logger,
|
logger: logger,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ func (n networkRouteCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
networkRouteProtocolToString(route.Protocol), // proto
|
networkRouteProtocolToString(route.Protocol), // proto
|
||||||
strconv.Itoa(int(nextHop.Hop.Hops) + 1), // weight
|
strconv.Itoa(int(nextHop.Hop.Hops) + 1), // weight
|
||||||
}
|
}
|
||||||
ch <- prometheus.MustNewConstMetric(n.routeDesc, prometheus.GaugeValue, 1, labels...)
|
ch <- prometheus.MustNewConstMetric(n.routeInfoDesc, prometheus.GaugeValue, 1, labels...)
|
||||||
deviceRoutes[ifName]++
|
deviceRoutes[ifName]++
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -119,13 +119,13 @@ func (n networkRouteCollector) Update(ch chan<- prometheus.Metric) error {
|
||||||
networkRouteProtocolToString(route.Protocol), // proto
|
networkRouteProtocolToString(route.Protocol), // proto
|
||||||
"", // weight
|
"", // weight
|
||||||
}
|
}
|
||||||
ch <- prometheus.MustNewConstMetric(n.routeDesc, prometheus.GaugeValue, 1, labels...)
|
ch <- prometheus.MustNewConstMetric(n.routeInfoDesc, prometheus.GaugeValue, 1, labels...)
|
||||||
deviceRoutes[ifName]++
|
deviceRoutes[ifName]++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for dev, total := range deviceRoutes {
|
for dev, total := range deviceRoutes {
|
||||||
ch <- prometheus.MustNewConstMetric(n.routesTotalDesc, prometheus.GaugeValue, float64(total), dev)
|
ch <- prometheus.MustNewConstMetric(n.routesDesc, prometheus.GaugeValue, float64(total), dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in New Issue