AWS cost explorer dashboard and CLI result mismatch

0

Hello, So i'm having trouble making the 'aws ce get-cost-and-usage' command work and get me the same result I get using the cost explorer console cost explorer dashboard applied filters are:

  • Date range: 2023-04-01 2023-04-10
  • Granularity: Monthly
  • Dimension: Linked Account
  • Charge type: excludes 2 (refund, credit)
  • Aggregate Costs by: Blended cost

Now here's the command I run: $ aws ce get-cost-and-usage --time-period Start=2023-04-01,End=2023-04-11 --granularity MONTHLY --group-by Type=DIMENSION,Key=LINKED_ACCOUNT --metrics "BlendedCost"

and here's the output I get:

{
    "GroupDefinitions": [
        {
            "Type": "DIMENSION",
            "Key": "LINKED_ACCOUNT"
        }
    ],
    "ResultsByTime": [
        {
            "TimePeriod": {
                "Start": "2023-04-01",
                "End": "2023-04-11"
            },
            "Total": {},
            "Groups": [
                {
                    "Keys": [
                        "aaaa"
                    ],
                    "Metrics": {
                        "BlendedCost": {
                            "Amount": "6.136607832",
                            "Unit": "USD"
                        }
                    }
                },
                {
                    "Keys": [
                        "bbbb"
                    ],
                    "Metrics": {
                        "BlendedCost": {
                            "Amount": "0.3097750801",
                            "Unit": "USD"
                        }
                    }
                },
                {
                    "Keys": [
                        "cccc"
                    ],
                    "Metrics": {
                        "BlendedCost": {
                            "Amount": "-0.0046580685",
                            "Unit": "USD"
                        }
                    }
                }
            ],
            "Estimated": true
        }
    ],
    "DimensionValueAttributes": [
        {
            "Value": "aaaa",
            "Attributes": {
                "description": "L****"
            }
        },
        {
            "Value": "bbbb",
            "Attributes": {
                "description": "Preprod"
            }
        },
        {
            "Value": "cccc",
            "Attributes": {
                "description": "Prod"
            }
        }
    ]
}

What are these weird negatives and very low values I get for each account compared to the result I get on the dashboard? what is missing on my command so I could get the same result on the dashboard ?

Thank you

2개 답변
0
수락된 답변

It looks like the reason you are seeing different results in Cost Explorer console vs. CLI command is that you have different filters applied. In Console, you are filtering on Charge Type to exclude refunds and credits. Without these exclusions in the CLI command, its possible you are getting total costs that include refunds and credits.
Try: aws ce get-cost-and-usage --time-period Start=2023-04-01,End=2023-04-11 --granularity MONTHLY --metrics BLENDED_COST --group-by Type=DIMENSION,Key=LINKED_ACCOUNT --filter Dimensions={Key=RECORD_TYPE,Values=Usage}

If you need to find all the specific record type (charge type) values, you can also use: aws ce get-dimension-values --dimension RECORD_TYPE --time-period Start=2023-04-01,End=2023-04-11

AWS
답변함 일 년 전
  • thank you, even though the command you mentioned doesn't work, syntax problem , but I could make it work using an external file:

    { "Dimensions": { "Key": "RECORD_TYPE", "Values": ["Usage","Tax","Support"] } }

    -then call it with $ aws ce get-cost-and-usage --time-period Start=2023-04-09,End=2023-04-17 --granularity MONTHLY --metrics BLENDED_COST --group-by Type=DIMENSION,Key=LINKED_ACCOUNT --filter file://file.json

0

@vjtean saying "In the command it says End=2023-04-11 instead of End=2023-04-10" Reply: According to AWS documentation, end_date is exclusive, so in order to include 10th April into account, you must mention the day after. even if that was the problem (which is not), it clearly doesn't explain negative and lower than 0 values.

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠