mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-05 17:27:51 +00:00
Add requested fixes
This commit is contained in:
parent
510c3724ce
commit
fa5f8cd742
3 changed files with 5 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
External Metrics
|
External Metrics
|
||||||
===========
|
===========
|
||||||
|
|
||||||
It's possible to configure [Autoscaling on metrics not related to Kubernetes objects](Autoscaling on metrics not related to Kubernetes objects) in Kubernetes. This is done with a special `External Metrics` system. Using external metrics in Kubernetes with the adapter requires you to configure special `external` rules in the configuration.
|
It's possible to configure [Autoscaling on metrics not related to Kubernetes objects](https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-metrics-not-related-to-kubernetes-objects) in Kubernetes. This is done with a special `External Metrics` system. Using external metrics in Kubernetes with the adapter requires you to configure special `external` rules in the configuration.
|
||||||
|
|
||||||
The configuration for `external` metrics rules is almost identical to the normal `rules`:
|
The configuration for `external` metrics rules is almost identical to the normal `rules`:
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ possible with `external` rules because the `namespace` label is set to match tha
|
||||||
|
|
||||||
However, you can explicitly disable the automatic add of the HPA namepace to the query, and instead opt to not set a namespace at all, or to target a different namespace.
|
However, you can explicitly disable the automatic add of the HPA namepace to the query, and instead opt to not set a namespace at all, or to target a different namespace.
|
||||||
|
|
||||||
This is done by setting `namespaced: false` the `resources` section of the `external` rule:
|
This is done by setting `namespaced: false` in the `resources` section of the `external` rule:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# rules: ...
|
# rules: ...
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,8 @@ external:
|
||||||
# but you can explicitly disable namespaces if needed with "namespaced: false"
|
# but you can explicitly disable namespaces if needed with "namespaced: false"
|
||||||
# this is useful if you have an HPA with an external metric in namespace A
|
# this is useful if you have an HPA with an external metric in namespace A
|
||||||
# but want to query for metrics from namespace B
|
# but want to query for metrics from namespace B
|
||||||
namespaced: false
|
resources:
|
||||||
|
namespaced: false
|
||||||
|
|
||||||
# TODO: should we be able to map to a constant instance of a resource
|
# TODO: should we be able to map to a constant instance of a resource
|
||||||
# (e.g. `resources: {constant: [{resource: "namespace", name: "kube-system"}}]`)?
|
# (e.g. `resources: {constant: [{resource: "namespace", name: "kube-system"}}]`)?
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ type queryPart struct {
|
||||||
func (q *metricsQuery) Build(series string, resource schema.GroupResource, namespace string, extraGroupBy []string, metricSelector labels.Selector, names ...string) (prom.Selector, error) {
|
func (q *metricsQuery) Build(series string, resource schema.GroupResource, namespace string, extraGroupBy []string, metricSelector labels.Selector, names ...string) (prom.Selector, error) {
|
||||||
queryParts := q.createQueryPartsFromSelector(metricSelector)
|
queryParts := q.createQueryPartsFromSelector(metricSelector)
|
||||||
|
|
||||||
if q.namespaced && namespace != "" {
|
if namespace != "" {
|
||||||
namespaceLbl, err := q.resConverter.LabelForResource(NsGroupResource)
|
namespaceLbl, err := q.resConverter.LabelForResource(NsGroupResource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue