Skip to content
This repository was archived by the owner on Dec 1, 2018. It is now read-only.

Commit 30d095a

Browse files
committed
add cpu load metrics
1 parent d37010c commit 30d095a

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

docs/storage-schema.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Heapster exports the following metrics to its backends.
1212
| cpu/request | CPU request (the guaranteed amount of resources) in millicores. |
1313
| cpu/usage | Cumulative CPU usage on all cores. |
1414
| cpu/usage_rate | CPU usage on all cores in millicores. |
15+
| cpu/load | CPU load in milliloads, i.e., runnable threads * 1000 |
1516
| filesystem/usage | Total number of bytes consumed on a filesystem. |
1617
| filesystem/limit | The total size of filesystem in bytes. |
1718
| filesystem/available | The number of available bytes remaining in a the filesystem |

metrics/core/metrics.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ const (
2929
var StandardMetrics = []Metric{
3030
MetricUptime,
3131
MetricCpuUsage,
32+
MetricCpuLoad,
3233
MetricEphemeralStorageUsage,
3334
MetricMemoryUsage,
3435
MetricMemoryRSS,
@@ -101,6 +102,7 @@ var CpuMetrics = []Metric{
101102
MetricCpuLimit,
102103
MetricCpuRequest,
103104
MetricCpuUsage,
105+
MetricCpuLoad,
104106
MetricCpuUsageRate,
105107
MetricNodeCpuAllocatable,
106108
MetricNodeCpuCapacity,
@@ -202,6 +204,25 @@ var MetricRestartCount = Metric{
202204
},
203205
}
204206

207+
var MetricCpuLoad = Metric{
208+
MetricDescriptor: MetricDescriptor{
209+
Name: "cpu/load",
210+
Description: "CPU load",
211+
Type: MetricGauge,
212+
ValueType: ValueInt64,
213+
Units: UnitsCount,
214+
},
215+
HasValue: func(spec *cadvisor.ContainerSpec) bool {
216+
return spec.HasCpu
217+
},
218+
GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue {
219+
return MetricValue{
220+
ValueType: ValueInt64,
221+
MetricType: MetricGauge,
222+
IntValue: int64(stat.Cpu.LoadAverage)}
223+
},
224+
}
225+
205226
var MetricCpuUsage = Metric{
206227
MetricDescriptor: MetricDescriptor{
207228
Name: "cpu/usage",

0 commit comments

Comments
 (0)