Skip to main content

A package for monitoring AWS resources

Project description

AWS Cost Monitoring Package

This package provides tools for monitoring and analyzing AWS costs, both at the organizational level and individual account level. It includes functionality to get detailed cost breakdowns by linked accounts and AWS services, along with visualizations.

Installation

To install the package, use pip:

pip install aws-monitor

This will also install the following dependencies:

  • boto3
  • matplotlib

Usage

AWSOrgMonitor Class

This class inherits from AWSCostMonitor and provides methods to fetch and analyze AWS cost data.

Initialization

from aws_monitoring.utils import AWSCostMonitor

class AWSOrgMonitor(AWSCostMonitor):
    def __init__(self):
        super().__init__()

Get Cost

Fetches the cost data within the specified time period and granularity.

def get_cost(self, start: str, end: str, granularity: str, metrics: list, group_by: list = [], json=False) -> dict:
  • start: Start date in YYYY-MM-DD format.
  • end: End date in YYYY-MM-DD format.
  • granularity: Granularity of the data (DAILY, MONTHLY).
  • metrics: List of metrics to fetch (e.g., ['UNBLENDED_COST']).
  • group_by: List of dimensions to group by.
  • json: Whether to return the response in JSON format.

Get Billed Accounts

Fetches the list of billed accounts within the specified time period.

def get_billed_accounts(self, start: str, end: str) -> dict:

Get Cost Per Account

Fetches the cost per account within the specified time period.

def get_cost_per_account(self, start, end) -> dict:

Get Cost Per Account Graph

Displays a bar graph of the cost per account within the specified time period.

def get_cost_per_account_graph(self, start, end):

Get Cost Per Service

Fetches the cost per AWS service within the specified time period and optionally for a specific linked account.

def get_cost_per_service(self, start: str, end: str, linked_account: str = None) -> dict:

Get Cost Per Service Graph

Displays a bar graph of the cost per AWS service within the specified time period and optionally for a specific linked account.

def get_cost_per_service_graph(self, start: str, end: str, linked_account: str = None):

Example Usage

from aws_monitoring.utils import AWSOrgMonitor

monitor = AWSOrgMonitor()
start_date = '2023-06-01'
end_date = '2023-06-30'

# Get cost per service
service_costs = monitor.get_cost_per_service(start_date, end_date)
print(service_costs)

# Visualize cost per service
monitor.get_cost_per_service_graph(start_date, end_date)

# Get cost per account
account_costs = monitor.get_cost_per_account(start_date, end_date)
print(account_costs)

# Visualize cost per account
monitor.get_cost_per_account_graph(start_date, end_date)

License

This package is licensed under the MIT License. See the LICENSE file for more information.

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

aws_monitor-0.0.9.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

aws_monitor-0.0.9-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file aws_monitor-0.0.9.tar.gz.

File metadata

  • Download URL: aws_monitor-0.0.9.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for aws_monitor-0.0.9.tar.gz
Algorithm Hash digest
SHA256 08d2c0f30fb3b3d0c4f1c96e6dc3ff33d101095c3a9eea445ced7868d022c555
MD5 da2595b7443beabda70b20362f02a57c
BLAKE2b-256 facd682d816da9187413f78dee8c71f3dd3aa32482cefb84056241cfe6d0596f

See more details on using hashes here.

File details

Details for the file aws_monitor-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: aws_monitor-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.8.18

File hashes

Hashes for aws_monitor-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4fa60306fe5f9a3424a5e06b6c4f4567ff3579cb250da1573cfc7bd160a2c9d0
MD5 290b2fc22e7843ba04e76d6e9511767e
BLAKE2b-256 09376e86f71052e011e3def6244287367fe7583161f66a9e486d62888041209a

See more details on using hashes here.

Supported by

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