README
¶
ccExplorer is in Alpha
ccExplorer
ccExplorer
(Cloud cost explorer) is a simple command line tool to explore the
cost of your cloud resources. It's built on opensource tools like cobra,
go-echarts, and go-pretty.
It lets you quickly surface cost and usage metrics associated with your AWS
account and visualize them in a human-readable format like a table, csv file,
or chart.
It's not designed as a replacement for the official AWS COST Explorer CLI
but does provide some nice features such as visualization and result sorting.
Build from source or download the latest release from the releases page.
From Homebrew
$ brew tap cduggn/cduggn
$ brew install ccExplorer
From source
:
$ git clone https://github.com/cduggn/ccExplorer.git
$ cd ccExplorer
$ go run .\cmd\ccexplorer\ccexplorer.go get aws -g DIMENSION=SERVICE,DIMENSION=OPERATION -f SERVICE="Amazon DynamoDB" -l
Fromdocker
:
# download
$ docker pull ghcr.io/cduggn/ccexplorer:v0.3.7
# Container requires AWS Access key, secret, and region
$ docker run -it \
-e AWS_ACCESS_KEY_ID=<AWS_ACCESS_KEY_ID> \
-e AWS_SECRET_ACCESS_KEY=<AWS_SECRET_ACCESS_KEY> \
-e AWS_REGION=<AWS-REGION> \
ghcr.io/cduggn/ccexplorer:v0.3.7 get aws -g DIMENSION=OPERATION,
DIMENSION=SERVICE \
-l -p stdout
Quick Start
Once ccExplorer
is installed you can run the help command to see the
available commands.
$ ccexplorer --help
When you invoke a command, ccExplorer
will use the AWS
credential chain to authenticate with AWS.
Presets are the most common way to use ccExplorer
. Presets are a
set of pre-defined cost and usage queries that can be used to quickly get a
sense of the cost of your cloud resources.
$ ccexplorer run-query
Sample queries
# Costs grouped by LINKED_ACCOUNT
$ ccexplorer get aws -g DIMENSION=LINKED_ACCOUNT
# Costs grouped by CommittedThroughput operation and SERVICE
$ ccexplorer get aws -g DIMENSION=OPERATION,DIMENSION=SERVICE -s 2022-10-10 -f OPERATION="CommittedThroughput" -l
# Costs grouped by CommittedThroughput and LINKED_ACCOUNT
$ ccexplorer get aws -g DIMENSION=OPERATION,DIMENSION=LINKED_ACCOUNT -s 2022-10-10 -f OPERATION="CommittedThroughput" -l
# DynamodDB costs grouped by OPERATION
$ ccexplorer get aws -g DIMENSION=OPERATION,DIMENSION=SERVICE -s 2022-10-10 -f SERVICE="Amazon DynamoDB" -l
# All service costs grouped by SERVICE
$ ccexplorer get aws -g DIMENSION=SERVICE -s 2022-10-10
# All service costs grouped by SERVICE and OPERATION
$ ccexplorer get aws -g DIMENSION=SERVICE,DIMENSION=OPERATION -s 2022-10- -l
# S3 costs grouped by OPERATION
$ ccexplorer get aws -g DIMENSION=OPERATION,DIMENSION=SERVICE -s 2022-04-04 -f SERVICE="Amazon Simple Storage Service" -l
# Costs grpuped by ApplicationName Cost Allocation Tag
$ ccexplorer get aws -g TAG=ApplicationName,DIMENSION=OPERATION -s 2022-12-10 -l
# Costs grpuped by ApplicationName Cost Allocation Tag and filtered by specific name
$ ccexplorer get aws -g TAG=ApplicationName,DIMENSION=OPERATION -s 2022-12-10 -f TAG="my-project" -l
# S3 costs grouped by SERVICE dimension and ApplicationName Cost Allocation Tag
$ ccexplorer get aws -g DIMENSION=SERVICE,TAG=ApplicationName -f SERVICE="Amazon Simple Storage Service" -l
# S3 costs grouped by SERVICE dimension and ApplicationName Cost Allocation Tag and filtered by specific name
$ ccexplorer get aws -g DIMENSION=SERVICE,TAG=ApplicationName -f SERVICE="Amazon Simple Storage Service" -l -f TAG="my-application"
# S3 costs grouped by SERVICE dimension and BucketName Cost Allocation Tag
$ ccexplorer get aws -g DIMENSION=SERVICE,TAG=BucketName -f SERVICE="Amazon Simple Storage Service" -l
# S3 costs grouped by SERVICE dimension and BucketName Cost Allocation Tag and filterred by specific name
$ ccexplorer get aws -g DIMENSION=OPERATION,TAG=BucketName -f SERVICE="Amazon Simple Storage Service" -l -f TAG="my-bucket"
# Costs groupedby OPERATION dimension and ApplicationName Cost Allocation Tag and filtered by PutObject operation
$ ccexplorer get aws -g TAG=ApplicationName,DIMENSION=OPERATION -s 2022-12-10 -f OPERATION="PutObject" -l
# Costs grouped by GetCostAndUsage operation and LINKED_ACCOUNT dimension
$ ccexplorer get aws -g DIMENSION=OPERATION,DIMENSION=LINKED_ACCOUNT -s 2022-12-10 -f OPERATION="GetCostAndUsage" -l
# Costs grouped by HOUR and by SERVICE and OPERATION DIMENSIONS
$ ccexplorer get aws -g DIMENSION=SERVICE,DIMENSION=OPERATION -l -e 2023-01-27T15:04:05Z -s 2023-01-26T15:04:05Z -m HOURLY
# Costs grouped by DAY and by SERVICE and OPERATION DIMEBSIONS
$ ccexplorer get aws -g DIMENSION=SERVICE,DIMENSION=OPERATION -l -e 2023-01-27 -s 2023-01-26 -m DAILY
# Costs exported in CSV format
$ ccexplorer get aws -g DIMENSION=LINKED_ACCOUNT,DIMENSION=OPERATION -l -m DAILY -p csv
# Costs exported to stdout
$ ccexplorer get aws -g DIMENSION=LINKED_ACCOUNT,DIMENSION=OPERATION -l -m DAILY -p stdout
# Costs grouped by MONTH by SERVICE and OPERATION and printed to chart
$ ccexplorer get aws -g DIMENSION=SERVICE, DIMENSION=OPERATION -l -e 2023-01-27 -s 2023-01-26 -m MONTHLY -p chart
# Costs grouped by MONTH by OPERATION and USAGE_TYPE and printed to chart
$ ccexplorer get aws -g DIMENSION=OPERATION,DIMENSION=USAGE_TYPE -l -e 2023-01-27 -s 2023-01-26 -m MONTHLY -p chart
Default settings
If no cost allocation tags have been defined, the ccExplorer
can still be
used to filter and group resources based on their
AWS resource types. This can be achieved by using the group by and filter
flags
- If no billing period is specified, the current calendar month will be used.
- UnblendedCost is the default cost metric. Other metrics can be specified
using the
-i
flag. - Selecting the chart output format
-p chart
returns a pie chart of the 15 most expensive services. - Results are sorted by cost in descending order.
- Refunds, discounts and credits are applied automatically. The
-l
flag should be used to exclude this behavior. - When filtering by cost allocation tags (
-f TAG="my-tag"
) a tag must also be specified in the group by flag (-g TAG=ApplicationName
). This instructs theccExplorer
to filter byApplicationName=my-tag
. - Hourly results can be returned by using the
-s
and-e
flags and providing an ISO 8601 formatted date and time for example-s 2022-10-10T00:00:00Z -e 2022-10-10T23:59:59Z
.
- Cost Explorer accesses data for the last 12 months.
- Cost Explorer charges per paginated request.
- The AWS SDK uses the default credentials provider chain.
- Credits and refunds are automatically applied to Cost Explorer results.
- Cost Explorer API calls can be tracked using CloudTrail.
- Requests are issued against the
us-east-1
region.