[英]How to reference a CloudWatch metric created by container insights for EKS?
[英]How to reference a CloudWatch metric created by container insights for ECS/Fargate
我已經創建了一個 ECS 集群,如下所示:
this.cluster = new ecs.Cluster(this, 'Cluster', {
containerInsights: true,
vpc: ec2.Vpc.fromLookup(this, props.stage + 'Vpc', {isDefault: false})
});
我想根據我的集群創建一個 CW 警報,如下所示:
const CPUHigh = new cw.Alarm(this, "CPUHigh", {
metric: this.cluster.metric("CPUUtilized"),
threshold: 50,
evaluationPeriods: 3,
period: cdk.Duration.seconds(60),
comparisonOperator: cw.ComparisonOperator.GREATER_THAN_THRESHOLD
})
但即使該指標與 Container Insights 創建的指標相匹配,似乎也無法以這種方式引用。
有誰知道它應該被引用的方式?
cdk 僅支持某些指標基線,並未涵蓋容器洞察力,但這不是問題,您可以非常輕松地創建自己的指標對象。 對於容器洞察,它看起來像這樣
new cloudwatch.Metric({
metricName: 'NetworkTxBytes',
namespace: 'ECS/ContainerInsights',
dimensions: { ServiceName: props.ecsService.serviceName, ClusterName: props.ecsCluster.clusterName },
statistic: 'avg',
period: cdk.Duration.minutes(5),
}),
這里重要的是命名空間、維度和度量名稱。
您可以從指標控制台和最后一個選項卡“源”中獲取有關命名空間和維度的信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.