Is there a clear way to calculate starting uptime metrics from AWS ELB?

I need to start running uptime calculations. I'd like to start by just using AWS services for monitoring the uptime and then grow from there as I determine what I'd like that to mean.

I have the service behind an ELB as a target group. I trust the instance health check to indicate service uptime. I'd like to use the metrics on the AWS ELB as received by AWS CloudWatch to calculate the uptime over 30 days. If the HealthyHostCount metric is 0 for 10 seconds, that's 10 seconds of downtime. Otherwise, we have uptime. Then I'd like to have a percentage of time up over a period (30 days) to the hundredth of a percent.

I've been playing with CloudWatch metrics to try to figure this out and finding that I can do math and have been getting results that seem in the right neighborhood, but I'm not confident that I'm properly thinking about the statistic period and the graph period. I'm also wondering if I should be using the PR statistic instead of doing my own math.

Here's what I have right now. I'm grabbing the ELB's HealthyHostCount as m1 and UnhealthyHostCount as m2. Both are summed up for 30 days. Then I have an expression 100*(m1/m1+m2) to calculate percent up counts over the total counts taken for that 30 days. I have the chart set to a relative 30 days period.

The problem is that this calculation, as soon as I have some value greater than 0 in m2, seems to result in numbers in the thousands or millions instead of reducing the percent down from 100.

How would you calculate service percent uptime from AWS ELB metrics?

1 Answer 1


I decided to approach the calculations this way.

Success = HealthyHostCount > 0

Fail = HealthyHostCount <= 0

Time = HealthyHostCount + UnhealthyHostCount

Uptime = 100*(Success/(Success+Fail))

That ended up with a dashboard widget in CloudWatch with a source like this.

    "metrics": [
        [ { "expression": "100*(succeed/(succeed+fail))", 
            "label": "Dev %Up", "id": "e2", 
            "region": "us-west-1", "period": 10 } ],
        [ { "expression": "IF(hhc > 0, 1, 0)", 
            "label": "Success Count", "id": "succeed",
            "visible": false, "region": "us-west-1" } ],
        [ { "expression": "IF(uhc > 0, 1, 0)", 
            "label": "Fail Count", "id": "fail", 
            "visible": false, "region": "us-west-1" } ],
        [ "AWS/ELB",
          { "id": "uhc", "visible": false, 
            "region": "us-west-1" } ],
        [ ".", "HealthyHostCount", ".", ".",
          { "id": "hhc", "visible": false,
            "region": "us-west-1" } ]
    "view": "gauge",
    "stacked": false,
    "region": "us-west-1",
    "stat": "Sum",
    "period": 10,
    "title": "Dev Uptime",
    "yAxis": {
        "left": {
            "min": 0,
            "max": 100
    "setPeriodToTimeRange": true,
    "sparkline": false,
    "trend": false,
    "singleValueFullPrecision": false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.