Specifying units type in math expression Cloudwatch - Various units error

0

I have a graph showing the TargetResponseTime metric (in seconds) of 5 different load balancers and I would like to also show the total of all 5 added up. Using the math expression of m1+m2+m3+m4+m5 or SUM(METRICS('m')) I can obtain a Total and the actual calculation is performing correctly unfortunately this results in the graph showing 'Various units' in general view and 'No units' when focused on the Total metric e1. Enter image description here

I have tried specifying "units": "Seconds" as an option in the expression part of the below query on its own and also in combination with the removal of the "period": 60, setting and I have also tried dividing by /60 or *60 at the end of the expression. None of my attempts has been succesful at showing the correct unit type.

What is the correct way to specify the units as seconds for my Total metric?

{
    "metrics": [
        [ { "expression": "m1+m2+m3+m4+m5", "label": "Total", "id": "e1", "region": "us-west-2", "yAxis": "left" } ]
        [ "AWS/ApplicationELB", "TargetResponseTime", "LoadBalancer", "app/k8s-warXXXXXX-XXXXX/XXXXX", { "label": "a", "region": "us-west-2", "id": "m1" } ],
        [ "...", "app/k8s-warXXXXXX-XXXXX/XXXXX", { "region": "us-west-2", "label": "b", "id": "m2" } ],
        [ "...", "app/k8s-warXXXXXX-XXXXX/XXXXX", { "region": "us-west-2", "label": "c", "id": "m3" } ],
        [ "...", "app/k8s-warXXXXXX-XXXXX/XXXXX", { "region": "us-west-2", "label": "d", "id": "m4" } ],
        [ "...", "app/k8s-warXXXXXX-XXXXX/XXXXX", { "region": "us-west-2", "label": "e", "id": "m5" } ]
    ],
    "period": 60,
    "region": "us-west-2",
    "stat": "Average",
    "title": "Target Response Time",
    "yAxis": {
        "left": {
            "min": 0
        },
        "units": "Seconds"
    },
    "view": "timeSeries",
    "stacked": false
}
asked 7 months ago298 views
2 Answers
2
Accepted Answer
  • You can set a custom label on the Y-axis in Options tab of graph
  • Also, turn off the option to display the units
  • SUM(METRICS()) is the quick way to sum all fully-named metrics
  • /PERIOD(m1) will convert the total time, to total time per second

The following graph should do the trick:

{
    "metrics": [
        [ { "expression": "SUM(METRICS())/PERIOD(m1)", "label": "Total", "id": "total", "region": "us-west-2", "yAxis": "left" } ],
        [ "AWS/ApplicationELB", "TargetResponseTime", "LoadBalancer", "app/k8s-warXXXXXX-XXXXX/XXXXX", { "label": "a", "region": "us-west-2", "id": "m1", "visible": false } ],
        [ "...", { "region": "us-west-2", "label": "b", "id": "m2", "visible": false } ],
        [ "...", { "region": "us-west-2", "label": "c", "id": "m3", "visible": false } ],
        [ "...", { "region": "us-west-2", "label": "d", "id": "m4", "visible": false } ],
        [ "...", { "region": "us-west-2", "label": "e", "id": "m5", "visible": false } ]
    ],
    "period": 60,
    "region": "us-east-1",
    "stat": "Average",
    "title": "Target Response Time (per second)",
    "yAxis": {
        "left": {
            "min": 0,
            "label": "Seconds",
            "showUnits": false
        }
    },
    "view": "timeSeries",
    "stacked": false
}
AWS
answered 7 months ago
  • The expression you provided did not work but adding "label": "Seconds", "showUnits": false in the query is an acceptable workaround. Thank you very much

0

Hello!

Thank you for contacting AWS re:Post!

Since SUM is nothing but the sum of the values of the all data points collected during the period, there is no unit associated with the expression and CloudWatch attaches no significance to a unit internally, other applications can derive semantic information based on the unit. [1][2]

That being said, the response shared above by user @Amazon-CloudWatch-0 (Thanks!) includes a valid workaround of using a custom label on the Y-axis in Options tab of graph. I am glad to see that response was of help to you.

I hope you will find the above information useful. In the meantime, please feel free to reach out in case you have any further queries or concerns. We would be happy to assist you.

====================

References:
[1] CloudWatch statistics definitions - https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Statistics-definitions.html
[2] Amazon CloudWatch concepts - Units - https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch_concepts.html#Unit

profile pictureAWS
answered 7 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions