Skip to content

Commit 6f15302

Browse files
vohoEugene Cheung
andauthored
chore: add detailed documentation of custom monitoring [skip ci] (#183)
* feat: add detailed documentation of custom monitoring * chore: fixed wording in anomaly detection custom metric description Co-authored-by: Eugene Cheung <[email protected]> * chore: updating docs Co-authored-by: Eugene Cheung <[email protected]>
1 parent 0b74403 commit 6f15302

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

README.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,89 @@ All the widgets will have the same size, which is chosen based on the number of
179179
Custom metric monitoring can be created for simple metrics, simple metrics with anomaly detection and search metrics.
180180
The first two also support alarming.
181181

182-
### Custom monitoring
182+
Below we are listing a couple of examples. Let us assume that there are three existing metric variables: `m1`, `m2`, `m3`.
183+
They can either be created by hand (`new Metric({...})`) or (preferably) by using `metricFactory` (that can be obtained from facade).
184+
The advantage of using the shared `metricFactory` is that you do not need to worry about period, etc.
185+
186+
```ts
187+
// create metrics manually
188+
const m1 = new Metric(/* ... */);
189+
```
190+
191+
```ts
192+
const metricFactory = monitoringFacade.createMetricFactory();
193+
194+
// create metrics using metric factory
195+
const m1 = metricFactory.createMetric(/* ... */);
196+
```
197+
198+
#### Example: metric with anomaly detection
199+
200+
In this case, only one metric is supported.
201+
Multiple metrics cannot be rendered with anomaly detection in a single widget due to a CloudWatch limitation.
202+
203+
```ts
204+
monitorCustom({
205+
title: "Metric with anomaly detection",
206+
metrics: [
207+
{
208+
metric: m1,
209+
anomalyDetectionStandardDeviationToRender: 3
210+
}
211+
]
212+
})
213+
```
214+
215+
Adding an alarm:
216+
217+
```ts
218+
monitorCustom({
219+
title: "Metric with anomaly detection and alarm",
220+
metrics: [
221+
{
222+
metric: m1,
223+
alarmFriendlyName: "MetricWithAnomalyDetectionAlarm",
224+
anomalyDetectionStandardDeviationToRender: 3,
225+
addAlarmOnAnomaly: {
226+
Warning: {
227+
standardDeviationForAlarm: 4,
228+
alarmWhenAboveTheBand: true,
229+
alarmWhenBelowTheBand: true
230+
}
231+
}
232+
}
233+
]
234+
})
235+
```
236+
237+
#### Example: search metrics
238+
239+
```ts
240+
monitorCustom({
241+
title: "Metric search",
242+
metrics: [
243+
{
244+
searchQuery: "My.Prefix.",
245+
dimensionsMap: {
246+
FirstDimension: "FirstDimensionValue",
247+
// allow any value for the given dimension
248+
// (pardon the weird typing due to JSII)
249+
SecondDimension: undefined as unknown as string
250+
}
251+
}
252+
]
253+
})
254+
```
255+
256+
Search metric does not support setting an alarm, that is a CloudWatch limitation.
257+
258+
### Custom monitoring segment
183259

184260
If you want even more flexibility, you can create your own Dashboard Segment.
185261

186262
This is a general procedure on how to do it:
187263

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

0 commit comments

Comments
 (0)