DENG-4691: Add view for fakespot cost data in dataservices prod project (#6163)
* DENG-4691: View for fakespot cost data in "dataservices-high-prod" project - Only Kuberay created Ray serve app costs are included
This commit is contained in:
Родитель
ae96d4e981
Коммит
b5f4adb19e
|
@ -188,6 +188,7 @@ dry_run:
|
|||
- sql/moz-fx-data-shared-prod/monitoring_derived/outerbounds_cost_per_flow_run_v1/view.sql
|
||||
- sql/moz-fx-data-shared-prod/monitoring_derived/outerbounds_cost_per_flow_v1/view.sql
|
||||
- sql/moz-fx-data-shared-prod/monitoring_derived/rayserve_cost_fakespot_tenant_v1/view.sql
|
||||
- sql/moz-fx-data-shared-prod/monitoring_derived/rayserve_cost_fakespot_tenant_prod_v1/view.sql
|
||||
# Query templates
|
||||
- sql/moz-fx-data-shared-prod/search_derived/mobile_search_clients_daily_v1/fenix_metrics.template.sql
|
||||
- sql/moz-fx-data-shared-prod/search_derived/mobile_search_clients_daily_v1/mobile_search_clients_daily.template.sql
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
CREATE OR REPLACE VIEW
|
||||
`moz-fx-data-shared-prod.monitoring_derived.rayserve_cost_fakespot_tenant_prod_v1`
|
||||
AS
|
||||
WITH cost_data AS (
|
||||
SELECT
|
||||
cost + (IFNULL((SELECT SUM(c.amount) FROM UNNEST(credits) c), 0)) AS total_cost,
|
||||
DATE_TRUNC(usage_start_time, DAY) AS invoice_day,
|
||||
(SELECT value FROM UNNEST(labels) WHERE KEY = "k8s-namespace") AS k8s_namespace,
|
||||
(
|
||||
SELECT
|
||||
value
|
||||
FROM
|
||||
UNNEST(labels)
|
||||
WHERE
|
||||
-- the label to identify the kuberay created ray serve workloads
|
||||
KEY = "k8s-label/app.kubernetes.io/created-by"
|
||||
) AS k8s_label_akio_createdBy,
|
||||
FROM
|
||||
`moz-fx-data-shared-prod.billing_syndicate.gcp_billing_export_resource_v1_01E7D5_97288E_E2EBA0`
|
||||
WHERE
|
||||
project.id = "moz-fx-dataservices-high-prod"
|
||||
AND DATE(usage_start_time) >= '2024-01-01'
|
||||
AND service.description = "Compute Engine"
|
||||
),
|
||||
cost_data_per_day AS (
|
||||
SELECT
|
||||
SUM(total_cost) AS total_cost_per_day,
|
||||
invoice_day,
|
||||
k8s_namespace,
|
||||
k8s_label_akio_createdBy,
|
||||
FROM
|
||||
cost_data
|
||||
WHERE
|
||||
k8s_namespace = "fakespot-ml-prod"
|
||||
AND k8s_label_akio_createdBy = "kuberay-operator"
|
||||
GROUP BY
|
||||
invoice_day,
|
||||
k8s_namespace,
|
||||
k8s_label_akio_createdBy
|
||||
ORDER BY
|
||||
invoice_day
|
||||
)
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
cost_data_per_day
|
Загрузка…
Ссылка в новой задаче