Skip to content

Commit 245ae03

Browse files
authored
Enhance GCP data auditing to sum all credits for each resource (#1162)
1 parent 69538da commit 245ae03

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

using-kubecost/kubecost-data-audit/gcp-kubecost-data-audit.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ First, in the Kubecost UI, view the price of a single node for a single day. Thi
1111

1212
Next, compare this instance's costs with what is found in the GCP export via BigQuery. Use the providerID that's in Kubecost for the node as the `resource.name` in the following query:
1313

14-
```bash
14+
```sql
1515
SELECT
1616
TIMESTAMP_TRUNC(usage_start_time, day) as usage_date,
1717
service.description as service,
1818
resource.name as resource,
1919
SUM(cost) as cost,
2020
SUM(cost_at_list) as list_cost,
21-
ARRAY_CONCAT_AGG(credits) as credits
21+
ARRAY_CONCAT_AGG(credits) as credits,
22+
-- OPTIONAL: Use the below line to SUM the credits associated with each resource
23+
SUM((SELECT SUM(credit.amount) FROM UNNEST(credits) credit)) as total_credits
2224
FROM detailedbilling.gcp_billing_export_resource_v1_0121AC_C6F51B_690771
2325
WHERE
2426
usage_start_time >= "2024-03-24"
@@ -32,7 +34,6 @@ GROUP BY
3234

3335
![BigQuery Output](/images/data-auditing/dataaudit-gcp-bigquery-output.png)
3436

35-
3637
{% hint style="info" %}
3738
The example above is auditing the GKE nodes associated with the cluster. BigQuery will return additional items such as network costs and costs associated with the node pool, however you should focus on GKE nodes only.
3839
{% endhint %}

0 commit comments

Comments
 (0)