我CfnDomain
在AWS CDK中创建了一个,并且试图获取生成的域名来创建警报。
const es = new elasticsearch.CfnDomain(this, id, esProps);
new cloudwatch.CfnAlarm(this, "test", {
...
dimensions: [
{
name: "DomainName",
value: es.domainName,
},
],
});
但似乎该domainName
属性实际上是我传入的参数(我没有传递任何变量,因此它将自动生成),因此它实际上是undefined
并且不能使用。
有什么方法可以指定它,以便它将等待创建Elasticsearch集群以便我可以获取生成的域名,还是有其他方法为该集群的指标创建警报?
您将其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
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句