Skip to content
This repository has been archived by the owner on Sep 3, 2020. It is now read-only.

GKE Usage Metering Data Studio connector fails on divide-by-zero error #319

Open
JoshuaFox opened this issue Apr 12, 2020 · 1 comment
Open

Comments

@JoshuaFox
Copy link

JoshuaFox commented Apr 12, 2020

Create a DataStudio report following instructions.

With some projects, you get a blank widget that is based on cost_with_unallocated_untracked. See attachment missing data.jpg. This is ultimately because for some values of sku, the SUM(usage.amount) is 0 in the billing-export table. Presumably this is an ordinary occurrence when an SKU is unused, and so this case should be handled.

Minimal reproduction of divide-by-zero error follows. (To run it, replace table and project identifiers). This is a subquery directly from the connector sourcecode and only uses one table, so the problem is not in complex joins, just in the usage of data that can have zero values.

SELECT
  sku.id AS sku_id,
  project.id AS project_id,
  MIN(usage_start_time) AS min_usage_start_time,
  MAX(usage_end_time) AS max_usage_end_time,
  SUM(usage.amount) AS amount,
  usage.unit AS usage_unit,
  SUM(cost) AS cost,
   (SUM(cost) / SUM(usage.amount)) AS rate
FROM
  `MY_BILLING_EXPORT_PROJECT.BILLING_EXPORT_DATASET.BILLING_EXPORT_TABLE`
WHERE
  usage_start_time >= TIMESTAMP("2010-00-00")
  AND usage_end_time <= TIMESTAMP("2030-01-01")
 AND project.id = "MYPROJECT"
GROUP BY
  project.id,
  sku.id,
  usage.unit

Solution: Handle cases with value 0.

A related issue is at the Google Issue tracker, but apparently here at GitHub is the right place for the elements of this bug that involve the connector.

@JoshuaFox
Copy link
Author

Here is what the blank widget looks like; and the error dialog. These don't give much info, but the query above helps diagnose this.

missing data

error dialog

@JoshuaFox JoshuaFox changed the title 153799905 GKE Usage Metering Data Studio connector fails on divide-by-zero error GKE Usage Metering Data Studio connector fails on divide-by-zero error Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant