Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable remote_ip dimension in rtr_clients #120

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions cmd/stayrtr/stayrtr.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,21 @@ var (
Name: "rtr_clients",
Help: "Number of clients connected.",
},
[]string{"bind"},
[]string{"bind", "remote_ip"},
)
ClientsFlaps = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "rtr_client_flaps",
Help: "Total count of connect/disconnect events per local and remote IP.",
},
[]string{"bind", "remote_ip"},
)
PDUsRecv = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "rtr_pdus",
Help: "PDU received.",
},
[]string{"type"},
[]string{"type", "remote_ip"},
)
CurrentSerial = prometheus.NewGauge(
prometheus.GaugeOpts{
Expand All @@ -164,6 +171,7 @@ func initMetrics() {
prometheus.MustRegister(LastRefresh)
prometheus.MustRegister(RefreshStatusCode)
prometheus.MustRegister(ClientsMetric)
prometheus.MustRegister(ClientsFlaps)
prometheus.MustRegister(PDUsRecv)
prometheus.MustRegister(CurrentSerial)
}
Expand Down Expand Up @@ -693,11 +701,13 @@ type metricsEvent struct {
}

func (m *metricsEvent) ClientConnected(c *rtr.Client) {
ClientsMetric.WithLabelValues(c.GetLocalAddress().String()).Inc()
ClientsMetric.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Inc()
ClientsFlaps.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Add(1)
}

func (m *metricsEvent) ClientDisconnected(c *rtr.Client) {
ClientsMetric.WithLabelValues(c.GetLocalAddress().String()).Dec()
ClientsMetric.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Dec()
ClientsFlaps.WithLabelValues(c.GetLocalAddress().String(), c.GetRemoteAddress().String()).Add(1)
}

func (m *metricsEvent) HandlePDU(c *rtr.Client, pdu rtr.PDU) {
Expand All @@ -707,7 +717,9 @@ func (m *metricsEvent) HandlePDU(c *rtr.Client, pdu rtr.PDU) {
rtr.TypeToString(
pdu.GetType()),
" ",
"_", -1))).Inc()
"_", -1)),
c.GetRemoteAddress().String(),
).Inc()
}

func (m *metricsEvent) UpdateMetrics(numIPv4 int, numIPv6 int, numIPv4filtered int, numIPv6filtered int, changed time.Time, refreshed time.Time, file string, brkCount int, aspaCount int) {
Expand Down
Loading