Skip to content

Commit

Permalink
VPA recommender: use rate() to query CPU historical usage from promet…
Browse files Browse the repository at this point in the history
…heus
  • Loading branch information
safanaj committed Mar 25, 2019
1 parent 3c64796 commit 63d93c6
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 63d93c6

Please sign in to comment.