Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

Commit

Permalink
add vrf_name label to rib metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
greenpau committed Feb 26, 2020
1 parent d826048 commit 38ebe31
Show file tree
Hide file tree
Showing 7 changed files with 170 additions and 145 deletions.
246 changes: 123 additions & 123 deletions README.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-farm v0.0.0-20171119141306-ac7624ea8da3/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/eapache/channels v1.1.0/go.mod h1:jMm2qB5Ubtg9zLd+inMZd2/NUvXgzmWXsDaLyQIGfH0=
github.com/eapache/queue v1.0.2/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
Expand Down
3 changes: 3 additions & 0 deletions pkg/gobgp_exporter/collect_rib.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (n *RouterNode) GetRibCounters() {
float64(serverResponse.GetNumDestination()),
strings.ToLower(tableTypeName),
strings.ToLower(addressFamilyName),
"default",
))

n.metrics = append(n.metrics, prometheus.MustNewConstMetric(
Expand All @@ -138,6 +139,7 @@ func (n *RouterNode) GetRibCounters() {
float64(serverResponse.GetNumPath()),
strings.ToLower(tableTypeName),
strings.ToLower(addressFamilyName),
"default",
))

n.metrics = append(n.metrics, prometheus.MustNewConstMetric(
Expand All @@ -146,6 +148,7 @@ func (n *RouterNode) GetRibCounters() {
float64(serverResponse.GetNumAccepted()),
strings.ToLower(tableTypeName),
strings.ToLower(addressFamilyName),
"default",
))

}
Expand Down
19 changes: 0 additions & 19 deletions pkg/gobgp_exporter/describe_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,25 +49,6 @@ var (
"The amount of time it took to scrape the router.",
nil, nil,
)

routerRibTotalDestinationCount = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "route", "total_destination_count"),
"The number of routes on per address family and route table basis",
[]string{"route_table", "address_family"}, nil,
)

routerRibTotalPathCount = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "route", "total_path_count"),
"The number of available paths to destinations on per address family and route table basis",
[]string{"route_table", "address_family"}, nil,
)

routerRibAcceptedPathCount = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "route", "accepted_path_count"),
"The number of accepted paths to destinations on per address family and route table basis",
[]string{"route_table", "address_family"}, nil,
)

routerPeers = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "peer", "count"),
"The number of BGP peers",
Expand Down
2 changes: 1 addition & 1 deletion pkg/gobgp_exporter/describe_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var (
)
routerPeerSessionState = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "peer", "session_state"),
"What is the state of BGP session to the peer: unknown (0), idle (1), connect (2), active (3), opensent (4), openconfirm (5), established (6)",
"What is the state of BGP session to the peer - unknown (0), idle (1), connect (2), active (3), opensent (4), openconfirm (5), established (6)",
[]string{"name"}, nil,
)

Expand Down
39 changes: 39 additions & 0 deletions pkg/gobgp_exporter/describe_rib.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2018 Paul Greenberg ([email protected])
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package exporter

import (
"github.com/prometheus/client_golang/prometheus"
)

var (
routerRibTotalDestinationCount = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "route", "total_destination_count"),
"The number of routes on per address family and route table basis",
[]string{"route_table", "address_family", "vrf_name"}, nil,
)

routerRibTotalPathCount = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "route", "total_path_count"),
"The number of available paths to destinations on per address family and route table basis",
[]string{"route_table", "address_family", "vrf_name"}, nil,
)

routerRibAcceptedPathCount = prometheus.NewDesc(
prometheus.BuildFQName(namespace, "route", "accepted_path_count"),
"The number of accepted paths to destinations on per address family and route table basis",
[]string{"route_table", "address_family", "vrf_name"}, nil,
)
)
4 changes: 2 additions & 2 deletions pkg/gobgp_exporter/metric_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ func (n *RouterNode) GetMetricsTable() string {
}
sort.Strings(labels)
if len(labels) > 0 {
out.WriteString(fmt.Sprintf("`%s` | %s | `%s` |\n", descr["name"], descr["help"], strings.Join(labels, "`, `")))
out.WriteString(fmt.Sprintf("| `%s` | %s | `%s` |\n", descr["name"], descr["help"], strings.Join(labels, "`, `")))
} else {
out.WriteString(fmt.Sprintf("`%s` | %s | |\n", descr["name"], descr["help"]))
out.WriteString(fmt.Sprintf("| `%s` | %s | |\n", descr["name"], descr["help"]))
}
}
return out.String()
Expand Down

0 comments on commit 38ebe31

Please sign in to comment.