Skip to content
This repository was archived by the owner on Jan 22, 2021. It is now read-only.
This repository was archived by the owner on Jan 22, 2021. It is now read-only.

Move to config file for configuration #19

@jsturtevant

Description

@jsturtevant

Currently all of the metadata required to pull the metrics from Azure are hosted on the HPA, for example on the external metrics HPA:

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
 name: consumer-scaler
spec:
 scaleTargetRef:
   apiVersion: extensions/v1beta1
   kind: Deployment
   name: consumer
 minReplicas: 1
 maxReplicas: 10
 metrics:
  - type: External
    external:
      metricName: queuemessages
      metricSelector:
        matchLabels:
          metricName: Messages
          resourceGroup: sb-external-example
          resourceName: sb-external-ns
          resourceProviderNamespace: Microsoft.Servicebus
          resourceType: namespaces
          aggregation: Total
          filter: EntityName_eq_externalq
      targetValue: 30

This creates overhead for the end user especially if they were to try to map Odata queries to label selectors as I previously suggested.

Another interesting result of this the conversion is when using metrics names. With custom metrics the end user must convert the Application Insights metric name from performanceCounters/requestsPerSecond to performanceCounters-requestsPerSecond replacing the / to a -.

With external metrics the "metric name" is not used at all and instead pulled from the selector. This is becuase the metricname in the URL is lower cased and Azure monitor is case sensitive the the metric names, for example Service Bus Messages cannot be messages which happens when the Metric name is pass via url via hpa.

Proposal

To create a better experience for the developer I propose we use a config file that is load via configmap to hold this meta data. The Prometheus Adapter uses the idea of a config though I believe we don't need it to be as complex (yet). This would allow a few scenarios:

  • makes cognitive overhead for developer converting azure meta data simpler
  • a cluster administrator could restrict which metrics are available through the configuration file (if not listed in the file then would not be able to retrieve metric)
  • all for more complex configuration when writing queries

To help even further it would be possible to provide tooling that would auto generate this config file based on the service principal that has access to azure resources.

Example config

#optional sub id that will be used by all external metrics (unless overriden on metric definition)
subscirptionId: 12345678-1234-1234-1234-12345678901234 
#optional appid that will be used by all custom metrics (unless overriden on metric definition)
applicationId: 12345678-1234-1234-1234-123456789012

#list all external metrics values are obtained from https://docs.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-supported-metrics
external:
  - metric: queuemessages #this is the name that will be referenced by hpa 
    metricName: Messages #azure name - is Case sensitive
    resourceGroup: sb-external-example
    resourceName: sb-external-ns
    resourceProviderNamespace: Microsoft.Servicebus #this can container slashes (/)
    resourceType: namespaces
    aggregation: Total
    filter: EntityName eq 'externalq'  #any valid odata filter
    subscriptionID: 12345678-1234-1234-1234-12345678901234 #optional (override global)

#list all custom metrics
custom:
  - metric: rps # this is the name that will be refrenced by hpa
    metricName: performanceCounters/requestsPerSecond # azure name which containers slashes
    applicationId: 12345678-1234-1234-1234-123456789012 #optional (override global)
  # use with ai queries 
  - metric: requests # this is the name that will be refrenced by hpa
    # AI query as defined at https://docs.loganalytics.io/docs/Language-Reference/Query-statements
    query: requests | where timestamp > ago(30d) and client_City == "Redmond" | summarize clients = dcount(client_IP) by tod_UTC=bin(timestamp % 1d, 1h), resultCode | extend local_hour = (tod_UTC - 8h) % 24h
    applicationId: 12345678-1234-1234-1234-123456789012 #optional (override global)

Feedback

Please provide any feedback you might have an the above proposal. Thanks!

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions