Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Elasticsearch client: add support for label selectors #10

Open
barkbay opened this issue Sep 21, 2021 · 0 comments
Open

Elasticsearch client: add support for label selectors #10

barkbay opened this issue Sep 21, 2021 · 0 comments

Comments

@barkbay
Copy link
Collaborator

barkbay commented Sep 21, 2021

Within an HPA spec. a label selector can be used to describe a metric:

Many metrics pipelines allow you to describe metrics either by name or by a set of additional descriptors called labels. For all non-resource metric types (pod, object, and external, described below), you can specify an additional label selector which is passed to your metric pipeline. For instance, if you collect a metric http_requests with the verb label, you can specify the following metric block to scale only on GET requests:

type: Object
object:
  metric:
    name: http_requests
    selector: {matchLabels: {verb: GET}}

This selector uses the same syntax as the full Kubernetes label selectors. The monitoring pipeline determines how to collapse multiple series into a single value, if the name and selector match multiple series. The selector is additive, and cannot select metrics that describe objects that are not the target object (the target pods in the case of the Pods type, and the described object in the case of the Object type).

(see original documentation here)

For the moment metricSelector labels.Selector is not used to retrieve a metric:

// valueFor is a helper function to get just the value of a specific metric
func (mc *MetricsClient) valueFor(
ctx *context.Context,
info provider.CustomMetricInfo,
name types.NamespacedName,
originalSelector labels.Selector,
objects []string,
metricSelector labels.Selector,
) (timestampedMetric, error) {
and
// TODO: handle metricSelector
/*if !metricSelector.Matches(value.labels) {
return resource.Quantity{}, provider.NewMetricNotFoundForSelectorError(info.GroupResource, info.Metric, name.Name, metricSelector)
}*/

If we want to support this feature we need to understand what is a label in the context of a document stored in Elasticsearch.

Note that the same question can be raised in the context of External metrics, however they are not likely to be supported as part of a first release of the adapter:

func (mc *MetricsClient) GetExternalMetric(
_, _ string,
_ labels.Selector,
) (*external_metrics.ExternalMetricValueList, error) {
klog.Error("GetExternalMetric: external are not supported by Elasticsearch metrics client")
return nil, nil
}
func (mc *MetricsClient) ListExternalMetrics() (map[provider.ExternalMetricInfo]struct{}, error) {
klog.V(2).Infof("ListAllExternalMetrics: external are not supported by Elasticsearch metrics client")
return nil, nil
}

@barkbay barkbay self-assigned this Sep 22, 2021
@barkbay barkbay removed their assignment Oct 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant