Skip to content

Commit 6e04b20

Browse files
author
Eugene Cheung
authored
chore(docs): minor doc cleanup (#344)
Related to #343 --- _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license_
1 parent 71b1c5c commit 6e04b20

File tree

11 files changed

+122
-131
lines changed

11 files changed

+122
-131
lines changed

API.md

Lines changed: 20 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-ready--to--code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/cdklabs/cdk-monitoring-constructs)
88
[![Mergify](https://img.shields.io/endpoint.svg?url=https://gh.mergify.io/badges/cdklabs/cdk-monitoring-constructs&style=flat)](https://mergify.io)
99

10-
Easy-to-use CDK constructs for monitoring your AWS infrastructure.
10+
Easy-to-use CDK constructs for monitoring your AWS infrastructure with [Amazon CloudWatch](https://aws.amazon.com/cloudwatch/).
1111

1212
* Easily add commonly-used alarms using predefined properties
13-
* Generate concise Cloudwatch dashboards that indicate your alarms
13+
* Generate concise CloudWatch dashboards that indicate your alarms
1414
* Extend the library with your own extensions or custom metrics
15-
* Consume the library in multiple languages (see below)
15+
* Consume the library in multiple supported languages
1616

1717

1818
## Installation
@@ -56,11 +56,6 @@ See https://pypi.org/project/cdk-monitoring-constructs/
5656
See https://www.nuget.org/packages/Cdklabs.CdkMonitoringConstructs/
5757
</details>
5858

59-
<details><summary><strong>Golang</strong></summary>
60-
61-
Coming soon!
62-
</details>
63-
6459

6560
## Features
6661

@@ -104,17 +99,21 @@ You can browse the documentation at https://constructs.dev/packages/cdk-monitori
10499

105100
## Getting started
106101

107-
### Create monitoring stack and facade
102+
### Create a facade
108103

109104
_Important note_: **Please, do NOT import anything from the `/dist/lib` package.** This is unsupported and might break any time.
110105

111-
Create an instance of `MonitoringFacade`, which is the main entry point:
106+
1. Create an instance of `MonitoringFacade`, which is the main entrypoint.
107+
1. Call methods on the facade like `.monitorLambdaFunction()` and chain them together to define your monitors. You can also use methods to add your own widgets, headers of various sizes, and more.
108+
109+
For examples of monitoring different resources, refer to [the unit tests](https://github.com/cdklabs/cdk-monitoring-constructs/tree/main/test/monitoring).
112110

113111
```ts
114112
export interface MonitoringStackProps extends DeploymentStackProps {
115113
// ...
116114
}
117115

116+
// This could be in the same stack as your resources, as a nested stack, or a separate stack as you see fit
118117
export class MonitoringStack extends DeploymentStack {
119118
constructor(parent: App, name: string, props: MonitoringStackProps) {
120119
super(parent, name, props);
@@ -129,21 +128,15 @@ export class MonitoringStack extends DeploymentStack {
129128
// Monitor your resources
130129
monitoring
131130
.addLargeHeader("Storage")
132-
.monitorDynamoTable({ /* table1 */ })
133-
.monitorDynamoTable({ /* table2 */ })
134-
.monitorDynamoTable({ /* table3 */ })
135-
// etc.
131+
.monitorDynamoTable({ /* Monitor a DynamoDB table */ })
132+
.monitorDynamoTable({ /* and a different table */ })
133+
.monitorLambdaFunction({ /* and a Lambda function */ })
134+
.monitorCustom({ /* and some arbitrary metrics in CloudWatch */ })
135+
// ... etc.
136136
}
137137
}
138138
```
139139

140-
### Set up your monitoring
141-
142-
Once the facade is created, you can use it to call methods like `.monitorLambdaFunction()` and chain them together to define your monitors.
143-
144-
You can also use facade methods to add your own widgets, headers of various sizes, and more.
145-
146-
147140
### Customize actions
148141

149142
Alarms should have an action setup, otherwise they are not very useful. Currently, we support notifying an SNS queue.
@@ -257,33 +250,28 @@ monitorCustom({
257250
})
258251
```
259252

260-
Search metric does not support setting an alarm, that is a CloudWatch limitation.
253+
Search metrics do not support setting an alarm, which is a CloudWatch limitation.
261254

262-
### Custom monitoring segment
255+
### Custom monitoring segments
263256

264-
If you want even more flexibility, you can create your own Dashboard Segment.
257+
If you want even more flexibility, you can create your own segment.
265258

266259
This is a general procedure on how to do it:
267260

268261
1. Extend the `Monitoring` class
269262
1. Override the `widgets()` method (and/or similar ones)
270-
1. Leverage the metric factor and alarm factory, provided by the base class (you can create additional factories, if you will)
263+
1. Leverage the metric factory and alarm factory provided by the base class (you can create additional factories, if you will)
271264
1. Add all alarms to `.addAlarm()` so they are visible to the user and being placed on the alarm summary dashboard
272265

273-
Both of these monitoring base classes are dashboard segments, so you can add them to your monitoring by calling `.addSegment()`.
274-
275-
### Monitoring Scopes
276-
277-
With CDK Monitoring Constructs, you can monitor complete CDK construct scopes. It will automatically discover all monitorable resources within the scope (recursively)) and add them to your dashboard.
266+
Both of these monitoring base classes are dashboard segments, so you can add them to your monitoring by calling `.addSegment()` on the `MonitoringFacade`.
278267

279-
```ts
280-
monitoring.monitorScope(stack);
281-
```
268+
### Monitoring scopes
282269

283-
You can also specify default alarms for any specific resource and disable automatic monitoring for it as well.
270+
You can monitor complete CDK construct scopes using an aspect. It will automatically discover all monitorable resources within the scope recursively and add them to your dashboard.
284271

285272
```ts
286273
monitoring.monitorScope(stack, {
274+
// With optional configuration
287275
lambda: {
288276
props: {
289277
addLatencyP50Alarm: {
@@ -293,13 +281,14 @@ monitoring.monitorScope(stack, {
293281
},
294282

295283
// Some resources that aren't dependent on nodes (e.g. general metrics across instances/account) may be included
296-
// by default, but can be explicitly disabled.
284+
// by default, which can be explicitly disabled.
297285
billing: { enabled: false },
298286
ec2: { enabled: false },
299287
elasticCache: { enabled: false },
300288
});
301289
```
302290

291+
303292
## Contributing/Security
304293

305294
See [CONTRIBUTING](CONTRIBUTING.md) for more information.

lib/common/monitoring/Monitoring.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,23 @@ import {
88
} from "../../dashboard";
99
import { AlarmWithAnnotation } from "../alarm";
1010

11+
export interface IAlarmConsumer {
12+
consume(alarms: AlarmWithAnnotation[]): void;
13+
}
14+
15+
/**
16+
* Base class for properties passed to each monitoring construct.
17+
* It contains (mostly optional) properties to specify naming, placement, and so on.
18+
*/
19+
export interface BaseMonitoringProps
20+
extends UserProvidedNames,
21+
MonitoringDashboardsOverrideProps {
22+
/**
23+
* Calls provided function to process all alarms created.
24+
*/
25+
readonly useCreatedAlarms?: IAlarmConsumer;
26+
}
27+
1128
/**
1229
* An independent unit of monitoring. This is the base for all monitoring classes with alarm support.
1330
*/
@@ -85,20 +102,3 @@ export abstract class Monitoring implements IDashboardSegment {
85102
*/
86103
abstract widgets(): IWidget[];
87104
}
88-
89-
export interface IAlarmConsumer {
90-
consume(alarms: AlarmWithAnnotation[]): void;
91-
}
92-
93-
/**
94-
* Base class for properties passed to each monitoring construct.
95-
* It contains (mostly optional) properties to specify naming, placement, and so on.
96-
*/
97-
export interface BaseMonitoringProps
98-
extends UserProvidedNames,
99-
MonitoringDashboardsOverrideProps {
100-
/**
101-
* Calls provided function to process all alarms created.
102-
*/
103-
readonly useCreatedAlarms?: IAlarmConsumer;
104-
}

lib/common/monitoring/MonitoringScope.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import { MetricFactory } from "../metric";
66
import { AwsConsoleUrlFactory } from "../url";
77

88
/**
9-
* A scope (construct) where all monitoring constructs are living in.
9+
* A scope where all the monitoring of constructs is managed (alarms, dashboards, etc.).
10+
*
11+
* Standard usages will use {@link MonitoringFacade}.
1012
*/
1113
export abstract class MonitoringScope extends Construct {
1214
/**
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* Preferred way of rendering dashboard widgets.
3+
*/
4+
export enum DashboardRenderingPreference {
5+
/**
6+
* Create standard set of dashboards with interactive widgets only
7+
*/
8+
INTERACTIVE_ONLY,
9+
10+
/**
11+
* Create standard set of dashboards with bitmap widgets only
12+
*/
13+
BITMAP_ONLY,
14+
15+
/**
16+
* Create a two sets of dashboards: standard set (interactive) and a copy (bitmap)
17+
*/
18+
INTERACTIVE_AND_BITMAP,
19+
}

lib/dashboard/DefaultDashboardFactory.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,10 @@ import {
77
import { Construct } from "constructs";
88

99
import { BitmapDashboard } from "./BitmapDashboard";
10+
import { DashboardRenderingPreference } from "./DashboardRenderingPreference";
1011
import { DashboardWithBitmapCopy } from "./DashboardWithBitmapCopy";
1112
import { IDashboardFactory, IDashboardFactoryProps } from "./IDashboardFactory";
1213

13-
/**
14-
* Preferred way of rendering the widgets.
15-
*/
16-
export enum DashboardRenderingPreference {
17-
/**
18-
* create standard set of dashboards with interactive widgets only
19-
*/
20-
INTERACTIVE_ONLY,
21-
/**
22-
* create standard set of dashboards with bitmap widgets only
23-
*/
24-
BITMAP_ONLY,
25-
/**
26-
* create a two sets of dashboards: standard set (interactive) and a copy (bitmap)
27-
*/
28-
INTERACTIVE_AND_BITMAP,
29-
}
30-
3114
export interface MonitoringDashboardsProps {
3215
/**
3316
* Prefix added to each dashboard name.

lib/dashboard/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from "./BitmapDashboard";
2+
export * from "./DashboardRenderingPreference";
23
export * from "./DashboardSegment";
34
export * from "./DashboardWithBitmapCopy";
45
export * from "./DefaultDashboardFactory";
File renamed without changes.

lib/facade/MonitoringAspect.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ import * as stepfunctions from "aws-cdk-lib/aws-stepfunctions";
2626
import * as wafv2 from "aws-cdk-lib/aws-wafv2";
2727
import { IConstruct } from "constructs";
2828

29-
import { MonitoringAspectProps, MonitoringAspectType } from "./aspect-types";
29+
import {
30+
MonitoringAspectProps,
31+
MonitoringAspectType,
32+
} from "./IMonitoringAspect";
3033
import { MonitoringFacade } from "./MonitoringFacade";
3134
import { ElastiCacheClusterType } from "../monitoring";
3235

@@ -394,5 +397,3 @@ export class MonitoringAspect implements IAspect {
394397
}
395398
}
396399
}
397-
398-
export * from "./aspect-types";

0 commit comments

Comments
 (0)