@composurecdk/neptune 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +140 -0
- package/dist/commonjs/cluster-alarm-config.d.ts +77 -0
- package/dist/commonjs/cluster-alarm-config.d.ts.map +1 -0
- package/dist/commonjs/cluster-alarm-config.js +3 -0
- package/dist/commonjs/cluster-alarm-config.js.map +1 -0
- package/dist/commonjs/cluster-alarm-defaults.d.ts +20 -0
- package/dist/commonjs/cluster-alarm-defaults.d.ts.map +1 -0
- package/dist/commonjs/cluster-alarm-defaults.js +52 -0
- package/dist/commonjs/cluster-alarm-defaults.js.map +1 -0
- package/dist/commonjs/cluster-alarms.d.ts +25 -0
- package/dist/commonjs/cluster-alarms.d.ts.map +1 -0
- package/dist/commonjs/cluster-alarms.js +133 -0
- package/dist/commonjs/cluster-alarms.js.map +1 -0
- package/dist/commonjs/cluster-builder.d.ts +194 -0
- package/dist/commonjs/cluster-builder.d.ts.map +1 -0
- package/dist/commonjs/cluster-builder.js +140 -0
- package/dist/commonjs/cluster-builder.js.map +1 -0
- package/dist/commonjs/cluster-defaults.d.ts +19 -0
- package/dist/commonjs/cluster-defaults.d.ts.map +1 -0
- package/dist/commonjs/cluster-defaults.js +87 -0
- package/dist/commonjs/cluster-defaults.js.map +1 -0
- package/dist/commonjs/cluster-parameter-group-defaults.d.ts +30 -0
- package/dist/commonjs/cluster-parameter-group-defaults.d.ts.map +1 -0
- package/dist/commonjs/cluster-parameter-group-defaults.js +53 -0
- package/dist/commonjs/cluster-parameter-group-defaults.js.map +1 -0
- package/dist/commonjs/index.d.ts +6 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +13 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/esm/cluster-alarm-config.d.ts +77 -0
- package/dist/esm/cluster-alarm-config.d.ts.map +1 -0
- package/dist/esm/cluster-alarm-config.js +2 -0
- package/dist/esm/cluster-alarm-config.js.map +1 -0
- package/dist/esm/cluster-alarm-defaults.d.ts +20 -0
- package/dist/esm/cluster-alarm-defaults.d.ts.map +1 -0
- package/dist/esm/cluster-alarm-defaults.js +49 -0
- package/dist/esm/cluster-alarm-defaults.js.map +1 -0
- package/dist/esm/cluster-alarms.d.ts +25 -0
- package/dist/esm/cluster-alarms.d.ts.map +1 -0
- package/dist/esm/cluster-alarms.js +129 -0
- package/dist/esm/cluster-alarms.js.map +1 -0
- package/dist/esm/cluster-builder.d.ts +194 -0
- package/dist/esm/cluster-builder.d.ts.map +1 -0
- package/dist/esm/cluster-builder.js +137 -0
- package/dist/esm/cluster-builder.js.map +1 -0
- package/dist/esm/cluster-defaults.d.ts +19 -0
- package/dist/esm/cluster-defaults.d.ts.map +1 -0
- package/dist/esm/cluster-defaults.js +84 -0
- package/dist/esm/cluster-defaults.js.map +1 -0
- package/dist/esm/cluster-parameter-group-defaults.d.ts +30 -0
- package/dist/esm/cluster-parameter-group-defaults.d.ts.map +1 -0
- package/dist/esm/cluster-parameter-group-defaults.js +49 -0
- package/dist/esm/cluster-parameter-group-defaults.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/package.json +71 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { AlarmConfig } from "@composurecdk/cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Controls which recommended alarms are created for a Neptune cluster.
|
|
4
|
+
* All applicable alarms are enabled by default with thresholds drawn from
|
|
5
|
+
* the Neptune team's own metric guidance. Set an individual alarm to `false`
|
|
6
|
+
* to disable it, or provide an {@link AlarmConfig} to tune its thresholds.
|
|
7
|
+
*
|
|
8
|
+
* Neptune is not yet covered by the CloudWatch out-of-the-box alarm
|
|
9
|
+
* recommendations table, so these thresholds are anchored to the Neptune
|
|
10
|
+
* User Guide's metrics guidance and the Neptune Well-Architected lens rather
|
|
11
|
+
* than to that table.
|
|
12
|
+
*
|
|
13
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/best-practices-general-metrics.html
|
|
14
|
+
* @see https://docs.aws.amazon.com/prescriptive-guidance/latest/neptune-well-architected-framework/introduction.html
|
|
15
|
+
*/
|
|
16
|
+
export interface NeptuneClusterAlarmConfig {
|
|
17
|
+
/**
|
|
18
|
+
* Master switch: set to `false` to disable all recommended alarms.
|
|
19
|
+
* Individual alarms can also be disabled via their own entry.
|
|
20
|
+
* @default true
|
|
21
|
+
*/
|
|
22
|
+
enabled?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Alarm on sustained high CPU on the cluster's instances — the primary
|
|
25
|
+
* signal of a saturated writer or undersized instance.
|
|
26
|
+
*
|
|
27
|
+
* Metric: `AWS/Neptune CPUUtilization`, statistic Average, period 1 minute.
|
|
28
|
+
* Default threshold: >= 80%.
|
|
29
|
+
*
|
|
30
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/cloudwatch-monitoring-instances.html
|
|
31
|
+
*/
|
|
32
|
+
cpuUtilization?: AlarmConfig | false;
|
|
33
|
+
/**
|
|
34
|
+
* Alarm when requests are queuing faster than the engine can execute them.
|
|
35
|
+
*
|
|
36
|
+
* Metric: `AWS/Neptune MainRequestQueuePendingRequests`, statistic Average,
|
|
37
|
+
* period 1 minute. Default threshold: > 100 pending requests.
|
|
38
|
+
*
|
|
39
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/best-practices-general-metrics.html
|
|
40
|
+
*/
|
|
41
|
+
mainRequestQueuePendingRequests?: AlarmConfig | false;
|
|
42
|
+
/**
|
|
43
|
+
* Alarm when the buffer cache hit ratio drops, indicating the working set
|
|
44
|
+
* no longer fits in memory and query latency is dominated by I/O.
|
|
45
|
+
*
|
|
46
|
+
* Metric: `AWS/Neptune BufferCacheHitRatio`, statistic Average, period 1
|
|
47
|
+
* minute. Default threshold: < 99.9%.
|
|
48
|
+
*
|
|
49
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/best-practices-general-metrics.html
|
|
50
|
+
*/
|
|
51
|
+
bufferCacheHitRatio?: AlarmConfig | false;
|
|
52
|
+
/**
|
|
53
|
+
* Alarm when a read replica falls too far behind the writer. Only emits
|
|
54
|
+
* data when the cluster has at least one replica, so it stays quiet on a
|
|
55
|
+
* single-instance cluster (`TreatMissingData.NOT_BREACHING`).
|
|
56
|
+
*
|
|
57
|
+
* Metric: `AWS/Neptune ClusterReplicaLag`, statistic Average, period 1
|
|
58
|
+
* minute. Default threshold: > 30000 ms.
|
|
59
|
+
*
|
|
60
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/cw-metrics.html
|
|
61
|
+
*/
|
|
62
|
+
clusterReplicaLag?: AlarmConfig | false;
|
|
63
|
+
/**
|
|
64
|
+
* Alarm when a serverless cluster sustains capacity near its configured
|
|
65
|
+
* ceiling, indicating the max NCU setting is too low or query load is
|
|
66
|
+
* running away. Only created when the cluster is serverless (i.e.
|
|
67
|
+
* `serverlessScalingConfiguration` is set); the default threshold is
|
|
68
|
+
* derived as 90% of the configured `maxCapacity`.
|
|
69
|
+
*
|
|
70
|
+
* Metric: `AWS/Neptune ServerlessDatabaseCapacity`, statistic Average,
|
|
71
|
+
* period 1 minute.
|
|
72
|
+
*
|
|
73
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/neptune-serverless-capacity-scaling.html
|
|
74
|
+
*/
|
|
75
|
+
serverlessDatabaseCapacity?: AlarmConfig | false;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=cluster-alarm-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-alarm-config.d.ts","sourceRoot":"","sources":["../../src/cluster-alarm-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAErC;;;;;;;OAOG;IACH,+BAA+B,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAEtD;;;;;;;;OAQG;IACH,mBAAmB,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAE1C;;;;;;;;;OASG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;IAExC;;;;;;;;;;;OAWG;IACH,0BAA0B,CAAC,EAAE,WAAW,GAAG,KAAK,CAAC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-alarm-config.js","sourceRoot":"","sources":["../../src/cluster-alarm-config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AlarmConfigDefaults } from "@composurecdk/cloudwatch";
|
|
2
|
+
interface ClusterAlarmDefaults {
|
|
3
|
+
enabled: true;
|
|
4
|
+
cpuUtilization: AlarmConfigDefaults;
|
|
5
|
+
mainRequestQueuePendingRequests: AlarmConfigDefaults;
|
|
6
|
+
bufferCacheHitRatio: AlarmConfigDefaults;
|
|
7
|
+
clusterReplicaLag: AlarmConfigDefaults;
|
|
8
|
+
/** `threshold` is unused — the real value is derived from `maxCapacity` at build time. */
|
|
9
|
+
serverlessDatabaseCapacity: AlarmConfigDefaults;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Recommended default alarm configuration for Neptune clusters. Thresholds
|
|
13
|
+
* follow the Neptune team's metric guidance; Neptune is absent from the
|
|
14
|
+
* CloudWatch recommended-alarms table, so no anchor to that page exists.
|
|
15
|
+
*
|
|
16
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/best-practices-general-metrics.html
|
|
17
|
+
*/
|
|
18
|
+
export declare const CLUSTER_ALARM_DEFAULTS: ClusterAlarmDefaults;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=cluster-alarm-defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-alarm-defaults.d.ts","sourceRoot":"","sources":["../../src/cluster-alarm-defaults.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,UAAU,oBAAoB;IAC5B,OAAO,EAAE,IAAI,CAAC;IACd,cAAc,EAAE,mBAAmB,CAAC;IACpC,+BAA+B,EAAE,mBAAmB,CAAC;IACrD,mBAAmB,EAAE,mBAAmB,CAAC;IACzC,iBAAiB,EAAE,mBAAmB,CAAC;IACvC,0FAA0F;IAC1F,0BAA0B,EAAE,mBAAmB,CAAC;CACjD;AAED;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBA4CpC,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { TreatMissingData } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
/**
|
|
3
|
+
* Recommended default alarm configuration for Neptune clusters. Thresholds
|
|
4
|
+
* follow the Neptune team's metric guidance; Neptune is absent from the
|
|
5
|
+
* CloudWatch recommended-alarms table, so no anchor to that page exists.
|
|
6
|
+
*
|
|
7
|
+
* @see https://docs.aws.amazon.com/neptune/latest/userguide/best-practices-general-metrics.html
|
|
8
|
+
*/
|
|
9
|
+
export const CLUSTER_ALARM_DEFAULTS = {
|
|
10
|
+
enabled: true,
|
|
11
|
+
/** Sustained CPU at/above 80% over several minutes signals saturation. */
|
|
12
|
+
cpuUtilization: {
|
|
13
|
+
threshold: 80,
|
|
14
|
+
evaluationPeriods: 5,
|
|
15
|
+
datapointsToAlarm: 3,
|
|
16
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
17
|
+
},
|
|
18
|
+
/** A growing request backlog means the engine cannot keep up with load. */
|
|
19
|
+
mainRequestQueuePendingRequests: {
|
|
20
|
+
threshold: 100,
|
|
21
|
+
evaluationPeriods: 5,
|
|
22
|
+
datapointsToAlarm: 3,
|
|
23
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
24
|
+
},
|
|
25
|
+
/** A cache hit ratio below 99.9% indicates the working set exceeds memory. */
|
|
26
|
+
bufferCacheHitRatio: {
|
|
27
|
+
threshold: 99.9,
|
|
28
|
+
evaluationPeriods: 15,
|
|
29
|
+
datapointsToAlarm: 10,
|
|
30
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
31
|
+
},
|
|
32
|
+
/** Replica lag over 30s risks stale reads; quiet on single-instance clusters. */
|
|
33
|
+
clusterReplicaLag: {
|
|
34
|
+
threshold: 30_000,
|
|
35
|
+
evaluationPeriods: 5,
|
|
36
|
+
datapointsToAlarm: 3,
|
|
37
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
38
|
+
},
|
|
39
|
+
// `threshold` is a required-shape filler: the serverless capacity alarm
|
|
40
|
+
// always derives its threshold from `maxCapacity` at build time (or a user
|
|
41
|
+
// override), so this value is never read. The evaluation window is.
|
|
42
|
+
serverlessDatabaseCapacity: {
|
|
43
|
+
threshold: 0,
|
|
44
|
+
evaluationPeriods: 15,
|
|
45
|
+
datapointsToAlarm: 10,
|
|
46
|
+
treatMissingData: TreatMissingData.NOT_BREACHING,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=cluster-alarm-defaults.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-alarm-defaults.js","sourceRoot":"","sources":["../../src/cluster-alarm-defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAa9D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAyB;IAC1D,OAAO,EAAE,IAAI;IAEb,0EAA0E;IAC1E,cAAc,EAAE;QACd,SAAS,EAAE,EAAE;QACb,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;IAED,2EAA2E;IAC3E,+BAA+B,EAAE;QAC/B,SAAS,EAAE,GAAG;QACd,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;IAED,8EAA8E;IAC9E,mBAAmB,EAAE;QACnB,SAAS,EAAE,IAAI;QACf,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;IAED,iFAAiF;IACjF,iBAAiB,EAAE;QACjB,SAAS,EAAE,MAAM;QACjB,iBAAiB,EAAE,CAAC;QACpB,iBAAiB,EAAE,CAAC;QACpB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;IAED,wEAAwE;IACxE,2EAA2E;IAC3E,oEAAoE;IACpE,0BAA0B,EAAE;QAC1B,SAAS,EAAE,CAAC;QACZ,iBAAiB,EAAE,EAAE;QACrB,iBAAiB,EAAE,EAAE;QACrB,gBAAgB,EAAE,gBAAgB,CAAC,aAAa;KACjD;CACF,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import type { IDatabaseCluster, ServerlessScalingConfiguration } from "@aws-cdk/aws-neptune-alpha";
|
|
3
|
+
import type { IConstruct } from "constructs";
|
|
4
|
+
import type { AlarmDefinition, AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
5
|
+
import type { NeptuneClusterAlarmConfig } from "./cluster-alarm-config.js";
|
|
6
|
+
/**
|
|
7
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
8
|
+
* {@link AlarmDefinition}s for a Neptune cluster. The serverless capacity
|
|
9
|
+
* alarm is only emitted when `serverlessScaling` is provided.
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveClusterAlarmDefinitions(cluster: IDatabaseCluster, config: NeptuneClusterAlarmConfig | undefined, serverlessScaling: ServerlessScalingConfiguration | undefined): AlarmDefinition[];
|
|
12
|
+
/**
|
|
13
|
+
* Creates recommended CloudWatch alarms for a Neptune cluster, merging the
|
|
14
|
+
* recommended definitions with any custom alarm builders.
|
|
15
|
+
*
|
|
16
|
+
* @param scope - CDK construct scope for creating alarm constructs.
|
|
17
|
+
* @param id - Base identifier for alarm construct ids.
|
|
18
|
+
* @param cluster - The Neptune cluster to create alarms for.
|
|
19
|
+
* @param config - User-provided alarm configuration, or `false` to disable all.
|
|
20
|
+
* @param serverlessScaling - The cluster's serverless scaling config, if any.
|
|
21
|
+
* @param customAlarms - Custom alarm builders added via `addAlarm()`.
|
|
22
|
+
* @returns A record mapping alarm keys to their created Alarm constructs.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createClusterAlarms(scope: IConstruct, id: string, cluster: IDatabaseCluster, config: NeptuneClusterAlarmConfig | false | undefined, serverlessScaling: ServerlessScalingConfiguration | undefined, customAlarms?: AlarmDefinitionBuilder<IDatabaseCluster>[]): Record<string, Alarm>;
|
|
25
|
+
//# sourceMappingURL=cluster-alarms.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-alarms.d.ts","sourceRoot":"","sources":["../../src/cluster-alarms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,KAAK,EAAsB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAExF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAY3E;;;;GAIG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,yBAAyB,GAAG,SAAS,EAC7C,iBAAiB,EAAE,8BAA8B,GAAG,SAAS,GAC5D,eAAe,EAAE,CA4GnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,UAAU,EACjB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,yBAAyB,GAAG,KAAK,GAAG,SAAS,EACrD,iBAAiB,EAAE,8BAA8B,GAAG,SAAS,EAC7D,YAAY,GAAE,sBAAsB,CAAC,gBAAgB,CAAC,EAAO,GAC5D,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAUvB"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Duration } from "aws-cdk-lib";
|
|
2
|
+
import { ComparisonOperator } from "aws-cdk-lib/aws-cloudwatch";
|
|
3
|
+
import { createAlarms, resolveAlarmConfig } from "@composurecdk/cloudwatch";
|
|
4
|
+
import { CLUSTER_ALARM_DEFAULTS } from "./cluster-alarm-defaults.js";
|
|
5
|
+
const METRIC_PERIOD = Duration.minutes(1);
|
|
6
|
+
const METRIC_PERIOD_LABEL = `${String(METRIC_PERIOD.toMinutes())} minute`;
|
|
7
|
+
/**
|
|
8
|
+
* Fraction of a serverless cluster's configured `maxCapacity` at which the
|
|
9
|
+
* `serverlessDatabaseCapacity` alarm fires by default.
|
|
10
|
+
*/
|
|
11
|
+
const SERVERLESS_CAPACITY_ALARM_FRACTION = 0.9;
|
|
12
|
+
/**
|
|
13
|
+
* Resolves the recommended alarm configuration into fully-resolved
|
|
14
|
+
* {@link AlarmDefinition}s for a Neptune cluster. The serverless capacity
|
|
15
|
+
* alarm is only emitted when `serverlessScaling` is provided.
|
|
16
|
+
*/
|
|
17
|
+
export function resolveClusterAlarmDefinitions(cluster, config, serverlessScaling) {
|
|
18
|
+
if (config?.enabled === false)
|
|
19
|
+
return [];
|
|
20
|
+
const definitions = [];
|
|
21
|
+
if (config?.cpuUtilization !== false) {
|
|
22
|
+
const cfg = resolveAlarmConfig(config?.cpuUtilization, CLUSTER_ALARM_DEFAULTS.cpuUtilization);
|
|
23
|
+
definitions.push({
|
|
24
|
+
key: "cpuUtilization",
|
|
25
|
+
alarmName: cfg.alarmName,
|
|
26
|
+
metric: cluster.metric("CPUUtilization", { period: METRIC_PERIOD, statistic: "Average" }),
|
|
27
|
+
threshold: cfg.threshold,
|
|
28
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
29
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
30
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
31
|
+
treatMissingData: cfg.treatMissingData,
|
|
32
|
+
description: `Neptune cluster CPU utilization is high. Threshold: >= ${String(cfg.threshold)}% over ${METRIC_PERIOD_LABEL} periods.`,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (config?.mainRequestQueuePendingRequests !== false) {
|
|
36
|
+
const cfg = resolveAlarmConfig(config?.mainRequestQueuePendingRequests, CLUSTER_ALARM_DEFAULTS.mainRequestQueuePendingRequests);
|
|
37
|
+
definitions.push({
|
|
38
|
+
key: "mainRequestQueuePendingRequests",
|
|
39
|
+
alarmName: cfg.alarmName,
|
|
40
|
+
metric: cluster.metric("MainRequestQueuePendingRequests", {
|
|
41
|
+
period: METRIC_PERIOD,
|
|
42
|
+
statistic: "Average",
|
|
43
|
+
}),
|
|
44
|
+
threshold: cfg.threshold,
|
|
45
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD,
|
|
46
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
47
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
48
|
+
treatMissingData: cfg.treatMissingData,
|
|
49
|
+
description: `Neptune cluster request queue is backing up. Threshold: > ${String(cfg.threshold)} pending requests over ${METRIC_PERIOD_LABEL} periods.`,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
if (config?.bufferCacheHitRatio !== false) {
|
|
53
|
+
const cfg = resolveAlarmConfig(config?.bufferCacheHitRatio, CLUSTER_ALARM_DEFAULTS.bufferCacheHitRatio);
|
|
54
|
+
definitions.push({
|
|
55
|
+
key: "bufferCacheHitRatio",
|
|
56
|
+
alarmName: cfg.alarmName,
|
|
57
|
+
metric: cluster.metric("BufferCacheHitRatio", {
|
|
58
|
+
period: METRIC_PERIOD,
|
|
59
|
+
statistic: "Average",
|
|
60
|
+
}),
|
|
61
|
+
threshold: cfg.threshold,
|
|
62
|
+
comparisonOperator: ComparisonOperator.LESS_THAN_THRESHOLD,
|
|
63
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
64
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
65
|
+
treatMissingData: cfg.treatMissingData,
|
|
66
|
+
description: `Neptune cluster buffer cache hit ratio is low; working set may exceed memory. Threshold: < ${String(cfg.threshold)}% over ${METRIC_PERIOD_LABEL} periods.`,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (config?.clusterReplicaLag !== false) {
|
|
70
|
+
const cfg = resolveAlarmConfig(config?.clusterReplicaLag, CLUSTER_ALARM_DEFAULTS.clusterReplicaLag);
|
|
71
|
+
definitions.push({
|
|
72
|
+
key: "clusterReplicaLag",
|
|
73
|
+
alarmName: cfg.alarmName,
|
|
74
|
+
metric: cluster.metric("ClusterReplicaLag", { period: METRIC_PERIOD, statistic: "Average" }),
|
|
75
|
+
threshold: cfg.threshold,
|
|
76
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_THRESHOLD,
|
|
77
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
78
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
79
|
+
treatMissingData: cfg.treatMissingData,
|
|
80
|
+
description: `Neptune read replica is lagging the writer. Threshold: > ${String(cfg.threshold)} ms over ${METRIC_PERIOD_LABEL} periods.`,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// Contextual: only meaningful for a serverless cluster, where capacity is
|
|
84
|
+
// measured in NCUs and a ceiling is configured. The threshold defaults to a
|
|
85
|
+
// fraction of the configured maximum.
|
|
86
|
+
if (serverlessScaling !== undefined && config?.serverlessDatabaseCapacity !== false) {
|
|
87
|
+
const cfg = resolveAlarmConfig(config?.serverlessDatabaseCapacity, CLUSTER_ALARM_DEFAULTS.serverlessDatabaseCapacity);
|
|
88
|
+
const threshold = config?.serverlessDatabaseCapacity?.threshold ??
|
|
89
|
+
serverlessScaling.maxCapacity * SERVERLESS_CAPACITY_ALARM_FRACTION;
|
|
90
|
+
definitions.push({
|
|
91
|
+
key: "serverlessDatabaseCapacity",
|
|
92
|
+
alarmName: cfg.alarmName,
|
|
93
|
+
metric: cluster.metric("ServerlessDatabaseCapacity", {
|
|
94
|
+
period: METRIC_PERIOD,
|
|
95
|
+
statistic: "Average",
|
|
96
|
+
}),
|
|
97
|
+
threshold,
|
|
98
|
+
comparisonOperator: ComparisonOperator.GREATER_THAN_OR_EQUAL_TO_THRESHOLD,
|
|
99
|
+
evaluationPeriods: cfg.evaluationPeriods,
|
|
100
|
+
datapointsToAlarm: cfg.datapointsToAlarm,
|
|
101
|
+
treatMissingData: cfg.treatMissingData,
|
|
102
|
+
description: `Neptune serverless capacity is sustained near its ${String(serverlessScaling.maxCapacity)} NCU ceiling. Threshold: >= ${String(threshold)} NCU over ${METRIC_PERIOD_LABEL} periods.`,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return definitions;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates recommended CloudWatch alarms for a Neptune cluster, merging the
|
|
109
|
+
* recommended definitions with any custom alarm builders.
|
|
110
|
+
*
|
|
111
|
+
* @param scope - CDK construct scope for creating alarm constructs.
|
|
112
|
+
* @param id - Base identifier for alarm construct ids.
|
|
113
|
+
* @param cluster - The Neptune cluster to create alarms for.
|
|
114
|
+
* @param config - User-provided alarm configuration, or `false` to disable all.
|
|
115
|
+
* @param serverlessScaling - The cluster's serverless scaling config, if any.
|
|
116
|
+
* @param customAlarms - Custom alarm builders added via `addAlarm()`.
|
|
117
|
+
* @returns A record mapping alarm keys to their created Alarm constructs.
|
|
118
|
+
*/
|
|
119
|
+
export function createClusterAlarms(scope, id, cluster, config, serverlessScaling, customAlarms = []) {
|
|
120
|
+
if (config === false)
|
|
121
|
+
return {};
|
|
122
|
+
const enabled = config?.enabled ?? CLUSTER_ALARM_DEFAULTS.enabled;
|
|
123
|
+
if (!enabled)
|
|
124
|
+
return {};
|
|
125
|
+
const recommended = resolveClusterAlarmDefinitions(cluster, config, serverlessScaling);
|
|
126
|
+
const custom = customAlarms.map((b) => b.resolve(cluster));
|
|
127
|
+
return createAlarms(scope, id, [...recommended, ...custom]);
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=cluster-alarms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-alarms.js","sourceRoot":"","sources":["../../src/cluster-alarms.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAc,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAI5E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAErE,MAAM,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAC1C,MAAM,mBAAmB,GAAG,GAAG,MAAM,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,SAAS,CAAC;AAE1E;;;GAGG;AACH,MAAM,kCAAkC,GAAG,GAAG,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,OAAyB,EACzB,MAA6C,EAC7C,iBAA6D;IAE7D,IAAI,MAAM,EAAE,OAAO,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;I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U,mBAAmB,CACjC,KAAiB,EACjB,EAAU,EACV,OAAyB,EACzB,MAAqD,EACrD,iBAA6D,EAC7D,eAA2D,EAAE;IAE7D,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,EAAE,CAAC;IAEhC,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC;IAClE,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IAExB,MAAM,WAAW,GAAG,8BAA8B,CAAC,OAAO,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACvF,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;IAE3D,OAAO,YAAY,CAAC,KAAK,EAAE,EAAE,EAAE,CAAC,GAAG,WAAW,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { type Alarm } from "aws-cdk-lib/aws-cloudwatch";
|
|
2
|
+
import { type IConnectable, type ISecurityGroup, type IVpc } from "aws-cdk-lib/aws-ec2";
|
|
3
|
+
import { type IGrantable } from "aws-cdk-lib/aws-iam";
|
|
4
|
+
import { DatabaseCluster, type DatabaseClusterProps, type IClusterParameterGroup, type IDatabaseCluster, type ISubnetGroup } from "@aws-cdk/aws-neptune-alpha";
|
|
5
|
+
import { type IConstruct } from "constructs";
|
|
6
|
+
import { COPY_STATE, type Lifecycle, type Resolvable } from "@composurecdk/core";
|
|
7
|
+
import { type ITaggedBuilder } from "@composurecdk/cloudformation";
|
|
8
|
+
import { AlarmDefinitionBuilder } from "@composurecdk/cloudwatch";
|
|
9
|
+
import type { NeptuneClusterAlarmConfig } from "./cluster-alarm-config.js";
|
|
10
|
+
/**
|
|
11
|
+
* A principal that can be granted access to a Neptune cluster via
|
|
12
|
+
* {@link IClusterBuilder.allowAccessFrom}. Must be both an {@link IConnectable}
|
|
13
|
+
* (so its security group can be opened to the cluster's port) and an
|
|
14
|
+
* {@link IGrantable} (so it can be granted IAM `connect`). EC2 instances,
|
|
15
|
+
* Lambda functions, and Fargate tasks all satisfy this.
|
|
16
|
+
*/
|
|
17
|
+
export type ClusterAccessor = IConnectable & IGrantable;
|
|
18
|
+
/**
|
|
19
|
+
* Configuration properties for the Neptune cluster builder.
|
|
20
|
+
*
|
|
21
|
+
* Extends the CDK {@link DatabaseClusterProps} but lifts the
|
|
22
|
+
* cross-component-wiring props to {@link Resolvable} so they can be supplied
|
|
23
|
+
* as either concrete values or {@link Ref}s to sibling components in a
|
|
24
|
+
* {@link compose}d system:
|
|
25
|
+
*
|
|
26
|
+
* - `vpc` is supplied via the dedicated {@link IClusterBuilder.vpc | .vpc()}
|
|
27
|
+
* method (it is required).
|
|
28
|
+
* - `securityGroups` accepts `Resolvable<ISecurityGroup>` entries.
|
|
29
|
+
*
|
|
30
|
+
* It also adds builder-specific options for the auto-created cluster
|
|
31
|
+
* parameter group and recommended alarms.
|
|
32
|
+
*/
|
|
33
|
+
export interface ClusterBuilderProps extends Omit<DatabaseClusterProps, "vpc" | "securityGroups"> {
|
|
34
|
+
/**
|
|
35
|
+
* Security groups to attach to the cluster. Accepts concrete
|
|
36
|
+
* {@link ISecurityGroup}s or {@link Ref}s that resolve to them at build
|
|
37
|
+
* time (e.g. a sibling `SecurityGroupBuilder`).
|
|
38
|
+
*
|
|
39
|
+
* @default - CDK creates a security group for the cluster.
|
|
40
|
+
*/
|
|
41
|
+
securityGroups?: readonly Resolvable<ISecurityGroup>[];
|
|
42
|
+
/**
|
|
43
|
+
* Parameters to set on the auto-created cluster parameter group, merged
|
|
44
|
+
* onto (and overriding) {@link CLUSTER_PARAMETER_GROUP_DEFAULTS}. Use this
|
|
45
|
+
* to tune engine behaviour without managing a parameter group yourself.
|
|
46
|
+
*
|
|
47
|
+
* Mutually exclusive with `clusterParameterGroup`: a user-managed group is
|
|
48
|
+
* not built (or mutated) by this builder.
|
|
49
|
+
*/
|
|
50
|
+
clusterParameters?: Record<string, string>;
|
|
51
|
+
/**
|
|
52
|
+
* Configuration for recommended CloudWatch alarms.
|
|
53
|
+
*
|
|
54
|
+
* By default the builder creates recommended alarms with sensible
|
|
55
|
+
* thresholds for every applicable metric. Individual alarms can be
|
|
56
|
+
* customized or disabled. Set to `false` to disable all alarms.
|
|
57
|
+
*
|
|
58
|
+
* No alarm actions are configured by default since notification methods
|
|
59
|
+
* are user-specific. Access alarms from the build result or use an
|
|
60
|
+
* `afterBuild` hook to apply actions.
|
|
61
|
+
*/
|
|
62
|
+
recommendedAlarms?: NeptuneClusterAlarmConfig | false;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The build output of an {@link IClusterBuilder}. Contains the CDK
|
|
66
|
+
* constructs created during {@link Lifecycle.build}, keyed by role.
|
|
67
|
+
*/
|
|
68
|
+
export interface ClusterBuilderResult {
|
|
69
|
+
/** The Neptune cluster, including the writer/reader instances it manages. */
|
|
70
|
+
cluster: DatabaseCluster;
|
|
71
|
+
/**
|
|
72
|
+
* The DB subnet group the cluster runs in. CDK auto-creates this from the
|
|
73
|
+
* VPC; it is exposed here so it can be reused or asserted against.
|
|
74
|
+
*/
|
|
75
|
+
subnetGroup: ISubnetGroup;
|
|
76
|
+
/**
|
|
77
|
+
* The cluster parameter group — either the one supplied via
|
|
78
|
+
* `.clusterParameterGroup()` or the audit-log-enabled group the builder
|
|
79
|
+
* auto-creates.
|
|
80
|
+
*/
|
|
81
|
+
clusterParameterGroup: IClusterParameterGroup;
|
|
82
|
+
/**
|
|
83
|
+
* CloudWatch alarms created for the cluster, keyed by alarm key (e.g.
|
|
84
|
+
* `result.alarms.cpuUtilization`). Includes recommended alarms and any
|
|
85
|
+
* added via {@link IClusterBuilder.addAlarm}. No alarm actions are
|
|
86
|
+
* configured — apply them via the result or an `afterBuild` hook.
|
|
87
|
+
*/
|
|
88
|
+
alarms: Record<string, Alarm>;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A fluent builder for configuring and creating an Amazon Neptune cluster.
|
|
92
|
+
*
|
|
93
|
+
* Each configuration property from the CDK {@link DatabaseClusterProps} is
|
|
94
|
+
* exposed as an overloaded method: call with a value to set it (returns the
|
|
95
|
+
* builder for chaining), or call with no arguments to read the current value.
|
|
96
|
+
*
|
|
97
|
+
* The `vpc` is set via the dedicated {@link IClusterBuilder.vpc | .vpc()}
|
|
98
|
+
* method, which accepts a {@link Resolvable} for cross-component wiring (e.g.
|
|
99
|
+
* to a sibling `VpcBuilder`). `securityGroups` likewise accept
|
|
100
|
+
* {@link Resolvable} values.
|
|
101
|
+
*
|
|
102
|
+
* The builder implements {@link Lifecycle}, so it can be used directly as a
|
|
103
|
+
* component in a {@link compose | composed system}. When built it creates a
|
|
104
|
+
* cluster with {@link CLUSTER_DEFAULTS | well-architected defaults}, an
|
|
105
|
+
* audit-log-enabled cluster parameter group, recommended CloudWatch alarms,
|
|
106
|
+
* and returns a {@link ClusterBuilderResult}.
|
|
107
|
+
*
|
|
108
|
+
* Both provisioned and serverless clusters are supported — set a provisioned
|
|
109
|
+
* `.instanceType(InstanceType.R6G_LARGE)`, or `.instanceType(InstanceType.SERVERLESS)`
|
|
110
|
+
* with `.serverlessScalingConfiguration({ minCapacity, maxCapacity })`.
|
|
111
|
+
*
|
|
112
|
+
* @see https://docs.aws.amazon.com/cdk/api/v2/docs/aws-neptune-alpha-readme.html
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const graph = createClusterBuilder()
|
|
117
|
+
* .vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
118
|
+
* .instanceType(InstanceType.SERVERLESS)
|
|
119
|
+
* .serverlessScalingConfiguration({ minCapacity: 1, maxCapacity: 8 });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export type IClusterBuilder = ITaggedBuilder<ClusterBuilderProps, ClusterBuilder>;
|
|
123
|
+
declare class ClusterBuilder implements Lifecycle<ClusterBuilderResult> {
|
|
124
|
+
#private;
|
|
125
|
+
props: Partial<ClusterBuilderProps>;
|
|
126
|
+
/**
|
|
127
|
+
* Sets the VPC the cluster runs in. Required. Accepts a concrete
|
|
128
|
+
* {@link IVpc} or a {@link Ref} that resolves to one at build time — the
|
|
129
|
+
* standard cross-component wiring path (e.g. to a sibling `VpcBuilder`).
|
|
130
|
+
*
|
|
131
|
+
* @param vpc - The VPC or a Ref to one.
|
|
132
|
+
* @returns This builder for chaining.
|
|
133
|
+
*/
|
|
134
|
+
vpc(vpc: Resolvable<IVpc>): this;
|
|
135
|
+
/**
|
|
136
|
+
* Grants a principal both network and IAM access to the cluster in a single
|
|
137
|
+
* declaration. At build time this applies
|
|
138
|
+
* `cluster.connections.allowDefaultPortFrom(peer)` (opening the cluster's
|
|
139
|
+
* port to the peer's security group) and `cluster.grantConnect(peer)`
|
|
140
|
+
* (granting the IAM `connect` action required by the cluster's
|
|
141
|
+
* IAM-authentication default).
|
|
142
|
+
*
|
|
143
|
+
* Accepts a concrete {@link ClusterAccessor} or a {@link Ref} to one, so the
|
|
144
|
+
* grant can be declared inside `compose()` rather than wired up in an
|
|
145
|
+
* `afterBuild` hook.
|
|
146
|
+
*
|
|
147
|
+
* @param peer - The principal to grant access to, or a Ref to one.
|
|
148
|
+
* @returns This builder for chaining.
|
|
149
|
+
*/
|
|
150
|
+
allowAccessFrom(peer: Resolvable<ClusterAccessor>): this;
|
|
151
|
+
/**
|
|
152
|
+
* Adds a custom CloudWatch alarm to be created alongside the recommended
|
|
153
|
+
* alarms. The callback receives an {@link AlarmDefinitionBuilder} scoped to
|
|
154
|
+
* the built cluster; configure it fluently and return it.
|
|
155
|
+
*
|
|
156
|
+
* @param key - A unique key for the alarm (used to generate the alarm id).
|
|
157
|
+
* @param configure - Callback that configures the alarm definition.
|
|
158
|
+
* @returns This builder for chaining.
|
|
159
|
+
*/
|
|
160
|
+
addAlarm(key: string, configure: (alarm: AlarmDefinitionBuilder<IDatabaseCluster>) => AlarmDefinitionBuilder<IDatabaseCluster>): this;
|
|
161
|
+
/** @internal — see ADR-0005. */
|
|
162
|
+
[COPY_STATE](target: ClusterBuilder): void;
|
|
163
|
+
build(scope: IConstruct, id: string, context?: Record<string, object>): ClusterBuilderResult;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Creates a new {@link IClusterBuilder} for configuring an Amazon Neptune
|
|
167
|
+
* cluster.
|
|
168
|
+
*
|
|
169
|
+
* This is the entry point for defining a Neptune component. The returned
|
|
170
|
+
* builder exposes every {@link ClusterBuilderProps} property as a fluent
|
|
171
|
+
* setter/getter, plus {@link IClusterBuilder.vpc | .vpc()} and
|
|
172
|
+
* {@link IClusterBuilder.allowAccessFrom | .allowAccessFrom()} for
|
|
173
|
+
* cross-component wiring with Ref support. It implements {@link Lifecycle}
|
|
174
|
+
* for use with {@link compose}.
|
|
175
|
+
*
|
|
176
|
+
* @returns A fluent builder for an Amazon Neptune cluster.
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* const system = compose(
|
|
181
|
+
* {
|
|
182
|
+
* network: createVpcBuilder().maxAzs(2),
|
|
183
|
+
* graph: createClusterBuilder()
|
|
184
|
+
* .vpc(ref<VpcBuilderResult>("network").get("vpc"))
|
|
185
|
+
* .instanceType(InstanceType.SERVERLESS)
|
|
186
|
+
* .serverlessScalingConfiguration({ minCapacity: 1, maxCapacity: 8 }),
|
|
187
|
+
* },
|
|
188
|
+
* { network: [], graph: ["network"] },
|
|
189
|
+
* );
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
export declare function createClusterBuilder(): IClusterBuilder;
|
|
193
|
+
export {};
|
|
194
|
+
//# sourceMappingURL=cluster-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cluster-builder.d.ts","sourceRoot":"","sources":["../../src/cluster-builder.ts"],"names":[],"mappings":"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