DEV Community

Colin Duggan for AWS Community Builders

Posted on

A CLI tool to visualize AWS cost and usage data

ccExplorer is a CLI tool I created to make it easier to surface AWS cost and usage data in human readable formats (like table, csv, chart, and HTML)and which can be used to easily sort results in descending order by cost or date.

It doesn't replace the cost explorer capabilities provided by the AWS CLI but instead focuses on providing more convenient output formats which enables the user to quickly reason about data without having to traverse a YAML or JSON tree.

CostAndUsage Queries

Where possible ccExplorer uses the same nomenclature as the AWS CLI when naming command line options. Queries use the groupBy or filterby flags to specify the dimensions and/or tags used when fetching cost and usage data and when outputting results.

By default results are sorted by cost in descending order. The following command exports results to stdout and groups by SERVICE and OPERATION. The -l flag is used to exclude discount, credit and refund information to get a true sense of costs.


Image description

Cost Allocation Tags

ccExplorer makes it easy to surface costs associated with custom cost allocation tags. For example:

  • Surface S3 Bucket Costs ccexplorer get aws -g DIMENSION=SERVICE,TAG=BucketName -f SERVICE="Amazon Simple Storage Service" -l
  • Surface DynamoDB Table Costs ccexplorer get aws -g DIMENSION=SERVICE,TAG=DynamoTableName -f SERVICE="Amazon DynamoDB" -l

Print Formats

ccExplorer supports output formats including CSV, chart, and HTML. HTML reports are generated using OpenAI and the GPT-3 completions API. In order to use this feature the end user must supply an OPEN AI API KEY. The resulting HTML report includes the top 10 costs in descending order. Results also include cost optimization hints for each of the highest costing resources. Note: The HTML output type does not support queries which include the LINKED_ACCOUNT dimension type, which would require sending sensitive account information to GPT-3. The HTML output type is still very experimental and subject to changes.

Image description


At the outset I was hoping to build something that could quickly surface high level data about the resources I was using. I quickly discovered that ccExplorer was also deepening my knowledge across other facets of AWS including usage and operation types. I was able to pinpoint the cost implication of specific resources including S3 buckets and DynamoDB tables. This has helped me to better reason about the workloads I manage and ultimately eliminate inefficiencies.

ccExplorer is still very much a work in progress but I hope you find it useful. Suggestions and feedback are welcome.

Top comments (0)