How to account for traffic in GCP

The following may be used as a custom metric to weight scale decisions.


SELECT TIMESTAMP_TRUNC(TIMESTAMP, MINUTE) AS ts,

sum(CAST (jsonPayload.bytes_sent AS INT64)) AS sent, jsonPayload.dest_instance.zone AS dst_zone, jsonPayload.dest_instance.vm_name
FROM delasport-prod.NetFlow.compute_googleapis_com_vpc_flows_*
WHERE _TABLE_SUFFIX IN (
FORMAT_DATE("%Y%m%d",CURRENT_DATE),
FORMAT_DATE("%Y%m%d", DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY)))
AND TIMESTAMP_DIFF(TIMESTAMP_SUB(CURRENT_TIMESTAMP, INTERVAL 60 MINUTE),TIMESTAMP,MINUTE) < 60
AND jsonPayload.src_instance.zone IS NOT NULL
AND jsonPayload.dest_instance.zone IS NOT NULL
AND jsonPayload.src_instance.zone != jsonPayload.dest_instance.zone
AND jsonPayload.bytes_sent != "0" group by ts,jsonPayload.dest_instance.zone, jsonPayload.dest_instance.vm_name

 

 

SELECT
count(*) as cnt, _TABLE_SUFFIX as table_name
FROM
[$Project].[$dataset].*
Where _TABLE_SUFFIX like '%20201116%'
Group by table_name
Order by cnt DESC

Leave a Reply

Your email address will not be published. Required fields are marked *