<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>looker studio Archives - Big Data Processing</title>
	<atom:link href="https://bigdataproc.com/category/gcp/looker-studio/feed/" rel="self" type="application/rss+xml" />
	<link>https://bigdataproc.com/category/gcp/looker-studio/</link>
	<description>Big Data Solution for GCP, AWS, Azure and on-prem</description>
	<lastBuildDate>Thu, 26 Oct 2023 13:08:40 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.3.2</generator>
	<item>
		<title>Google Bigquery &#8211; Find Query Cost By User</title>
		<link>https://bigdataproc.com/google-bigquery-find-query-cost-by-user/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=google-bigquery-find-query-cost-by-user</link>
					<comments>https://bigdataproc.com/google-bigquery-find-query-cost-by-user/#respond</comments>
		
		<dc:creator><![CDATA[Gaurang]]></dc:creator>
		<pubDate>Fri, 02 Jun 2023 18:02:30 +0000</pubDate>
				<category><![CDATA[bigquery]]></category>
		<category><![CDATA[GCP]]></category>
		<category><![CDATA[looker studio]]></category>
		<category><![CDATA[gcp]]></category>
		<guid isPermaLink="false">https://bigdataproc.com/?p=393</guid>

					<description><![CDATA[<p> Discover how to optimize BigQuery costs on Google Cloud Platform (GCP) by identifying users responsible for high query execution expenses. Learn effective strategies, including the use of BigQuery labels and the Job Information Schema, to educate users on cost-efficient query execution and achieve desired data analysis outcomes.</p>
<div class="more-link-wrapper"><a class="more-link" href="https://bigdataproc.com/google-bigquery-find-query-cost-by-user/">Continue reading<span class="screen-reader-text">Google Bigquery &#8211; Find Query Cost By User</span></a></div>
<p>The post <a rel="nofollow" href="https://bigdataproc.com/google-bigquery-find-query-cost-by-user/">Google Bigquery &#8211; Find Query Cost By User</a> appeared first on <a rel="nofollow" href="https://bigdataproc.com">Big Data Processing </a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The organization I am currently consulting has recently migrated to the Google Cloud Platform (GCP) to leverage its powerful services, including Google BigQuery for efficient big data analysis. However, we have observed a significant increase in Query Execution costs and deemed it necessary to investigate the users or teams responsible for these expenses. By identifying the high spenders, we can provide them with valuable insights on optimizing query execution to minimize costs. It&#8217;s important to note that these users are transitioning from an on-premises environment where a CAPEX model was implemented, and they may not be fully aware of the cost implications associated with every query on GCP&#8217;s BigQuery. We aim to educate them on optimizing their queries to achieve the desired output while minimizing expenses effectively .</p>



<p>In this blog post, we will explore effective strategies to identify which teams or users are driving up costs</p>



<h2 class="wp-block-heading">Use BigQuery Labels for Cost Attribution</h2>



<p> To track query costs accurately, one option is to employ BigQuery labels. Although this method requires users to set labels manually before executing queries, it provides granular cost attribution. However, relying solely on users&#8217; compliance may not always yield optimal results.</p>



<h2 class="wp-block-heading">Leverage BigQuery Job Information Schema </h2>



<p>BigQuery maintains detailed information for each job execution, including user details, slot utilization, and data processed. By querying the job information schema, you can calculate the query analysis cost per user accurately.</p>



<p> Ensure that the following permissions are granted to run this query: </p>



<ul>
<li>bigquery.resourceViewer</li>



<li>bigquery.metadataViewer</li>
</ul>



<pre class="EnlighterJSRAW" data-enlighter-language="sql" data-enlighter-theme="" data-enlighter-highlight="" data-enlighter-linenumbers="" data-enlighter-lineoffset="" data-enlighter-title="" data-enlighter-group="">SELECT
  user_email,
  SUM(total_cost) total_cost_per_user
FROM (
  SELECT
    reservation_id,
    user_email,
    CASE
      WHEN reservation_id IS NULL THEN (SUM(total_bytes_processed)/1024/1024/1024/1024)*5 -- 5 USD by TB processed 
      WHEN reservation_id is not null and reservation_id &lt;> "default-pipeline" then (SUM(jbo.total_slot_ms)/(1000*60*60))*0.069 -- 0.69 USD per slot hour for northamerica-northeast1
  END
    AS total_cost
  FROM
    region-northamerica-northeast1.INFORMATION_SCHEMA.JOBS_BY_ORGANIZATION jbo
  WHERE
    DATE(creation_time) >= "2023-05-01" --change the filter 
  GROUP BY
    reservation_id,
    user_email )
GROUP BY
  user_email
ORDER BY
  total_cost_per_user DESC</pre>



<h2 class="wp-block-heading">Understand the Limitations of Cost Calculation using Information Schema</h2>



<p>If your organization is utilizing on-demand pricing in BigQuery, the cost calculated through the information schema will closely align with the cost report. </p>



<p>However, if you organization is using auto-scalling slots, cost calculation through the information schema may not provide accurate results. While the information schema captures slot utilization during query execution, it doesn&#8217;t account for slots used during scale-up, scale-down, or the cooldown period. As a result, there may be discrepancies between the cost reported in the information schema and the actual cost shown in the cost report. This difference becomes more prominent for queries with shorter execution times (within 1 minute).</p>



<h2 class="wp-block-heading">Looker Studio Reports for Quick Analysis and Visualization</h2>



<p>To streamline the process of extracting query cost information, consider creating Looker Studio reports. These reports offer date filters, enabling quick access to the desired information. Additionally, Looker Studio reports provide a visual representation of query costs, facilitating a better understanding of cost trends and patterns.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img decoding="async" fetchpriority="high" width="1024" height="565" src="https://bigdataproc.com/wp-content/uploads/2023/06/bq_cost_per_user-1024x565.jpg" alt="" class="wp-image-399" srcset="https://bigdataproc.com/wp-content/uploads/2023/06/bq_cost_per_user-1024x565.jpg 1024w, https://bigdataproc.com/wp-content/uploads/2023/06/bq_cost_per_user-300x165.jpg 300w, https://bigdataproc.com/wp-content/uploads/2023/06/bq_cost_per_user-768x423.jpg 768w, https://bigdataproc.com/wp-content/uploads/2023/06/bq_cost_per_user.jpg 1090w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure></div><p>The post <a rel="nofollow" href="https://bigdataproc.com/google-bigquery-find-query-cost-by-user/">Google Bigquery &#8211; Find Query Cost By User</a> appeared first on <a rel="nofollow" href="https://bigdataproc.com">Big Data Processing </a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://bigdataproc.com/google-bigquery-find-query-cost-by-user/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
