Skip to main content

SaU (Stopped and Unattached) Exporter

GitHub release (latest SemVer) GitHub Workflow Status GitHub pre-commit GitHub top language Docker Pulls

Overview

The SaU Exporter is a Python-based application designed to collect and expose AWS EC2 and EBS volume metrics for monitoring and observability. It utilizes the Prometheus client library to provide an HTTP endpoint for scraping metrics.

Features

  • EC2 Metrics: Collects information about stopped EC2 instances in different AWS regions.
  • EBS Volume Metrics: Retrieves data on unattached/errored EBS volumes, including volume state, type, size, and region.
  • Prometheus Integration: Exposes metrics in the Prometheus format, making it compatible with Prometheus monitoring systems.
  • Exclude Tagging: Instances and/or volumes can be optionally omitted as metrics if their corresponding tags & matching values are included in the exclude_tags config. The tag values are case insensitive. E.g inv_environment_id: ["dev"] will also match inv_environment_id: ["DEV"]

Installing via pip

Pip package is available here

Prerequisites:

  • Python 3.8+ installed on your system.
  • Ensure the required Python libraries are installed by running the following command.
pip install -r requirements.txt
pip install sau

AWS Credentials

The exporter requires two AWS EC2 permissions, DescribeInstances and DescribeVolumes. A sample iam policy document can be seen below:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ec2:DescribeInstances",
                "ec2:DescribeVolumes"
            ],
            "Resource": "*"
        }
    ]
}

It would be easier to put the creds in a env file. Example .env file can be seen below:

AWS_ACCESS_KEY_ID=129QJDNC2OQD09N
AWS_SECRET_ACCESS_KEY=9KXXXXXXXXX
AWS_REGION=eu-central-1

then you can source the .env

source .env

Configuration

Create a YAML configuration file with the necessary settings.

Configuration Options

  • Regions: Specify the AWS regions for which you want to collect metrics.
  • Exporter Port: Define the port on which the exporter will expose metrics (default: 9191).
  • Logging Configuration: Customize logging settings, such as log file directory and retention. See example below.
# list of regions to scrape: REQUIRED
regions:
  - eu-central-1
  - eu-west-1

# exporter port. Defaults to 9191
exporter_port: 9191

# Logging configuration
logging:
  # Number of log files to retain after log rotation
  retention: 7
  # log directory. defaults to current working directory
  directory: "."
  # log level (debug, info, warn, error). Defaults to info
  level: info
  # which log handler to use (stdout, file, both). Defaults to both.
  # stdout will only log to stdout
  # file will only log to the specified file
  # both will log to both stdout and file
  handler: both

# Optional: Tags to exclude from monitoring
#           The tag values are case insensitive
exclude_tags:
  inv_environment_id:
    - development
    - staging

Using pip package after installation

python3 -m sau -c /path/to/config.yaml

Installing using docker

The docker repository is available at link. You will need the following:

docker run -ti --env-file .env -v /path/to/config.yaml:/sau/config.yaml ugwuanyi/sau:latest -c /sau/config.yaml

Installing from source:

Prerequisites:

  • Python 3.8+ installed on your system.
  • clone the repository
git clone https://github.com/emylincon/sau.git
  • Ensure the required Python libraries are installed by running the following command.
pip install -r requirements.txt

You will need the following:

Execute the exporter by providing the path to the configuration file:

python3 src/sau/__main__.py -c /path/to/your/config.yaml

Metrics Endpoint:

Once the exporter is running, metrics can be accessed at http://localhost:<exporter_port>/.

Grafana Dashboard

Grafana dashboard of sample metrics Grafana dashboard

Customization

Feel free to extend or customize the exporter to meet your specific requirements. You can modify the provided code or add additional collectors to gather more AWS resource metrics.

License

This project is licensed under the MIT License. Feel free to use, modify, and distribute it according to the terms of the license.

Author

Created by Emeka Ugwuanyi. For questions or feedback, please contact me.

Upgrading version

  • enable pr-commit
pre-commit install
  • Increament version in docker/Taskfile
  • Commiting changes with update all the version references

Happy monitoring!

Metadata

Release files for sau 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sau 0.1.1
File Size Uploaded
sau-0.1.1.tar.gz 17.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sau 0.1.1
File Interpreter ABI Platform
sau-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.2 kB

Release files / sau-0.1.1.tar.gz

Download URL sau-0.1.1.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f3a47c3a72469fe56a359fbcc8c93056d66ab8596422232f8be4b55426187d07
BLAKE2b-256 checksum
How to use checksums
96aa788888329f59278f262122b2921a400189b68e9a1ce96453aa7d18c9517a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / sau-0.1.1-py3-none-any.whl

Download URL sau-0.1.1-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9e444c34e98583f2070c1fa93bc7629d0c541113376917bf2f8a6ba3c7cbbdc0
BLAKE2b-256 checksum
How to use checksums
c640ba1309a29aa64b1d0b2cfc582d2d205a661bdf84006abdc070d3a4548af0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page