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.2.0.tar.gz (25.3 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.2.0-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for alertalot-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f0a9a44adc1fff048b7f7e929d8988b3f572e711277beb69f5851a520a340e9d
MD5 7ca9b566887560b7c1452af9029f6f83
BLAKE2b-256 fbb2fe018ce99b836aaa33b3df11e47e2c8ade57965a88360b21714600e10ba5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for alertalot-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 17eef78e2a168f7bc93268464043fe7339c429d3ea085e8bbc9cdb7cbc33b6ed
MD5 17d05264d79d7521c03ff50bf41fb845
BLAKE2b-256 c4402402802ad70715124af6bb6bf69ba48278ea38bdfa6c94947ee147fb7fa1

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