@@ -16,13 +16,14 @@ Easy-to-use CDK constructs for monitoring your AWS infrastructure.
1616* Extend the library with your own extensions or custom metrics
1717* Consume the library in multiple languages (see below)
1818
19- ## Usage
2019
21- ### TypeScript (NPM)
20+ ## Installation
21+
22+ <details ><summary ><strong >TypeScript</strong ></summary >
2223
2324> https://www.npmjs.com/package/cdk-monitoring-constructs
2425
25- Add the dependency to your ` package.json ` :
26+ In your ` package.json ` :
2627
2728``` json
2829{
@@ -37,8 +38,9 @@ Add the dependency to your `package.json`:
3738 }
3839}
3940```
41+ </details >
4042
41- ### Java
43+ < details >< summary >< strong > Java</ strong ></ summary >
4244
4345> https://mvnrepository.com/artifact/io.github.cdklabs/cdkmonitoringconstructs
4446
@@ -59,18 +61,22 @@ Add the following Maven project to your `pom.xml`:
5961``` kotlin
6062implementation(" io.github.cdklabs:cdkmonitoringconstructs:0.0.11" )
6163```
64+ </details >
6265
63- ### Python (PyPi)
66+ < details >< summary >< strong > Python</ strong ></ summary >
6467
6568> https://pypi.org/project/cdk-monitoring-constructs/
6669
6770TODO: describe usage
71+ </details >
6872
69- ### C# (Nuget)
73+ < details >< summary >< strong >C#</ strong ></ summary >
7074
7175> https://www.nuget.org/packages/Cdklabs.CdkMonitoringConstructs/
7276
7377TODO: describe usage
78+ </details >
79+
7480
7581## Features
7682
@@ -110,10 +116,105 @@ You can also browse the documentation at https://constructs.dev/packages/cdk-mon
110116| CloudWatch Logs (` .monitorLog() ` ) | Patterns present in the log group | | |
111117| Custom metrics (` .monitorCustom() ` ) | Addition of custom metrics into the dashboard (each group is a widget) | | Supports anomaly detection |
112118
119+
120+ ## Getting started
121+
122+ ### Create monitoring stack and facade
123+
124+ _ Important note_ : ** Please, do NOT import anything from the ` /dist/lib ` package.** This is unsupported and might break any time.
125+
126+ Create an instance of ` MonitoringFacade ` , which is the main entry point:
127+
128+ ``` ts
129+ export interface MonitoringStackProps extends DeploymentStackProps {
130+ // ...
131+ }
132+
133+ export class MonitoringStack extends DeploymentStack {
134+ constructor (parent : App , name : string , props : MonitoringStackProps ) {
135+ super (parent , name , props );
136+
137+ const monitoring = new MonitoringFacade (this , " Monitoring" , {
138+ // Define all necessary props
139+ });
140+
141+ // Setup your monitoring
142+ monitoring
143+ .addLargeHeader (" Storage" )
144+ .monitorDynamoTable ({ /* table1 */ })
145+ .monitorDynamoTable ({ /* table2 */ })
146+ .monitorDynamoTable ({ /* table3 */ })
147+ // ...and more
148+ }
149+ }
150+ ```
151+
152+ ### Set up your monitoring
153+
154+ Once the facade is created, you can use it to call methods like ` .monitorLambdaFunction() ` and chain them together to define your monitors.
155+
156+ You can also use facade methods to add your own widgets, headers of various sizes, and more.
157+
158+
159+ ### Customize actions
160+
161+ Alarms should have an action setup, otherwise they are not very useful. Currently, we support notifying an SNS queue.
162+
163+ ``` ts
164+ const onAlarmTopic = new Topic (this , " AlarmTopic" );
165+
166+ const monitoring = new MonitoringFacade (this , " Monitoring" , {
167+ // ...other props
168+ alarmFactoryDefaults: {
169+ // ....other props
170+ action: new SnsAlarmActionStrategy ({ onAlarmTopic }),
171+ },
172+ });
173+ ```
174+
175+ You can override the default topic for any alarm like this:
176+
177+ ``` ts
178+ monitoring
179+ .monitorSomething (something , {
180+ addSomeAlarm: {
181+ Warning: {
182+ // ...other props
183+ threshold: 42 ,
184+ actionOverride: new SnsAlarmActionStrategy ({ onAlarmTopic }),
185+ }
186+ }
187+ });
188+ ```
189+
190+ ### Custom metrics
191+
192+ For simply adding some custom metrics, you can use ` .monitorCustom() ` and specify your own title and metric groups.
193+ Each metric group will be rendered as a single graph widget, and all widgets will be placed next to each other.
194+ All the widgets will have the same size, which is chosen based on the number of groups to maximize dashboard space usage.
195+
196+ Custom metric monitoring can be created for simple metrics, simple metrics with anomaly detection and search metrics.
197+ The first two also support alarming.
198+
199+ ### Custom monitoring
200+
201+ If you want even more flexibility, you can create your own Dashboard Segment.
202+
203+ This is a general procedure on how to do it:
204+
205+ 1 . Extend the ` Monitoring ` ckass
206+ 1 . Override the ` widgets() ` method (and/or similar ones)
207+ 1 . Leverage the metric factor and alarm factory, provided by the base class (you can create additional factories, if you will)
208+ 1 . Add all alarms to ` .addAlarm() ` so they are visible to the user and being placed on the alarm summary dashboard
209+
210+ Both of these monitoring base classes are dashboard segments, so you can add them to your monitoring by calling ` .addSegment() ` .
211+
212+
113213## Contributing/Security
114214
115215See [ CONTRIBUTING] ( CONTRIBUTING.md ) for more information.
116216
217+
117218## License
118219
119220This project is licensed under the Apache-2.0 License.
0 commit comments