|
1 | | -# LambdaEniUsageMetricPublisher |
2 | | -A construct that creates an AWS Lambda function to publish ENI usage metrics to CloudWatch. |
| 1 | +[](https://codecov.io/gh/time-loop/cdk-redis-queue-depth-metric-publisher) |
| 2 | + |
| 3 | +# RedisQueueDepthMetricPublisher |
| 4 | +A construct that creates an AWS Lambda function to publish |
| 5 | +queue depths from a redis instance |
3 | 6 |
|
4 | 7 | ## Usage |
5 | | -To use the `LambdaEniUsageMetricPublisher` construct, simply import it into your AWS CDK stack and create a new instance of the construct: |
| 8 | +To use the `RedisQueueDepthMetricPublisher` construct, simply import it into your AWS CDK stack and create a new instance of the construct: |
6 | 9 |
|
7 | 10 | ``` ts |
8 | 11 | import { Stack } from 'aws-cdk-lib'; |
9 | | -import { LambdaEniUsageMetricPublisher } from './lambda-eni-usage-metric-publisher'; |
10 | | - |
11 | | -const stack = new Stack(app, 'MyStack'); |
12 | | - |
13 | | -new LambdaEniUsageMetricPublisher(stack, 'MyLambdaEniUsageMetricPublisher', { |
14 | | - publishFrequency: 5, |
15 | | - regions: ['us-east-1', 'us-west-2'], |
16 | | - cwNamespace: 'MyNamespace', |
| 12 | +import { RedisQueueDepthMetricPublisher } from './cdk-redis-queue-depth-metric-publisher'; |
| 13 | + |
| 14 | +let stack: Stack; |
| 15 | + |
| 16 | +new RedisQueueDepthMetricPublisher(stack, 'RedisQueueDepthMetricPublisher', { |
| 17 | + cwNamespace: 'example', |
| 18 | + cloudwatchLogsRetention: RetentionDays.THREE_MONTHS, |
| 19 | + publishFrequency: Duration.minutes(5), |
| 20 | + queues: ['fakeQueue', 'fakeQueue2'], |
| 21 | + redisAddr: 'fakeRedisAddr', |
| 22 | + // redisPort: '123456', // Optional |
| 23 | + redisSecretArn: 'fakeRedisSecretArn', |
| 24 | + redisSecretKeyArn: 'fakeRedisSecretKeyArn', |
| 25 | + // redisSecretPasswordPath: 'fakeRedisSecretPasswordPath', |
| 26 | + // redisSecretUsernamePath: 'fakeRedisSecretUsernamePath', |
17 | 27 | }); |
18 | 28 | ``` |
19 | 29 |
|
20 | | -This will create a new AWS Lambda function that publishes ENI usage metrics to CloudWatch every 5 minutes for the `us-east-1` and `us-west-2` regions, using the `MyNamespace` namespace. |
| 30 | +This will create a new AWS Lambda function that publishes queue depth metrics to CloudWatch every 5 |
| 31 | +minutes. It pulls the information from the `fakeRedisAddr` redis instance on the default port. |
| 32 | +It will fetch login credentials from `redisSecretArn`, log into the redis instance and query |
| 33 | +the two queues `['fakeQueue', 'fakeQueue2']`, then publish the info to the `cwNamespace` with |
| 34 | +metric names that are identical to the queue names. |
| 35 | +NOTE: no mapping is currently supported for the queue names. |
21 | 36 |
|
22 | 37 | ## API |
23 | | -`LambdaEniUsageMetricPublisher(scope: Construct, id: string, props: LambdaEniUsageMetricPublisherProps)` |
| 38 | +`RedisQueueDepthMetricPublisher(scope: Construct, id: string, props: RedisQueueDepthMetricPublisherProps)` |
24 | 39 |
|
25 | | -Creates a new instance of the `LambdaEniUsageMetricPublisher` construct. |
| 40 | +Creates a new instance of the `RedisQueueDepthMetricPublisher` construct. |
26 | 41 |
|
27 | 42 | ### Parameters |
28 | 43 | - `scope` - The parent construct. |
29 | 44 | - `id` - The ID of the construct. |
30 | 45 | - `props` - The properties of the construct. |
31 | 46 |
|
| 47 | +WRITEME FROM HERE DOWN |
| 48 | + |
32 | 49 | ### Properties |
33 | 50 | - `publishFrequency` - The time interval (in minutes) that the Lambda function will be triggered to publish metrics to CloudWatch. |
34 | 51 | - `regions` - The list of AWS regions to publish ENI usage metrics for. |
|
0 commit comments