<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Andi Partovi on Medium]]></title>
        <description><![CDATA[Stories by Andi Partovi on Medium]]></description>
        <link>https://medium.com/@andi_91543?source=rss-1531492e521c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ABFHpvyhi_czHdHI</url>
            <title>Stories by Andi Partovi on Medium</title>
            <link>https://medium.com/@andi_91543?source=rss-1531492e521c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:32:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@andi_91543/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a data analytics dashboard on GCP — Part II]]></title>
            <link>https://medium.com/@andi_91543/building-a-data-analytics-dashboard-on-gcp-part-ii-11e05d617d5f?source=rss-1531492e521c------2</link>
            <guid isPermaLink="false">https://medium.com/p/11e05d617d5f</guid>
            <category><![CDATA[google-cloud]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Andi Partovi]]></dc:creator>
            <pubDate>Wed, 23 Mar 2022 05:02:45 GMT</pubDate>
            <atom:updated>2022-03-23T05:02:45.709Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a data analytics dashboard on GCP — Part II</h3><p>In <a href="https://medium.com/@andi_91543/building-a-data-analytics-dashboard-on-gcp-part-i-6249c42592e">part I</a>, I talked about the business problem we are trying to solve, and built the first version of the product to solve it. There were a few flaws in our design, some processes that were manual, and some non-functional requirements that were missing. In each subsequent part of this blog, we will build on top of our first solution and make it better. Each version will be a shippable version that satisfies the core requirements.</p><p>In this version, we will use Cloud Scheduler, BigQuery Python API, and Google Cloud Functions to automate the manual components of our solution, and make the dashboard dynamic with automatic updates.</p><p><strong>MVP Version 2 — Dynamic dashboard</strong></p><p>This version will automate the running of the RSS feeder code, and writing the data to BigQuery through APIs. The bolded components are additions to the previous version:</p><ol><li>A python code that reads the RSS feed and parses the website and outputs the data in a CSV format</li><li><strong>Writing the data back to BigQuery using Python API</strong></li><li><strong>Running the RSS feeder and data write back automatically and on a schedule, using Cloud Scheduler and Google Cloud Functions</strong></li><li>Run analytics queries in BigQuery</li><li>Build a dashboard in Google Data Studio connected to the BigQuery</li><li>Publish the dashboard in a static website</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*36VN0xrMrOScP5wCaMB6mg.png" /><figcaption>Architecture diagram V2</figcaption></figure><p><strong>Step 1 —Add BigQuery API to the Python code</strong></p><p>Let’s modify our Python code from <a href="https://medium.com/@andi_91543/building-a-data-analytics-dashboard-on-gcp-part-i-6249c42592e">part I</a> to now write the scraped data to BigQuery automatically through APIs. We will:</p><ul><li>Add BigQ necessary libraries: pandas.io, pandas_gbq, gcsfs<br>gcsfs enables connections to cloud storage. pandas.io and pandas_gbq enable interactions with Google cloud and BigQ. pandas_gbq has two very handy functions:<br>- to_gbq: writing data to a BigQ table.<br>e.g. pandas_gbq.to_gbq(dataframe, “dataset.table”)<br>- read_gbq: running queries in BigQ tables<br>e.g. pandas_gbq.read_gbq(“SELECT * FROM dataset.table”)</li><li>Make sure that we have an entry point function, which gets “requests” as an argument, and has a return. We are not really using this “requests” argument, but GCF requires it.</li></ul><p>I am basing this step heavily on <a href="https://towardsdatascience.com/how-to-upload-data-to-google-bigquery-using-python-in-3-steps-7138ae625fe3">this tutorial</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/26688062e85149e2cc546fe5eba27e38/href">https://medium.com/media/26688062e85149e2cc546fe5eba27e38/href</a></iframe><p>With these changes implemented, we can create a GCF instance and run the code serverless-ly.</p><p><strong>Step 2 — Run the Python code through Google Cloud Functions (GCF)</strong></p><p>So far, we have been running our Python code snippet manually. We want to automate this part and do it on the cloud as opposed to a local machine. There are a number of ways we can do this on GCP. You might have seen this chart, as the different alternatives for compute in GCP:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*H5YIaOOFWjg4J-CTGKFGcw.png" /><figcaption>Compute options in GCP</figcaption></figure><p>On the most low-level side of the spectrum, we have Compute Engine (GCE), GCP’s Infrastructure as a service (IaaS) offering. If we go with this solution, we can spin out a VM, install Python and the required libraries, install git then clone the above code from a repository, and finally schedule a cron job to run that code at specific times. This is a perfectly valid solution and can achieve what we are trying to achieve here. There are a couple of considerations however that might make this a less suitable option, compared to the other side of the spectrum, managed services.</p><p>There are steps in the above solution that is handles by the user, but can be managed automatically by GCP, when we move to a more managed solution like GAE (which is a Platform as a Service solution) or GCF (which is a Function as a Service solution):</p><ul><li>We need to decide the size of the VM in terms of CPU, memory, disk size, etc. If our needs change later, we have to manually change the VM or provision a new one. We have to keep monitoring the VM to manage this</li><li>We need to install all the required software and libraries and manage their versions ourselves</li><li>The VM has to be constantly running (constantly being billed for usage), even if the cron job is not active for some time</li></ul><p>While IaaS solutions give more flexibility, in an application like ours where that is not needed, we can opt for a managed service (PaaS or FaaS) that is taking care of some or all of the above points. In “serverless” services, the server provisioning and configuration is hidden from the user and is handled by the cloud provider. This helps in saving cost and reducing devops efforts.</p><p>Note that GKE and GAE are also viable options, each taking care of some of the devops aspect that is manual in a GCE solution. So ultimately, we can build the same solution on all 4 options, with different pricings, different management responsibilities, and flexibility levels.</p><p>With that background, let’s start building a GCF. GCF manages all of the above tasks and only bills the account when it is run (invoked). Running the GCF can be triggered by a HTTP request, a change in the Google Cloud Storage, a pub/sub topic, or an array of Firebase triggers. It is the perfect choice for event or schedule based applications and microservice architectures.</p><p>If it is the first time you are using GCF, there are some set up steps that you need to do. Firstly, enable GCF API: make sure that billing is enabled for the project, then go to APIs and enable GCF</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*rhJi3cDdE5_nyAKFxZVrPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*jmtF_8Y0rIXPj09Wl_AhgQ.png" /><figcaption>Enable GCF API</figcaption></figure><p>Then create a new GCF. As mentioned, there are different types of trigger for GCF. Choose HTTP for now and allow unauthenticated invocations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*68LpUsnvCorCjBFK8Ca0Cg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*4J5CHwkhKJ3gBUBudzFGgA.png" /><figcaption>Create new GCF</figcaption></figure><p>Choose Python for the runtime environment and paste your code. Also add library requirements to the requirements tab</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WOyF_19qHu5rf9RBw0PiCQ.png" /><figcaption>Python runtime for source code</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*KqvVnepxLhjI8bCdyhcnfg.png" /><figcaption>Requirements file outlines the libraries our code uses</figcaption></figure><p>Create a new permission, by allowing all users to invoke this GCF (if doesn’t exist under permissions). Choose allUsers and give “Cloud Functions Invoker” permission to the user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*LhyPA8-7ngKG8q8Us_RnmA.png" /><figcaption>Create new role</figcaption></figure><p>Try triggering the function by opening the trigger URL in a browser. You can also test it in the GCF menu. There are a couple of troubleshooting tips to keep in mind. The “details” page and “Logs” are your friends in debugging your code. Also try as much of the code offline first, before pushing it to GCF.</p><p><strong>Step 3 — Schedule GCF to run twice a day with Cloud Scheduler</strong></p><p>Now that our scraping code snippet can be called and run with GCF, let’s add a small component to make it run twice a day automatically with Cloud Scheduler. Scheduler is like an alarm clock that wakes our function up at a regular time and runs it. It is the equivalent of cron jobs in Operating Systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*1tf7XKQjjJWgDiHV6FbSwg.png" /><figcaption>Create a new scheduler</figcaption></figure><p>This is the last bit of automation needed to run everything automatically and shift the whole product to the cloud. The last step below is adding a visualisation component to improve the report.</p><p><strong>Step 4 — Dashboard improvement: add a timeline view</strong></p><p>For this version, I want to do one last update to the appearance of our BI dashboard to include a timeline. The line chart we currently have doesn’t quite convey a timeline. In future versions, we will keep improving the visualisation.</p><p>Data Studio offers a range of community-built visualisations that complement the out-of-the-box components. Here we will add a Gantt chart to display medication shortage timelines.</p><p>Let’s create a second page in our Data Studio dashboard. Go to your saved report on <a href="https://datastudio.google.com/">https://datastudio.google.com/</a> and click on the page number, then add a new page. You can name each report page separately.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*mkJ2pqtB5A21eLy5igO53Q.png" /><figcaption>Add new page</figcaption></figure><p>Then add the Gantt chart from community visualisations</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*d5maJPRGPeXJvEhKerQ8FA.png" /></figure><p>The first time you add a community chart, you have to give permission for these 3rd party charts to use the data. If you are facing issues here, check the data source and make sure community access is On and you are the owner of data credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KsZWfIxzPD7p8SK32LCexA.png" /><figcaption>Checking community access</figcaption></figure><p>Configure the parameters to see the below timeline view.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*U77bXJHH_brm88D-rI8_TQ.png" /><figcaption>Build a Gantt chart from our dataset</figcaption></figure><p>You will get the following diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5E_-Ep9h3t4cChrHSjbtGw.png" /><figcaption>Gantt chart as our timeline</figcaption></figure><p>Now while this is not very pretty, it is a minor improvement over the line chart we had in the first page. We need to clean up the medication names and categorise them to make this diagram readable. This and architecture improvements will be the focus of part III.</p><p>That’s it for V2 of our product. Again, we have ended up with a shippable product that satisfies the core functionalities with improvements in different areas. In part III, we will make some architecture improvements and add more data clean up and processing. Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11e05d617d5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a data analytics dashboard on GCP — Part I]]></title>
            <link>https://medium.com/@andi_91543/building-a-data-analytics-dashboard-on-gcp-part-i-6249c42592e?source=rss-1531492e521c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6249c42592e</guid>
            <category><![CDATA[mvp]]></category>
            <category><![CDATA[google-cloud-platform]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-visualisation]]></category>
            <category><![CDATA[business-intelligence]]></category>
            <dc:creator><![CDATA[Andi Partovi]]></dc:creator>
            <pubDate>Thu, 17 Mar 2022 22:01:53 GMT</pubDate>
            <atom:updated>2022-03-23T05:04:15.627Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a data analytics dashboard on GCP — Part I</h3><p>Recently I came across a cool business problem to visualise medication supply chain disruptions, something that can be viewed by medical doctors and pharma companies to make decisions and find substitutes based on. This was around the time that I was refreshing my Google Cloud Platform (GCP) knowledge and seemed like the universe wants me to build this tool using GCP services!</p><p>This dashboard is live and you can view it at: <a href="http://www.medalarm.info/">www.medalarm.info</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BaOLLZrHmSBK8v-RUzvyjg.png" /><figcaption>High level business objective</figcaption></figure><p>Like other projects in my startup, I approached this from a product management iterative approach and thought about the different versions that can achieve the bare minimum requirements of the projects and gradually built on that. I documented this whole process from both the product management and technical build perspective, which became this series of hands-on tutorials on GCP. This series does not assume any prior knowledge of cloud or GCP, and is objective-focused, meaning if something is not relevant to the project objective, it is generally only brushed on or not mentioned at all.</p><p>In <em>Part I</em>, I will talk about the business problem we are solving and what the first version looks like. From the build perspective, I present a tutorial on: Google Cloud Storage, Big Query, and Data Studio as I build the static version of the solution.</p><p><a href="https://medium.com/@andi_91543/building-a-data-analytics-dashboard-on-gcp-part-ii-11e05d617d5f">In <em>part II</em></a>, I will automate all the steps in the Version 1 solution and make the dashboard update automatically. For that, I will go into more details about Google Cloud Functions, Big Query Python APIs, and Cloud Scheduler.</p><p>In <em>part III</em>, I will improve the architecture by adding DataFlow and Cloud Composer, and redo the visualisation dashboard in Python.</p><p><strong>Business problem</strong></p><p>The COVID interruptions to the global supply chain has dire implications on medication shortage. Medical doctors and pharmaceutical companies need to know what medications are in shortage and for how long to be able to make decisions like prescribing alternatives or changing clinical trial parameters.</p><p>Australia’s TGA (Therapeutic Goods Administration) publishes the list of medication shortages in Australia on their website, but the information is presented in a long table format with no visualisation. We want to build an interactive BI dashboard that is fed TGA’s data but allows users to see the supply chain issues in nicer graphics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*7jOWLGD4sQaDtx9bvA0JzQ.png" /><figcaption>Snapshot of TGA’s website — <a href="https://apps.tga.gov.au/prod/MSI/search">https://apps.tga.gov.au/prod/MSI/search</a></figcaption></figure><p><strong>Solutions</strong></p><p>The core business requirements are visualising the data in an online dashboard, so every version of our product will fulfill this business objective. Each version is also fully functional and shippable.</p><p><strong>MVP Version 1 — Offline dashboard</strong></p><p>V1.0: A one-off static version of the dashboard that gets the data from TGA once, and present in a dashboard.</p><p>Components:</p><ol><li>A python code that reads the RSS feed and parses the website and outputs the data in a CSV format</li><li>Manually uploading the CSV in Google Big Query</li><li>Run analytics queries in Big Query</li><li>Build a dashboard in Google Data Studio connected to the Big Query</li><li>Publish the dashboard in a static website</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/790/1*-9ntlaMNpQRrtW_nHcA9vg.png" /></figure><p>This architecture is not following best practice…yet. This will be fixed as we add new components in the next parts.</p><p><strong>Step 1 — Build the RSS Feeder with Python</strong></p><p>The Python code below retrieves the information we need from the TGA website. We will first access the RSS feed, which returns an XML file. The XML includes the title of the medication, the cause of supply chain disruption, and a link to where we can find the disruption dates. We need to look for the dates in the underlying code of the medication link. The Python code uses these libraries:</p><ul><li>Requests handles the http request reading</li><li>BeautifulSoup handles the extraction and parsing of the RSS feed (XML file)</li><li>CSV to save the list in a csv</li><li>Re (regex) converts the date format</li><li>Datetime transform a date string to datetime object</li><li>Pandas creates a dataframe from dict and saves to csv file</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/de3a0a8dbc334d91e9a1cb6fba653f7d/href">https://medium.com/media/de3a0a8dbc334d91e9a1cb6fba653f7d/href</a></iframe><p><strong>Step 2 — Enter the Big Query!</strong></p><p>Big Query is the crown jewel of GCP. It is <em>the </em>enterprise data warehouse solution to handle analytics of Petabytes of data. We are however using it for the very small dataset we made in the previous step.</p><p>BigQ is a typical OLAP data warehouse, designed for fast analytics over massive amounts of data. It can ingest data from multiple sources, store them in a columnar and distributed storage system, and enable running SQL queries over them. All of these are managed by GCP, meaning that there is no need to provision storage or compute.</p><p>For this version of the product, we will manually upload the CSV file. In the next version, we will automate this step using Big Query Python APIs. Also for this version, we are not following the best practice around keeping a copy of our raw data in a storage bucket and ingest from there. We are going straight to BigQ. We will improve on this architecture as we build onto the solution in the next part.</p><p>To upload the file, first make a new dataset, then add a table. This can be done on the GUI or using Cloud Shell. Cloud shell is an amazing tool that gives you a very quick access to a VM to run CommandLine Interface super quickly. This is equivalent of spinning up a VM (Compute Engine) and then decommission it once done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*U4s2iT-9-6YunVOUMLcRaA.png" /><figcaption>How to access and activate cloud shell</figcaption></figure><pre>bq mk TGA_medalert_dataset</pre><p>You can also do it on the GUI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tw2Hzp4mXfQN04XhXiMXzQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/519/1*9NPQ4NSdIO-jauyOiWttKQ.png" /><figcaption>Creating a dataset using GUI</figcaption></figure><p>Then create a table in the dataset</p><p>Using the GUI: click on the dataset option menu and choose create table</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*ND6YHr0en_IKokk83SPUow.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQElnP6lvjf3VegvL5IT9g.png" /><figcaption>Choose the upload option and set the table name</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*60I4Uj9GTHfT8BhrDQi_tA.png" /><figcaption>Setting the table schema</figcaption></figure><p>Schema tells our relational database (BigQuery) on what are each columns of the data. Setting the Schema manually often works better than letting BigQuery automatically figure it out, but that is also an option. Also the date format has to be YYYY-MM-DD for BigQuery to parse the input as DATE.</p><p>Because our CSV has a header row, in the Advanced option, we will set the header rows to skip to 1. Generally speaking, partitioning and clustering the database table is critical to get good performance in a big data setting. You can learn all about it <a href="https://youtu.be/wapi0aR4BZE">here</a>. For our small dataset however, it is not critical.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5zM8wmJWNZlMKsV9ajKJrw.png" /><figcaption>Creating the table using GUI</figcaption></figure><p>You can preview the table and run queries once it is created</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c-CiidOy3N2kZrb1BlkjNw.png" /><figcaption>Table preview</figcaption></figure><p>Let’s do a very simple query, to see the different descriptions, and how many of each we have. Note that BigQuery will charge based on the amount of data being processed, which you will get a preview of in the top right corner, <em>before </em>running the query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1009/1*EABQtSjcFKj19pc6YUYBmQ.png" /><figcaption>Query preview</figcaption></figure><p>Now let’s select all of the data and go to Data Studio for visualisation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HTzXDVeScNbEX1y4Up10IQ.png" /><figcaption>Run the query, then go to Data Studio</figcaption></figure><p><strong>Step 3 — Dashboarding with Data Studio</strong></p><p>So far, we have scraped the data from TGA’s website, put it in a structured CSV format and uploaded that into a Big Query SQL-based table. Now we want to visualise the data. For this version of the product, I will do a very simple visualisation, instead of the final polished product. But remember that each version has to be shippable, so we need to build a timeline, even if not pretty.</p><p>There a handful of good Business Intelligence (BI) dashboards in the market. You might have worked with <a href="https://www.tableau.com/">Tableau</a>, which is the most mature one in functionality (also the most expensive one). GCP’s Data Studio is free, and is very easy to pick up. Options are easy to figure out and there is a growing catalogue of community-built visualisations to choose from as well. It does not however offer the same level of complexity as Tableau. So my rule of thumb is start with the free Data Studio tool, and if you hit barriers with your visualisation, then seek alternatives. We are going to look at visualisation with Dash in later parts of this tutorial for a very customised look.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qVNqsPwPDAtdAD7PiyFBYw.png" /><figcaption>Building a crude timeline with line chart</figcaption></figure><p>Although this is a very basic visualisation, it will do for the first version. Hit “save” and then “share”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*W5tAQq1ViXOcnVQNP3Abew.png" /><figcaption>Share the explorer</figcaption></figure><p>That takes us from the “explorer view” to the “report view”. Here I can add more elements to make this report look better. Here I added a few text boxes, will links and also another diagram</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TRaZxHn27J6q10DbEED-fQ.png" /><figcaption>Reprot view</figcaption></figure><p>Click on “share” drop-down menu and choose “Embed report” since we want to embed this into a HTML webpage. Alternatively, we can just share the report link, but that won’t look as nice (especially in future versions)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pHrk5FQtXqEzD8rFm6EWIw.png" /><figcaption>Getting an embedding link</figcaption></figure><p>You will get an iframe to embed in your website</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/801/1*YeUM1dL5TCD1-pSIv-UTiw.png" /><figcaption>Getting an embedding link</figcaption></figure><p>Also make sure that the link is publicly available. Click on “share” again and go to “Manage access” tab, then choose “Anyone on the Internet can find and view” option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1014/1*nJQ_hWWl4xt6Xw4B5o53KQ.png" /><figcaption>Making the report public</figcaption></figure><p><strong>Step 4— Static webpage with Google Cloud Storage</strong></p><p>Let’s finish up by building a HTML webpage and hosting it on GCP. Since this version of the product is only a static website, we can use Google Cloud Storage buckets for a quick deploy. For this step, we are largely following the tutorial <a href="https://cloud.google.com/storage/docs/hosting-static-website?utm_source=youtube&amp;utm_medium=unpaidsocial&amp;utm_campaign=ram-20190815-Hosting-Static-Website">here</a>.</p><p>Our “index.html file” will only embed the report link (I have changed the sizes here:</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;body&gt;</pre><pre>&lt;iframe width=&quot;1200&quot; height=&quot;900&quot; src=&quot;<a href="https://datastudio.google.com/embed/reporting/cbd5b1ef-c0e5-4786-aa6b-2c26dd6b4853/page/XRHoC">https://datastudio.google.com/embed/reporting/cbd5b1ef-c0e5-4786-aa6b-2c26dd6b4853/page/XRHoC</a>&quot; frameborder=&quot;0&quot; style=&quot;border:0&quot; allowfullscreen&gt;&lt;/iframe&gt;</pre><pre>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>Not let’s host this on GCS. First choose the domain you are hosting this on. For us is <a href="http://www.medalarm.info/">www.medalarm.info</a>. I used Google Domains to buy this, but any domain manager will work the same.</p><p>Create a GCS bucket with the name of your top-level domain, so for us it has to be “medalarm.info” (not “www.medalarm.info”). Go to Cloud Storage and create a bucket. You can also use the CLI. In terms of options:</p><ul><li>Multi-region: the best performance, but also the most expensive option. Hosts the bucket on multiple region. Here I am using single region in Melbourne, which is closer to me.</li><li>Choose “standard” storage as we need to access this bucket often. The other options are discounted if the bucket is not accessed often.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*-f3O3v45xvOK2RSoEWVBEA.png" /><figcaption>Creating a bucket</figcaption></figure><p>Upload the index.html file into the bucket</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hCY9rfU4q7N-J3224_wtTQ.png" /><figcaption>Uploading the index.html file</figcaption></figure><p>Since we need the Internet to access this bucket, we need to add a new permission for it. Add a new permission for “allUsers” to be “Storage Object Viewer”. This will make the bucket public to the entire Internet</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/627/1*RvM0_zA4pWdp5I59EEZPBQ.png" /><figcaption>Making the storage bucket public</figcaption></figure><p>Now let’s direct the traffic for our domain to here. For this, we need to add a CNAME DNS record in our domain manger. So I added this on Google Domains. Use the below parameters for adding the record. Like any DNS record change, allow an hour or so for this to be propagated over the internet. You can always check your routings <a href="https://toolbox.googleapps.com/apps/dig/#ANY/">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o0lYNsNu4_gWw-w0mXzrXQ.png" /></figure><p>One last step to do is to add a main page and 404 page pointers to the bucket so when user accesses those addresses, GCS knows where to direct the traffic. We did not design a 404 for our website, but we can point main to index.html</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_fl4rcHYYCueY5HjouJxUA.png" /><figcaption>Editting the website config</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/693/1*3s_kbmx8UoZrbV3bJTzSUg.png" /><figcaption>Editting the website config</figcaption></figure><p>Troubleshooting this whole step might be tricky, you can refer to <a href="https://stackoverflow.com/questions/40735724/connect-google-domain-to-google-cloud-bucket">this list</a> for troubleshooting.</p><h3><strong>First version is ready!</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WWgbvSJY4oyl9amd-PfC5A.png" /><figcaption>Our hosted report — V1</figcaption></figure><p>We are done with the first version of our product! It is satisfying all the core customer needs, but there are lots of improvements we can apply to it. The process is still very manual, the dashboard does not update automatically, and our timeline…well, is not really a timeline. I will fix all these problems in the next versions.</p><p>You can continue to <a href="https://medium.com/@andi_91543/building-a-data-analytics-dashboard-on-gcp-part-ii-11e05d617d5f">part II</a>, where we will add dynamic updates and make the whole process automatic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6249c42592e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>