Skip to content

Commit

Permalink
doc: Update documentation for metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
kozub committed Jan 4, 2024
1 parent 6089ea1 commit 48ba585
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 1 deletion.
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,41 @@ const flow = new OnDemandFlow(stack, 'OnDemandFlow', {
});
```

## EventBridge notifications
## Monitoring


### Metrcis

Each flow reports the following metrics in the `AWS/AppFlow` namespace:

|Metric name|Description|
|---|---|
|FlowExecutionsStarted|The number of flow runs started.|
|FlowExecutionsFailed|The number of failed flow runs.|
|FlowExecutionsSucceeded|The number of successful flow runs.|
|FlowExecutionTime|The interval, in milliseconds, between the time the flow starts and the time it finishes.|
|FlowExecutionRecordsProcessed|The number of records that Amazon AppFlow attempted to transfer for the flow run. This metric counts all records that Amazon AppFlow processed internally. The processed records include those that transferred successfully and those that failed to transfer because the flow run failed.|


It can be consume by CloudWatch alert using as in the example below:


```ts
import { IFlow } from '@cdklabs/cdk-appflow';
import { Stack } from 'aws-cdk-lib';

declare const flow: IFlow;
declare const stack: Stack;

const metric = flow.metricFlowExecutionsStarted()
metric.createAlarm(stack, "FlowExecutionsStartedAlarm", {
threshold: 1000,
evaluationPeriods: 2
})
```


### EventBridge notifications

Each flow publishes events to the default EventBridge bus:

Expand Down
25 changes: 25 additions & 0 deletions src/core/flows/flow-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,35 @@ export interface IFlow extends IResource {

onRunCompleted(id: string, options?: OnEventOptions): Rule;


/**
* Creates a metric to report the number of flow runs started.
* @param options
*/
metricFlowExecutionsStarted(options?: MetricOptions): Metric;

/**
* Creates a metric to report the number of failed flow runs.
* @param options
*/
metricFlowExecutionsFailed(options?: MetricOptions): Metric;

/**
* Creates a metric to report the number of successful flow runs.
* @param options
*/
metricFlowExecutionsSucceeded(options?: MetricOptions): Metric;

/**
* Creates a metric to report the interval, in milliseconds, between the time the flow starts and the time it finishes.
* @param options
*/
metricFlowExecutionTime(options?: MetricOptions): Metric;

/**
* Creates a metric to report the number of records that Amazon AppFlow attempted to transfer for the flow run.
* @param options
*/
metricFlowExecutionRecordsProcessed(options?: MetricOptions): Metric;

/**
Expand Down

0 comments on commit 48ba585

Please sign in to comment.