9

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)

godzsa
  • 2,105
  • 4
  • 34
  • 56

3 Answers3

6

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

Dejan Peretin
  • 10,891
  • 1
  • 45
  • 54
  • 1
    I really want your answer to be true for me, but it isn't. I have not been able to change from `count` I pushed for about 3 minutes, even though I have been pushing as `milliseconds` for hours now. Still says `count` even if I narrow the graph to last 10 minutes. – red6 Jan 17 '18 at 21:17
  • Can you do a GetMetricStatistics call for that metric and check the unit on each data point? Also, how are you limiting the range to last 10 min? Don't use zoom, use the time range selector on the top right in the dashboard. – Dejan Peretin Jan 17 '18 at 21:29
  • I just looked back and it rolled off in the range and now says `milliseconds`. Thanks! I had definitely been zooming (shame, shame on me) – red6 Jan 17 '18 at 21:36
  • Thanks. I guess this explains why I'm seeing a "Multiple units returned" warning in my legend, after changing units from `None` to `Count`. – djvg Apr 19 '22 at 14:39
2

Perhaps, you can go to Edit > Options, then:

  1. Uncheck the "Show units" option.
  2. Add custom label into the "Label" field.

Here, for example, I changed the label to "Seconds":

AWS CloudWatch: "Show units" unchecked; field "Label" filled with "Seconds"

Result:

Line graph showing iterator age in seconds

Andriy Makukha
  • 7,580
  • 1
  • 38
  • 49
1

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
midhun k
  • 11
  • 1