@nesn/commons-system-health-tools
v1.1.0
Published
`@nesn/commons-system-health-tools` is a utility package designed to facilitate the creation and management of AWS CloudWatch alarms and tags. It provides functions to build alarm tags based on system health configurations, making it easier to monitor app
Readme
@nesn/commons-system-health-tools
Overview
@nesn/commons-system-health-tools is a utility package designed to facilitate the creation and management of AWS CloudWatch alarms and tags. It provides functions to build alarm tags based on system health configurations, making it easier to monitor application performance.
Installation
To install the package, use npm:
npm install @nesn/commons-system-health-toolsUsage
Building System Health CloudWatch Alarm Tags
You can use the buildSystemHealthCloudwatchAlarmTags function to create an array of tags for AWS CloudWatch alarms based on a provided configuration.
In serverless.json file
import { buildSystemHealthCloudwatchAlarmTags } from '@nesn/commons-system-health-tools';
export const serverlessConfiguration = {
resources: {
Resources: {
TestAlarm: {
Type: 'AWS::CloudWatch::Alarm',
Properties: {
AlarmDescription: 'Monitor errors in the test function',
Namespace: 'AWS/Lambda',
MetricName: 'Errors',
Dimensions: [
{
Name: 'FunctionName',
Value: '${self:service}-${self:provider.stage}-test'
}
],
Statistic: 'Sum',
Period: 60,
EvaluationPeriods: 1,
Threshold: 1,
ComparisonOperator: 'GreaterThanOrEqualToThreshold',
TreatMissingData: 'missing',
Tags: buildSystemHealthCloudwatchAlarmTags({
env: '${self:provider.stage}', // '${self:provider.stage}' will be resolved dynamically by serverless
componentName: 'testFunction',
indicatorName: 'error'
})
}
}
}
}
};API
buildSystemHealthCloudwatchAlarmTags(config)
- config:
SystemHealthAlarmTagConfig- An object containing the configuration for the tags. It should include:- env:
string- The environment (e.g., prod, qa, dev). - componentName:
string- The name of the component or service (e.g., database, redis, stripe). - indicatorName:
string- The name of the health indicator (e.g., CPUUtilization, latency).
- env:
Returns an array of Tag objects that can be used with AWS CloudWatch alarms.
License
This project is licensed under the MIT License - see the LICENSE file for details.
