在AWS cloudwatch仪表板中,我可以选择绘制一个指标的所有维度吗?



假设,我想绘制系统中每个pod的CPU使用指标,以Podname为维度。我可以像这样在CDK中指定一个小部件,并期望它在一个小部件中获得所有pod吗?

const podcpumetric = new cloudwatch.Metric({
namespace: 'chkk',
metricName: 'CPU Metrics with podName as dimension',
period: Duration.days(1),
//   dimensionsMap: {}, // not specified so that all pods are in the widget
statistic: 'maximum',
});
dashboard.addWidgets(
new GraphWidget({
title: 'Pod Cpu Usage',
width: 12,
left: [podcpumetric],
}),
);

我尝试了类似上面的东西,没有指定维度,并希望它将获得所有pod的数据。这似乎行不通。

然而,我可以声明每个pod一个度量,然后将其添加到left数组中,但这似乎不是一个全面的解决方案。因为我必须更新这个小部件,如果我在将来添加一个新的pod并想要绘制它的数据。

我发现这是可能的。Domain是其dimensionSet中唯一的维度。


const CompanyLogins = new MathExpression({
label: 'NumberOfDailyLoginsPerDomain',
expression: `SEARCH(' {namespace, Domain} MetricName="NumberOfDailyLoginsPerDomain" ', 'Maximum', 1440)`,
usingMetrics: {},
});
dashboard.addWidgets(
new GraphWidget({
title: 'Number of Logins per Domain (sum of logins by all users of the domain)',
width: 12,
view: cloudwatch.GraphWidgetView.BAR,
left: [CompanyLogins],
}),
);

相关内容

最新更新