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

Commit

Permalink
Merge pull request #1989 from andyxning/add_cpu_load
Browse files Browse the repository at this point in the history
add cpu load metrics
  • Loading branch information
k8s-ci-robot committed Mar 26, 2018
2 parents d37010c + 30d095a commit 89ea3ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/storage-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Heapster exports the following metrics to its backends.
| cpu/request | CPU request (the guaranteed amount of resources) in millicores. |
| cpu/usage | Cumulative CPU usage on all cores. |
| cpu/usage_rate | CPU usage on all cores in millicores. |
| cpu/load | CPU load in milliloads, i.e., runnable threads * 1000 |
| filesystem/usage | Total number of bytes consumed on a filesystem. |
| filesystem/limit | The total size of filesystem in bytes. |
| filesystem/available | The number of available bytes remaining in a the filesystem |
Expand Down
21 changes: 21 additions & 0 deletions metrics/core/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
var StandardMetrics = []Metric{
MetricUptime,
MetricCpuUsage,
MetricCpuLoad,
MetricEphemeralStorageUsage,
MetricMemoryUsage,
MetricMemoryRSS,
Expand Down Expand Up @@ -101,6 +102,7 @@ var CpuMetrics = []Metric{
MetricCpuLimit,
MetricCpuRequest,
MetricCpuUsage,
MetricCpuLoad,
MetricCpuUsageRate,
MetricNodeCpuAllocatable,
MetricNodeCpuCapacity,
Expand Down Expand Up @@ -202,6 +204,25 @@ var MetricRestartCount = Metric{
},
}

var MetricCpuLoad = Metric{
MetricDescriptor: MetricDescriptor{
Name: "cpu/load",
Description: "CPU load",
Type: MetricGauge,
ValueType: ValueInt64,
Units: UnitsCount,
},
HasValue: func(spec *cadvisor.ContainerSpec) bool {
return spec.HasCpu
},
GetValue: func(spec *cadvisor.ContainerSpec, stat *cadvisor.ContainerStats) MetricValue {
return MetricValue{
ValueType: ValueInt64,
MetricType: MetricGauge,
IntValue: int64(stat.Cpu.LoadAverage)}
},
}

var MetricCpuUsage = Metric{
MetricDescriptor: MetricDescriptor{
Name: "cpu/usage",
Expand Down

0 comments on commit 89ea3ac

Please sign in to comment.