Forum Discussion

Pmeems's avatar
Pmeems
Copper Contributor
Sep 20, 2022
Solved

How to add Cost Management per resource group to workbook?

Via the Portal I can go to Cost Management + Billing > Cost Management > Costs Analysis (preview) > Resource.

And with a resource group selected as the scope I get a very nice overview with the total costs and the resources in this resource group with their individual costs.

 

How can I add something similar to my workbook?

  • Pmeems 

     

    You can start with a basic query like

    let price_ = 4.20;
    union *
    | where _IsBillable == True
    // | where ResourceGroup == "< name of RG > "
    | where isnotempty(Resource)
    | summarize  rgtotalGBytes =sumif(_BilledSize, isnotempty(ResourceGroup)), pricePerGB = sum(_BilledSize)/(1024*1024*1024) * price_  by ResourceGroup, Resource
    | order by rgtotalGBytes desc

3 Replies

  • Clive_Watson's avatar
    Clive_Watson
    Bronze Contributor

    Pmeems 

     

    You can start with a basic query like

    let price_ = 4.20;
    union *
    | where _IsBillable == True
    // | where ResourceGroup == "< name of RG > "
    | where isnotempty(Resource)
    | summarize  rgtotalGBytes =sumif(_BilledSize, isnotempty(ResourceGroup)), pricePerGB = sum(_BilledSize)/(1024*1024*1024) * price_  by ResourceGroup, Resource
    | order by rgtotalGBytes desc
    • Pmeems's avatar
      Pmeems
      Copper Contributor

      Clive_Watson 
      Thanks for your response. It really helps.
      The costs queries are all new to me, so I have some addition questions.

       

      I use the Subscription as the scope and I noticed only for my Keyvault _IsBillable == True.

      Is that excepted? Without that where part I do get all my resources.

       

      Where did the price of 4.20 came from? Is this in $ or in Euro?

       

      I've set my Time Range to Last 30 days.

      My storage is large but not that large. The query shows 101824 in the column rgtotalGBytes.

      I assume the value 101824 in in MB not in GB, right?

       

      And the costs are very low for the storage 0.00039 (column pricePerGB). Or do I misinterpret this column and isn't this the costs for the storage of the last 30 days?

      • Pmeems's avatar
        Pmeems
        Copper Contributor
        I'm using a slightly different JSON Body now and I get what I'm looking for.
        I do have some additional questions but I'll create a new post for them.