import {Statistic, MetricProps, IWidget, Grap...

5/12/2021  •  57 views
 
import {Statistic, MetricProps, IWidget, GraphWidget, Metric} from 'monocdk/aws-cloudwatch';
import { Duration } from "monocdk";

enum METRIC_NAMESPACE {
AWS_SQS = "AWS/SQS"
}


const sqsMetricTitles = [
"integration_test_queue-messageCount",
"integration_test_queue-messageAge",
"integration_test_queue-messageDelayedCount",
"integration_test_queue-messageNotVisibleCount",
"integration_test_queue-emptyReceivesCount",
"integration_test_queue-messageDeletedCount",
"integration_test_queue-messageReceivedCount",
"integration_test_queue-messageSentCount",
"integration_test_queue-messageSentSize",
];



export function getSqsWidgets(): IWidget[] {
let widgets: IWidget[] = [];

sqsMetricTitles.forEach(sqsMetric => {
widgets.push(new GraphWidget({
left: [new Metric(top_level_sqs_metrics[sqsMetric])]
}))
});

return widgets;
}

export const top_level_sqs_metrics: Record<string, MetricProps> = {
["integration_test_queue-messageCount"]: {
metricName: `ApproximateNumberOfMessagesVisible`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageAge"]: {
metricName: `ApproximateAgeOfOldestMessage`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageDelayedCount"]: {
metricName: `ApproximateNumberOfMessagesDelayed`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageNotVisibleCount"]: {
metricName: `ApproximateNumberOfMessagesNotVisible`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-emptyReceivesCount"]: {
metricName: `NumberOfEmptyReceives`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageDeletedCount"]: {
metricName: `NumberOfMessagesDeleted`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageReceivedCount"]: {
metricName: `NumberOfMessagesReceived`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageSentCount"]: {
metricName: `NumberOfMessagesSent`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},
["integration_test_queue-messageSentSize"]: {
metricName: `SentMessageSize`,
namespace: METRIC_NAMESPACE.AWS_SQS,
statistic: Statistic.SUM,
period: Duration.minutes(1),
dimensions: {
QueueName: "integration_test_queue"
},
},

}
https://paste.ac/YBMLnbN