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

Expose load averages #113

Merged
merged 1 commit into from
Dec 13, 2017
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions collector/nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,42 @@ func NewNodes(logger log.Logger, client *http.Client, url *url.URL, all bool) *N
}),

nodeMetrics: []*nodeMetric{
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "os", "load1"),
"Shortterm load average",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.OS.CPU.LoadAvg.Load1)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "os", "load5"),
"Midterm load average",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.OS.CPU.LoadAvg.Load5)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "os", "load15"),
"Longterm load average",
defaultNodeLabels, nil,
),
Value: func(node NodeStatsNodeResponse) float64 {
return float64(node.OS.CPU.LoadAvg.Load15)
},
Labels: defaultNodeLabelValues,
},
{
Type: prometheus.GaugeValue,
Desc: prometheus.NewDesc(
Expand Down
15 changes: 11 additions & 4 deletions collector/nodes_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,17 @@ type NodeStatsOSSwapResponse struct {
}

type NodeStatsOSCPUResponse struct {
Sys int64 `json:"sys"`
User int64 `json:"user"`
Idle int64 `json:"idle"`
Steal int64 `json:"stolen"`
Sys int64 `json:"sys"`
User int64 `json:"user"`
Idle int64 `json:"idle"`
Steal int64 `json:"stolen"`
LoadAvg NodeStatsOSCPULoadResponse `json:"load_average"`
}

type NodeStatsOSCPULoadResponse struct {
Load1 float64 `json:"1m"`
Load5 float64 `json:"5m"`
Load15 float64 `json:"15m"`
}

// NodeStatsProcessResponse is a representation of a process statistics, memory consumption, cpu usage, open file descriptors
Expand Down