Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I change metric units on CloudWatch?

I am sending metric data to CloudWatch, and they were sent to AWS with StandardUnit.Count unit, but I later changed them to StandardUnit.Milliseconds. On my dashboard in AWS I still see the data in Count unit.

Is it possible to force AWS to show it in Millisecs, or will it change later? Or should I rename my metrics (I would not like that option)

like image 846
godzsa Avatar asked Oct 12 '17 14:10

godzsa


People also ask

How do I edit metrics on AWS?

To edit a metric policy (console) Open the MediaStore console at https://console.aws.amazon.com/mediastore/ . On the Containers page, choose the container name. In the Metric policy section, choose Edit metric policy. Make the appropriate changes, and then choose Save.

Are CloudWatch metrics Regional?

Metrics are stored separately in Regions, but you can use CloudWatch cross-Region functionality to aggregate statistics from different Regions.


2 Answers

You do not have to rename your metric. CloudWatch doesn't really care about your unit all that much. From CloudWatch Concepts doc:

Units help provide conceptual meaning to your data. Though CloudWatch attaches no significance to a unit internally, other applications can derive semantic information based on the unit.

Units are not tied to a metric, they are tied to each specific datapoint. In your case datapoints will have unit Count up to one point and Milliseconds from that point on. This is not a problem as long as you don't use GetMetricStatistics API with a specified unit. If you don't specify a unit, GetMetricStatistics will return data for both units, but if you set a unit, you'll only get the data for the specified unit (see the API docs for more detail).

CloudWatch Dashboards will display the last unit they see. In the example below, I was publishing the metric with unit Milliseconds up until the gap and with unit Count after the gap (opposite of your situation) and the dashboards are displaying the Count as unit:

enter image description here

If I change the range of the graph to exclude the datapoints with Count unit, graph displays Milliseconds as unit:

enter image description here

like image 175
Dejan Peretin Avatar answered Oct 14 '22 04:10

Dejan Peretin


May be someone searching for cloudformation templates for the same.

      MetricName: "Duration"
  Namespace: "AWS/Lambda"
  Statistic: "Average"
  TreatMissingData: "notBreaching"
  Period: 120
  EvaluationPeriods: 1
  Threshold: 5000
  Unit: "Milliseconds"
  ComparisonOperator: "GreaterThanThreshold"
  Dimensions:
  - Name: "FunctionName"
    Value: !Ref LambdaAuthorizerFnName
like image 22
midhun k Avatar answered Oct 14 '22 06:10

midhun k