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

Fix active connections #6

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

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
12 changes: 8 additions & 4 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ func NewIpvsCollector(namespace string) *ipvsCollector {
labels := []string{"vip", "vport", "rip", "rport", "protocol"}
return &ipvsCollector{
metrics: map[string]*ipvsMetric{
"ipvs_connections": {
Desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "connections"), "ipvs connections counter", labels, nil),
ValType: prometheus.CounterValue,
},
"ipvs_active_connections": {
Desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "active_connections"), "ipvs active connection counter", labels, nil),
Desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "active_connections"), "ipvs current active connection", labels, nil),
ValType: prometheus.GaugeValue,
},
"ipvs_inactive_connections": {
Desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "inactive_connections"), "ipvs inactive connection counter", labels, nil),
Desc: prometheus.NewDesc(prometheus.BuildFQName(namespace, "", "inactive_connections"), "ipvs current inactive connection", labels, nil),
ValType: prometheus.GaugeValue,
},
"ipvs_rate_cps": {
Expand Down Expand Up @@ -93,7 +97,7 @@ func (c *ipvsCollector) Collect(ch chan<- prometheus.Metric) {
for _, svc := range svcs {
labels := []string{svc.Address.String(), strconv.Itoa(int(svc.Port)), "", "", ipvs.Protocol(svc.Protocol)}
stats := svc.Stats
metric := c.metrics["ipvs_active_connections"]
metric := c.metrics["ipvs_connections"]
ch <- prometheus.MustNewConstMetric(metric.Desc, metric.ValType, float64(stats.Connections), labels...)
metric = c.metrics["ipvs_rate_cps"]
ch <- prometheus.MustNewConstMetric(metric.Desc, metric.ValType, float64(stats.CPS), labels...)
Expand Down Expand Up @@ -123,7 +127,7 @@ func (c *ipvsCollector) Collect(ch chan<- prometheus.Metric) {
labels[3] = strconv.Itoa(int(dest.Port))
stats := dest.Stats
metric = c.metrics["ipvs_active_connections"]
ch <- prometheus.MustNewConstMetric(metric.Desc, metric.ValType, float64(stats.Connections), labels...)
ch <- prometheus.MustNewConstMetric(metric.Desc, metric.ValType, float64(dest.ActiveConnections), labels...)
metric = c.metrics["ipvs_inactive_connections"]
ch <- prometheus.MustNewConstMetric(metric.Desc, metric.ValType, float64(dest.InactiveConnections), labels...)
metric = c.metrics["ipvs_rate_cps"]
Expand Down
25 changes: 12 additions & 13 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,21 @@ module github.com/kwanhur/ipvs-exporter
go 1.18

require (
github.com/moby/ipvs v1.0.1
github.com/prometheus/client_golang v1.12.1
github.com/prometheus/common v0.33.0
github.com/sirupsen/logrus v1.6.0
github.com/moby/ipvs v1.1.0
github.com/prometheus/client_golang v1.16.0
github.com/prometheus/common v0.44.0
github.com/sirupsen/logrus v1.9.3
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/vishvananda/netlink v1.1.0 // indirect
github.com/vishvananda/netns v0.0.0-20191106174202-0a2b9b5464df // indirect
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
google.golang.org/protobuf v1.28.0 // indirect
github.com/vishvananda/netns v0.0.4 // indirect
golang.org/x/sys v0.12.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
)
503 changes: 30 additions & 473 deletions go.sum

Large diffs are not rendered by default.

31 changes: 17 additions & 14 deletions vendor/github.com/cespare/xxhash/v2/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions vendor/github.com/cespare/xxhash/v2/testall.sh

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 20 additions & 27 deletions vendor/github.com/cespare/xxhash/v2/xxhash.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading