mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
Introduce support for the resource metrics API
This introduces support for the resource metrics in the adapter. The individual queries and window sizes are fully customizable via a new config section. This uses just the generic machinery from metrics-server to serve the API.
This commit is contained in:
parent
74c0c53e4f
commit
c5801455ec
5 changed files with 503 additions and 9 deletions
|
|
@ -89,5 +89,25 @@ func DefaultConfig(rateInterval time.Duration, labelPrefix string) *MetricsDisco
|
|||
MetricsQuery: fmt.Sprintf("sum(rate(<<.Series>>{<<.LabelMatchers>>}[%s])) by (<<.GroupBy>>)", pmodel.Duration(rateInterval).String()),
|
||||
},
|
||||
},
|
||||
|
||||
ResourceRules: &ResourceRules{
|
||||
CPU: ResourceRule{
|
||||
ContainerQuery: fmt.Sprintf("sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>}[%s])) by (<<.GroupBy>>)", pmodel.Duration(rateInterval).String()),
|
||||
NodeQuery: fmt.Sprintf("sum(rate(container_cpu_usage_seconds_total{<<.LabelMatchers>>, id='/'}[%s])) by (<<.GroupBy>>)", pmodel.Duration(rateInterval).String()),
|
||||
Resources: ResourceMapping{
|
||||
Template: fmt.Sprintf("%s<<.Resource>>", labelPrefix),
|
||||
},
|
||||
ContainerLabel: fmt.Sprintf("%scontainer_name", labelPrefix),
|
||||
},
|
||||
Memory: ResourceRule{
|
||||
ContainerQuery: "sum(container_memory_working_set_bytes{<<.LabelMatchers>>}) by (<<.GroupBy>>)",
|
||||
NodeQuery: "sum(container_memory_working_set_bytes{<<.LabelMatchers>>,id='/'}) by (<<.GroupBy>>)",
|
||||
Resources: ResourceMapping{
|
||||
Template: fmt.Sprintf("%s<<.Resource>>", labelPrefix),
|
||||
},
|
||||
ContainerLabel: fmt.Sprintf("%scontainer_name", labelPrefix),
|
||||
},
|
||||
Window: pmodel.Duration(rateInterval),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue