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

softnet: additionals metrics from softnet_data, #2592

Merged
merged 18 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 15 additions & 9 deletions collector/fixtures/e2e-64k-page-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3040,24 +3040,30 @@ 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_total Softnet backlog status
# TYPE node_softnet_backlog_len_total counter
node_softnet_backlog_len_total{cpu="0"} 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
# 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
# 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
# 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
node_softnet_times_squeezed_total{cpu="1"} 10
node_softnet_times_squeezed_total{cpu="2"} 85
node_softnet_times_squeezed_total{cpu="3"} 50
# HELP node_softnet_width softnet_data's Width
# TYPE node_softnet_width gauge
node_softnet_width{cpu="0"} 11
remijouannet marked this conversation as resolved.
Show resolved Hide resolved
# HELP node_sysctl_fs_file_nr sysctl fs.file-nr
# TYPE node_sysctl_fs_file_nr untyped
node_sysctl_fs_file_nr{index="0"} 1024
Expand Down
24 changes: 15 additions & 9 deletions collector/fixtures/e2e-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3062,24 +3062,30 @@ 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_total Softnet backlog status
# TYPE node_softnet_backlog_len_total counter
node_softnet_backlog_len_total{cpu="0"} 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
# 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
# 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
# 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
node_softnet_times_squeezed_total{cpu="1"} 10
node_softnet_times_squeezed_total{cpu="2"} 85
node_softnet_times_squeezed_total{cpu="3"} 50
# HELP node_softnet_width softnet_data's Width
# TYPE node_softnet_width gauge
node_softnet_width{cpu="0"} 11
# HELP node_sysctl_fs_file_nr sysctl fs.file-nr
# TYPE node_sysctl_fs_file_nr untyped
node_sysctl_fs_file_nr{index="0"} 1024
Expand Down
74 changes: 67 additions & 7 deletions collector/softnet_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,16 @@ 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
width *prometheus.Desc
logger log.Logger
}

const (
Expand Down Expand Up @@ -65,6 +70,31 @@ 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_total"),
remijouannet marked this conversation as resolved.
Show resolved Hide resolved
"Softnet backlog status",
[]string{"cpu"}, nil,
),
width: prometheus.NewDesc(
prometheus.BuildFQName(namespace, softnetSubsystem, "width"),
"softnet_data's Width",
remijouannet marked this conversation as resolved.
Show resolved Hide resolved
[]string{"cpu"}, nil,
),
logger: logger,
}, nil
}
Expand All @@ -76,8 +106,8 @@ func (c *softnetCollector) Update(ch chan<- prometheus.Metric) error {
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)
remijouannet marked this conversation as resolved.
Show resolved Hide resolved

ch <- prometheus.MustNewConstMetric(
c.processed,
Expand All @@ -97,6 +127,36 @@ 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.CounterValue,
float64(cpuStats.SoftnetBacklogLen),
cpu,
)
ch <- prometheus.MustNewConstMetric(
c.width,
prometheus.GaugeValue,
float64(cpuStats.Width),
cpu,
)
}

return nil
Expand Down