Skip to content

Commit

Permalink
softnet: additionals metrics from softnet_data, (prometheus#2592)
Browse files Browse the repository at this point in the history
* softnet: additionals metrics from softnet_data, prometheus/procfs#473
---------

Signed-off-by: remi <remijouannet@gmail.com>
Signed-off-by: Rémi Jouannet <remijouannet@gmail.com>
  • Loading branch information
remijouannet authored and oblitorum committed Apr 9, 2024
1 parent c994391 commit acc67e6
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 7 deletions.
24 changes: 24 additions & 0 deletions collector/fixtures/e2e-64k-page-output.txt
Expand Up @@ -3040,18 +3040,42 @@ node_softirqs_total{vector="rcu"} 508444
node_softirqs_total{vector="sched"} 622196
node_softirqs_total{vector="tasklet"} 1.783454e+06
node_softirqs_total{vector="timer"} 1.481983e+06
# HELP node_softnet_backlog_len Softnet backlog status
# TYPE node_softnet_backlog_len gauge
node_softnet_backlog_len{cpu="0"} 0
node_softnet_backlog_len{cpu="1"} 0
node_softnet_backlog_len{cpu="2"} 0
node_softnet_backlog_len{cpu="3"} 0
# HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting
# TYPE node_softnet_cpu_collision_total counter
node_softnet_cpu_collision_total{cpu="0"} 0
node_softnet_cpu_collision_total{cpu="1"} 0
node_softnet_cpu_collision_total{cpu="2"} 0
node_softnet_cpu_collision_total{cpu="3"} 0
# HELP node_softnet_dropped_total Number of dropped packets
# TYPE node_softnet_dropped_total counter
node_softnet_dropped_total{cpu="0"} 0
node_softnet_dropped_total{cpu="1"} 41
node_softnet_dropped_total{cpu="2"} 0
node_softnet_dropped_total{cpu="3"} 0
# HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached
# TYPE node_softnet_flow_limit_count_total counter
node_softnet_flow_limit_count_total{cpu="0"} 0
node_softnet_flow_limit_count_total{cpu="1"} 0
node_softnet_flow_limit_count_total{cpu="2"} 0
node_softnet_flow_limit_count_total{cpu="3"} 0
# HELP node_softnet_processed_total Number of processed packets
# TYPE node_softnet_processed_total counter
node_softnet_processed_total{cpu="0"} 299641
node_softnet_processed_total{cpu="1"} 916354
node_softnet_processed_total{cpu="2"} 5.577791e+06
node_softnet_processed_total{cpu="3"} 3.113785e+06
# HELP node_softnet_received_rps_total Number of times cpu woken up received_rps
# TYPE node_softnet_received_rps_total counter
node_softnet_received_rps_total{cpu="0"} 0
node_softnet_received_rps_total{cpu="1"} 0
node_softnet_received_rps_total{cpu="2"} 0
node_softnet_received_rps_total{cpu="3"} 0
# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota
# TYPE node_softnet_times_squeezed_total counter
node_softnet_times_squeezed_total{cpu="0"} 1
Expand Down
24 changes: 24 additions & 0 deletions collector/fixtures/e2e-output.txt
Expand Up @@ -3331,18 +3331,42 @@ node_softirqs_total{vector="rcu"} 508444
node_softirqs_total{vector="sched"} 622196
node_softirqs_total{vector="tasklet"} 1.783454e+06
node_softirqs_total{vector="timer"} 1.481983e+06
# HELP node_softnet_backlog_len Softnet backlog status
# TYPE node_softnet_backlog_len gauge
node_softnet_backlog_len{cpu="0"} 0
node_softnet_backlog_len{cpu="1"} 0
node_softnet_backlog_len{cpu="2"} 0
node_softnet_backlog_len{cpu="3"} 0
# HELP node_softnet_cpu_collision_total Number of collision occur while obtaining device lock while transmitting
# TYPE node_softnet_cpu_collision_total counter
node_softnet_cpu_collision_total{cpu="0"} 0
node_softnet_cpu_collision_total{cpu="1"} 0
node_softnet_cpu_collision_total{cpu="2"} 0
node_softnet_cpu_collision_total{cpu="3"} 0
# HELP node_softnet_dropped_total Number of dropped packets
# TYPE node_softnet_dropped_total counter
node_softnet_dropped_total{cpu="0"} 0
node_softnet_dropped_total{cpu="1"} 41
node_softnet_dropped_total{cpu="2"} 0
node_softnet_dropped_total{cpu="3"} 0
# HELP node_softnet_flow_limit_count_total Number of times flow limit has been reached
# TYPE node_softnet_flow_limit_count_total counter
node_softnet_flow_limit_count_total{cpu="0"} 0
node_softnet_flow_limit_count_total{cpu="1"} 0
node_softnet_flow_limit_count_total{cpu="2"} 0
node_softnet_flow_limit_count_total{cpu="3"} 0
# HELP node_softnet_processed_total Number of processed packets
# TYPE node_softnet_processed_total counter
node_softnet_processed_total{cpu="0"} 299641
node_softnet_processed_total{cpu="1"} 916354
node_softnet_processed_total{cpu="2"} 5.577791e+06
node_softnet_processed_total{cpu="3"} 3.113785e+06
# HELP node_softnet_received_rps_total Number of times cpu woken up received_rps
# TYPE node_softnet_received_rps_total counter
node_softnet_received_rps_total{cpu="0"} 0
node_softnet_received_rps_total{cpu="1"} 0
node_softnet_received_rps_total{cpu="2"} 0
node_softnet_received_rps_total{cpu="3"} 0
# HELP node_softnet_times_squeezed_total Number of times processing packets ran out of quota
# TYPE node_softnet_times_squeezed_total counter
node_softnet_times_squeezed_total{cpu="0"} 1
Expand Down
64 changes: 57 additions & 7 deletions collector/softnet_linux.go
Expand Up @@ -26,11 +26,15 @@ import (
)

type softnetCollector struct {
fs procfs.FS
processed *prometheus.Desc
dropped *prometheus.Desc
timeSqueezed *prometheus.Desc
logger log.Logger
fs procfs.FS
processed *prometheus.Desc
dropped *prometheus.Desc
timeSqueezed *prometheus.Desc
cpuCollision *prometheus.Desc
receivedRps *prometheus.Desc
flowLimitCount *prometheus.Desc
softnetBacklogLen *prometheus.Desc
logger log.Logger
}

const (
Expand Down Expand Up @@ -65,19 +69,41 @@ func NewSoftnetCollector(logger log.Logger) (Collector, error) {
"Number of times processing packets ran out of quota",
[]string{"cpu"}, nil,
),
cpuCollision: prometheus.NewDesc(
prometheus.BuildFQName(namespace, softnetSubsystem, "cpu_collision_total"),
"Number of collision occur while obtaining device lock while transmitting",
[]string{"cpu"}, nil,
),
receivedRps: prometheus.NewDesc(
prometheus.BuildFQName(namespace, softnetSubsystem, "received_rps_total"),
"Number of times cpu woken up received_rps",
[]string{"cpu"}, nil,
),
flowLimitCount: prometheus.NewDesc(
prometheus.BuildFQName(namespace, softnetSubsystem, "flow_limit_count_total"),
"Number of times flow limit has been reached",
[]string{"cpu"}, nil,
),
softnetBacklogLen: prometheus.NewDesc(
prometheus.BuildFQName(namespace, softnetSubsystem, "backlog_len"),
"Softnet backlog status",
[]string{"cpu"}, nil,
),
logger: logger,
}, nil
}

// Update gets parsed softnet statistics using procfs.
func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error {
var cpu string

stats, err := c.fs.NetSoftnetStat()
if err != nil {
return fmt.Errorf("could not get softnet statistics: %w", err)
}

for cpuNumber, cpuStats := range stats {
cpu := strconv.Itoa(cpuNumber)
for _, cpuStats := range stats {
cpu = strconv.FormatUint(uint64(cpuStats.Index), 10)

ch <- prometheus.MustNewConstMetric(
c.processed,
Expand All @@ -97,6 +123,30 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error {
float64(cpuStats.TimeSqueezed),
cpu,
)
ch <- prometheus.MustNewConstMetric(
c.cpuCollision,
prometheus.CounterValue,
float64(cpuStats.CPUCollision),
cpu,
)
ch <- prometheus.MustNewConstMetric(
c.receivedRps,
prometheus.CounterValue,
float64(cpuStats.ReceivedRps),
cpu,
)
ch <- prometheus.MustNewConstMetric(
c.flowLimitCount,
prometheus.CounterValue,
float64(cpuStats.FlowLimitCount),
cpu,
)
ch <- prometheus.MustNewConstMetric(
c.softnetBacklogLen,
prometheus.GaugeValue,
float64(cpuStats.SoftnetBacklogLen),
cpu,
)
}

return nil
Expand Down

0 comments on commit acc67e6

Please sign in to comment.