我在AWS CDK中创建了一个CfnDomain,并尝试获取生成的域名来创建警报。
const es = new elasticsearch.CfnDomain(this, id, esProps);
new cloudwatch.CfnAlarm(this, "test", {
...
dimensions: [
{
name: "DomainName",
value: es.domainName,
},
],
});但看起来domainName属性实际上是我传入的参数(我传递了none,所以它将被自动生成),所以它实际上是undefined,不能使用。
有没有办法指定它,让它等待创建elasticsearch集群,这样我就可以获取生成的域名,或者有没有其他方法可以对集群的指标进行告警?
发布于 2021-01-13 21:51:49
您可以使用CfnDomain.ref作为维度的域值。创建红色集群状态的告警示例:
const domain: CfnDomain = ...;
const elasticDimension = {
"DomainName": domain.ref,
};
const metricRed = new Metric({
namespace: "AWS/ES",
metricName: "ClusterStatus.red",
statistic: "maximum",
period: Duration.minutes(1),
dimensions: elasticDimension
});
const redAlarm = metricRed.createAlarm(construct, "esRedAlarm", {
alarmName: "esRedAlarm",
evaluationPeriods: 1,
threshold: 1
});https://stackoverflow.com/questions/65699433
复制相似问题