Skip to main content

Python library for creating AWS CloudWatch alerts automatically based on predefined configurations

Project description

Alertalot

Alertalot Logo

Python library for creating AWS CloudWatch alerts automatically based on predefined configurations.

Running the Code

Linux

  1. Clone the repository and run
    ./bin/install.sh
    
  2. Optionally, run tests
    ./bin/test.sh
    
    You should see:
    ...
    ─────────────────────────────────────────────
    ✓ SUCCESS: Alertalot Pylint check passed
    ✓ SUCCESS: Unittests Pylint check passed
    ✓ SUCCESS: Unittests passed
    ─────────────────────────────────────────────
    ✓ OK!
    

Code Quality and Testing

Before running any of the following commands, ensure that your virtual environment is activated:

source ./venv/bin/activate

Test and Lint Commands

Task Command
Run Unit Tests with Coverage pytest --cov=alertalot --cov-report=html --cov-branch
Lint Alertalot Code pylint alertalot --rcfile=.pylintrc --fail-under=10
Lint Test Code pylint tests --rcfile=tests/.pylintrc --fail-under=10

Usage

Alertalot can be run with various options to create CloudWatch alerts for AWS resources.

Basic Usage

python -m alertalot.main --instance-id i-xxxxxxxxx --vars-file examples/variables.yaml --template-file examples/ec2-application.yaml --region us-east-1

Available Options

Option Description
--instance-id ID of an EC2 instance to generate the alerts for
--params-file Relative path to the parameters file to use (see examples/params.yaml)
--template-file Relative path to the template file to use (see examples/ec2-application.yaml)
--region The AWS region to use
--dry-run Simulate the requests without executing them
-v, --verbose Enable verbose output to show details about executed actions

Special Actions

Action Description
--show-parameters, --show-params Only loads the parameters file and outputs the result. Parameters for the specified region will be merged with global parameters.
--test-aws Only checks if AWS is accessible by calling sts:GetCallerIdentity. Use with --verbose to see detailed output.
--show-instance Loads and describes the target instance. Requires a valid instance ID.

Configuration Files

Parameters File

The parameters file (YAML or JSON) contains values that will be substituted in the template file:

params:
  global:
    # Global parameters used across all regions
  us-east-1:
    # Region-specific parameters
    ALARM_ACTION_ARN: "arn:aws:sns:us-east-1:aaaa:bbbb"

Template File

The template file defines the CloudWatch alarms to be created:

alarms:
  - type: ec2
    alarm-name: AWS / CPU Usage 5 minute / $INSTANCE_NAME / $INSTANCE_ID
    metric-name: CPUUtilization
    alarm-actions: $ALARM_ACTION_ARN
    statistic: Average
    period: 5 minutes
    comparison-operator: GreaterThanOrEqualToThreshold
    threshold: 70%
    evaluation-periods: 1 minute
    tags:
      level: info
    treat-missing-data: breaching

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

alertalot-0.1.0.tar.gz (25.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alertalot-0.1.0-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file alertalot-0.1.0.tar.gz.

File metadata

  • Download URL: alertalot-0.1.0.tar.gz
  • Upload date:
  • Size: 25.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for alertalot-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d27f89957e8a862f837ef628a51b917213ffe7a65b5880b0a084b4ad2c5541d
MD5 09b3911eba03a9b6a3edbe96b0587551
BLAKE2b-256 084d35d43462a371eb70557940e4c366a343c08507a89f82d069fc0d09652e43

See more details on using hashes here.

File details

Details for the file alertalot-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: alertalot-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.16

File hashes

Hashes for alertalot-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e25a90a886c5094033b148d6587d4317af5235f4357322a4137bef1102411afd
MD5 a9975036a7f447857a81b295c40babab
BLAKE2b-256 72039a6522d84564ee55feac1e13d34856fce9322b2e542a248f1249a46bda1c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page