Skip to content

Commit

Permalink
Merge pull request #1824 from trilogy-group/fix/recommender-history-p…
Browse files Browse the repository at this point in the history
…rovider-for-cpu-usage-using-rate

VPA recommender: use rate() to query CPU historical usage from promet…
  • Loading branch information
k8s-ci-robot authored Mar 25, 2019
2 parents 61de403 + 63d93c6 commit d46dded
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (p *prometheusHistoryProvider) GetClusterHistory() (map[model.PodID]*PodHis
podSelector := fmt.Sprintf("job=\"%s\", %s=~\".+\", %s!=\"POD\", %s!=\"\"",
p.config.CadvisorMetricsJobName, p.config.CtrPodNameLabel,
p.config.CtrNameLabel, p.config.CtrNameLabel)
err := p.readResourceHistory(res, fmt.Sprintf("container_cpu_usage_seconds_total{%s}[%s]", podSelector, p.config.HistoryLength), model.ResourceCPU)
err := p.readResourceHistory(res, fmt.Sprintf("rate(container_cpu_usage_seconds_total{%s}[%s])", podSelector, p.config.HistoryLength), model.ResourceCPU)
if err != nil {
return nil, fmt.Errorf("cannot get usage history: %v", err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
)

const (
cpuQuery = "container_cpu_usage_seconds_total{job=\"kubernetes-cadvisor\", pod_name=~\".+\", name!=\"POD\", name!=\"\"}[8d]"
cpuQuery = "rate(container_cpu_usage_seconds_total{job=\"kubernetes-cadvisor\", pod_name=~\".+\", name!=\"POD\", name!=\"\"}[8d])"
memoryQuery = "container_memory_usage_bytes{job=\"kubernetes-cadvisor\", pod_name=~\".+\", name!=\"POD\", name!=\"\"}[8d]"
labelsQuery = "up{job=\"kubernetes-pods\"}[8d]"
)
Expand Down

0 comments on commit d46dded

Please sign in to comment.