2

I'm currently trying to make some reports about my AWS Cost and Usage via the Cost Explorer API(https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ce.html)

So far, I have been able to use the "get_cost_and_usage function" to query all the relevant information necessary to make my reports. However, I have been taking advantage of the "GroupBy" option in the queries, but it limits a user to only being able to specify 2 two fields.

Request Sytnax

response = client.get_cost_and_usage(
    TimePeriod={
        ...
    },
    Granularity= ...,
    Filter={
        ...
    },
    Metrics=[
        ...
    ],
    GroupBy=[
        {
            'Type': 'DIMENSION'|'TAG'|'COST_CATEGORY',
            'Key': 'string'
        },
    ],
    NextPageToken= ...
)

Is there anyway to circumvent this limit and group by 2+ fields when querying? Currently, I'm trying to group by two unique tags, and the services they've been using. I've experimented in using the Filter option, but the resulting information isn't what I need it to be.

On the likely chance that I can't circumvent this, is there any easy way to create multiple queries and then combine these to achieve my desired results? The results of the queries get spit out in JSON, and I've been using Pandas to create dataframes from this JSON. So, I would also be open to possibly using Pandas to merge these queries(This is the route I've been taken, but I am finding very little success with it). Any help is greatly appreciated!

When scouring the internet for an answer, this was the closet thing I could find(https://github.com/boto/boto3/issues/2761) to a similar question.

egg
  • 21
  • 3

0 Answers0