这是indexloc提供的服务,不要输入任何密码
Skip to content

folpindo/cdk-wakeful

 
 

Repository files navigation

CDKWakeful

The idea behind CDKWakeful is simple: reduce the undifferentiated heavily lifting in monitoring and alerting so that you can focus on creating custom metrics and threholds around your business logic. To do this, CDKWakeful uses CDK Aspects to introspect your code and provide a low water mark of alarms. In addition, CDKWakeful also creates mechanisms to automatically subscribe and be alerted to an incident. CDKWakeful supports both typescript and python.

A simple of example of how to use CDKWakeful is as follows

import os

from aws_cdk import core as cdk

from integration_test.integration_test_stack import IntegrationTestStack
from cdk_wakeful.cdk_wakeful import CDKWakeful
from cdk_wakeful.logger import LogLevel
from cdk_wakeful.sns_topic_alerter import SnsTopicAlerter

app = cdk.App()
stack = ExampleStack(app, "IntegrationTestStack",)

cdk.Aspects.of(stack).add(CDKWakeful(
    log_level=LogLevel.INFO,
    include_best_practices=True,
    include_errors=True,
    include_throttles=True,
    alertables=[SnsTopicAlerter(topic=stack.notification_topic)]
))
app.synth()

Alarms

CDKWakeful has three types of alarms: Best Practices, Errors, and Throttles. Through the CDKWakeful you can toggle which of these categories resources are alarmed.

Best Practices are Alarms describe by several sources as "best practices." These include blog posts and documentation in the service itself. For example, Recommended CloudWatch alarms for Amazon OpenSearch Service lists a number of metrics recommended by the Amazon OpenSearch service in the developer guide. Errors are defined as any error not proposed by user. For example, if an API Gateway returns as 5XX error, this is an error. This indicates something is wrong with the API Gateway or how it was configured. In constrast, a 4XX error is not defined as an error since this error occurs because of the client's request (for example a client does not authenticate with the API Gateway). Throttles occur when the number of calls to a given API exceed the maximum allow API request. In many cases, the limits can be adjusted by contacting the AWS Support Center

Services Alarmed

We support the following services:

Notifications

CDKWakeful supports three main methods of receiving notifications.

In addition, we also support a "no op" method of notification that sends the alert nowhere.

How to use

To build your local version of CDKWakeful simply run npm run build

When your local version of CDKWakeful builds successfully, you can test it to create a new CDK Project by going into another directory and invoking the package directly:

You can make a CDK python project using cdk init --language=python or CDK Typescript project using cdk init app --language=typescript

Navigate to the CDKWakeful directory and build the project.

$ cd /path/to/local/cdkwakeful
$ npm run build

Navigate to the dist copy the js or python folders into your project. Below is an example for a typescript project.

$ cp -R dist/js /path/to/my-project

Navigate back to your project and install the package.

For Typescript run the following command:

$ npm i js/CDKWakeful@0.0.0.jsii.tgz

For Python run the following command:

pip install python/cdk_wakeful-0.0.0-py3-none-any.whl

Security

See CONTRIBUTING for more information.

License

This library is licensed under the MIT-0 License. See the LICENSE file.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 93.9%
  • Python 4.6%
  • Other 1.5%