Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(custom): handle cross-account/cross-region search expressions for dashboards #551

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions API.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions lib/monitoring/custom/CustomMonitoring.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ export interface CustomMetricSearch {
* default: AxisPosition.LEFT
*/
readonly position?: AxisPosition;

/**
* Account which this metric comes from.
* Note that alarms cannot be created for cross-account metrics.
*
* @default - Deployment account.
*/
readonly account?: string;

/**
* Region which this metric comes from.
* Note that alarms cannot be created for cross-region metrics.
*
* @default - Deployment region.
*/
readonly region?: string;
}

/**
Expand Down Expand Up @@ -482,6 +498,8 @@ export class CustomMonitoring extends Monitoring {
metric.namespace,
metric.label,
metric.period,
metric.region,
metric.account,
);
} else {
// general metric
Expand Down
16 changes: 15 additions & 1 deletion test/monitoring/custom/CustomMonitoring.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ test("snapshot test", () => {
// regular metric
new Metric({ metricName: "DummyMetric1", namespace, dimensionsMap }),
// metric with alarm
new Metric({ metricName: "DummyMetric2", namespace, dimensionsMap }),
new Metric({
metricName: "DummyMetric2",
namespace,
dimensionsMap,
account: "01234567890",
region: "us-west-2",
}),
{
metric: new Metric({
metricName: "DummyMetric3",
Expand All @@ -71,6 +77,14 @@ test("snapshot test", () => {
dimensionsMap,
statistic: MetricStatistic.SUM,
},
{
searchQuery: "DummyMetric5-",
namespace,
dimensionsMap,
statistic: MetricStatistic.SUM,
account: "01234567890",
region: "us-west-2",
},
],
},
{
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.