Skip to content

Better estimate for SQS time to drain metrics #390

Open
@r0b0ji

Description

@r0b0ji

Version

v5.2.3

Steps and/or minimal code example to reproduce

It is not actually a bug but a better and simpler computation exist. Currently, time to drain metrics in SQS is calculated as below [1] , which is indirect. A better estimate can be calculated using RATE function [2].

  1. metricTimeToDrain() {
    return this.metricFactory.createMetricMath(
    "(visibleMessages / (consumptionVolume - incomingVolume)) * (PERIOD(consumptionVolume))",
    {
    visibleMessages: this.metricApproximateVisibleMessageCount(),
    incomingVolume: this.metricIncomingMessageCount(),
    consumptionVolume: this.metricDeletedMessageCount(),
    },
    "Time to Drain (seconds) (avg: ${AVG}, max: ${MAX})"
    );
    }
  2. https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/using-metric-math.html

Expected behavior

Instead of directly getting the consumption rate, current computation estimate based on different metrics which is less accurate.

Actual behavior

A better and direct method can be used.

Other details

A sample code for this is

{
    "metrics": [
        [ { "expression": "m1/ABS(RATE(m1))", "label": "TimeToDrain (sec)", "id": "e1", "region": "us-east-1" } ],
        [ "AWS/SQS", "ApproximateNumberOfMessagesVisible", "QueueName", "some-test-queue", { "id": "m1", "visible": false, "region": "us-east-1" } ]
    ],
    "view": "timeSeries",
    "stacked": false,
    "region": "us-east-1",
    "stat": "Average",
    "period": 300
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions