kubernetesamazon-cloudwatchmetricshpakeda

aws-cloudwatch expression attribute


Using aws-cloudwatch trigger with KEDA for auto scaling and not sure what the expression attribute is! Isn't supposed to return the value of the expected metrics/dimension at polling time? If yes, why do we still need other attributes like metricCollectionTime, metricStat, and metricStatPeriod?


Solution

  • Option 1: Specify expression - The docs say that it's "Optional, Required when dimensionName & dimensionValue are not specified". However, it could say namespace, metricName, dimensionName, and dimensionValue. e.g.

     ...
     expression: SELECT AVG("my_metric_name") FROM "Metric/Namespace" WHERE dimension1 = "dimension1value"
    

    Option 2: namespace, metricName, dimensionName, metricStat, and dimensionValue should be specified in place of expression.

    e.g. The equivalent to the above would be:

     ...
     metricName: metric_name
     namespace: Metric/Namespace
     dimensionName: dimension1
     metricStat: Average
     dimensionValue: dimension1value
    

    metricCollectionTime and metricStatPeriod are both needed regardless of which of the above two options is used, because they determine the time frame for which to look for metrics, whereas the above options have nothing to do with the timeframe associated to each metric.