<?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 Leo Rocca on Medium]]></title>
        <description><![CDATA[Stories by Leo Rocca on Medium]]></description>
        <link>https://medium.com/@leonardo.rocca_34863?source=rss-210da5ce9e00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*gwO8CPiJwIhAtIfE</url>
            <title>Stories by Leo Rocca on Medium</title>
            <link>https://medium.com/@leonardo.rocca_34863?source=rss-210da5ce9e00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 05:41:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@leonardo.rocca_34863/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[Automating Google Cloud VMware Engine Deployments]]></title>
            <link>https://medium.com/globant/automating-google-cloud-vmware-engine-deployments-a14fb5649044?source=rss-210da5ce9e00------2</link>
            <guid isPermaLink="false">https://medium.com/p/a14fb5649044</guid>
            <category><![CDATA[gcve]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[cloudops]]></category>
            <dc:creator><![CDATA[Leo Rocca]]></dc:creator>
            <pubDate>Sat, 26 Oct 2024 13:16:40 GMT</pubDate>
            <atom:updated>2024-10-26T13:16:40.982Z</atom:updated>
            <content:encoded><![CDATA[<h4>To survive long deployments</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*96gNFzoPf0pkAQzf" /><figcaption>Photo by <a href="https://unsplash.com/@museumsvictoria?utm_source=medium&amp;utm_medium=referral">Museums Victoria</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>This article aims to streamline the configuration and deployment of GCVE (<a href="https://cloud.google.com/vmware-engine/docs/overview">Google Cloud VMware Engine</a>). We will use Cloud Build as a CI/CD platform and Terraform as an IaC (Infrastructure as Code) tool. <a href="https://cloud.google.com/build/docs/overview">Cloud Build</a> is a serverless CI/CD platform that executes GCP builds. Cloud Build can import source code from several repositories, such as <a href="https://en.wikipedia.org/wiki/GitHub">GitHub</a>, <a href="https://en.wikipedia.org/wiki/GitLab">GitLab</a>, and <a href="https://en.wikipedia.org/wiki/Bitbucket">Bitbucket</a>.<br> <a href="https://developer.hashicorp.com/terraform?product_intent=terraform">Terraform</a> is a multi-cloud IaC tool. It’s able to define, deploy, and manage cloud resources consistently.</p><p>The main goal is to avoid trial-and-error deployment because deploying a GCVE private cloud takes more than an hour. To accomplish that, we will configure the resources used to support long deployments.</p><h3>GCVE Architecture</h3><p>Google&#39;s official <a href="https://cloud.google.com/vmware-engine/docs/overview">documentation</a> defines its VMware cloud service as “a fully managed service that lets you run the VMware platform in Google Cloud. The VMware environment runs natively on Google Cloud bare-metal infrastructure in different locations and fully integrates with the rest of Google Cloud.”</p><p>There are several use cases for GCVE, such as:</p><ul><li>Retire or migrate data centers.</li><li>Scale capacity on demand.</li><li>Disaster recovery.</li></ul><p>Figure 1 illustrates the GCVE architecture, which consists of two primary components. A VEN (VMware Engine network) and a Private Cloud:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/0*VhEBwytSfsak-WyS" /><figcaption><em>Figure 1 — </em><a href="https://cloud.google.com/vmware-engine/docs/networking/vmware-engine-network"><em>GCVE Architecture</em></a></figcaption></figure><p>A Standard VEN is a GCVE global VMware network that provides network connectivity through VPC peering. A VEN can be peered to:</p><ul><li>One or more private clouds.</li><li>Google Cloud Virtual Private Cloud networks.</li><li>On-premises networks.</li></ul><p>A Google Cloud VMware Engine private cloud is an isolated VMware stack that consists of the following VMware components:</p><ul><li><em>VMware ESXi</em>: hypervisor on dedicated nodes.</li><li><em>VMware vCenter</em>: centralized management of private cloud vSphere environments.</li><li><em>VMware vSAN</em>: hyper-converged, software-defined storage platform.</li><li><em>VMware NSX Data Center</em>: network virtualization and security software.</li><li><em>VMware HCX</em>: application migration and workload rebalancing across data centers and clouds.</li></ul><p>Additionally, when you create a private cloud, a Cloud DNS service is provided, offering built-in support for bidirectional DNS resolution.</p><h3>Setting Up The Environment</h3><p>Before starting the setup, we must count on the following resources:</p><ul><li>A GCP project attached to a billing account.</li><li>A custom VPC with at least one subnet.</li></ul><p>As mentioned above, we will use Cloud Build as a CI/CD platform. For this, we will need a service account, which will be used to deploy the infrastructure. Thus, as a first step, we will create the service account and grant it the following roles:</p><ul><li><em>Logs Writer</em>: roles/logging.logWriter</li><li><em>Service Account Token Creator</em>: roles/iam.serviceAccountTokenCreator</li><li><em>Service Account User</em>: roles/iam.serviceAccountUser</li><li><em>VMware Engine Service Admin</em>: roles/vmwareengine.vmwareengineAdmin</li><li><em>Cloud Build Editor:</em> roles/cloudbuild.builds.editor</li></ul><p>For the Service Account creation and role granting, we will use the gcloud CLI. Note that to assign Service Account roles, the role-binding command accepts one role per execution:</p><pre>gcloud iam service-accounts create NAME [ — description=DESCRIPTION] [ — display-name=DISPLAY_NAME]<br><br>gcloud projects add-iam-policy-binding PROJECT_ID \<br> - member=serviceAccount:SA-EMAIL \<br> - role=roles/ROLE NAME</pre><p>In our working project, we need to enable the following service APIs:</p><ul><li>VMware Engine API — vmwareengine.googleapis.com</li><li>Cloud Build API — cloudbuild.googleapis.com</li></ul><p>To accomplish this, run the following command for each of the previous APIs:</p><pre>gcloud enable service &lt;SERVICE API&gt;</pre><blockquote><strong>NOTE: </strong>To keep the exercise simple, we will deploy the entire infrastructure in a single project. In a production environment, we should use a shared VPC, which is composed of two projects: a host project, where networking resources are configured and deployed, and a service project, where the workloads are deployed. This allows us to have a proper separation of duties, as the networking management is centralized in the host project, and in the service project, we only need to focus on managing the workloads.</blockquote><p>Before proceeding further, we have to discuss the most sensitive and critical variable for our case study: the time variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/0*ZYBDUkKBTBDYsG5A" /></figure><p>Why time? According to the official <a href="https://cloud.google.com/vmware-engine/docs/private-clouds/howto-create-private-cloud#createstandardprivatecloud">documentation</a>, GCVE is a service that can remain active, between 30 minutes to 2 hours.<br>In some test cases, a private cloud with a single cluster could be active after more than four hours of deployment. As a result, we can face several problems, such as the service account token lifetime, the Cloud Build execution timeout, and the creation and deletion timeout of the Terraform resources. Most of these values, by default, do not exceed a one-hour timeout. Thus, we must reconfigure these timeouts.<br>We will focus on the reconfiguration of these values to deploy the infrastructure, avoiding re-deployments because the deployment time can exceed the resource’s timeout.</p><p>First, we will extend the lifetime of the Service Account token. To accomplish this, we must first set the <a href="https://cloud.google.com/docs/authentication/token-types#at-lifetime">iam.allowServiceAccountAccountCredentialLifetimeExtension</a> constraint. As shown in Figure 2, we will set this constraint at the project level. Thus, we will limit the scope of the constraint because if we apply it at the organizational level, we would be affecting any service account within the organization:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/0*8ZnIpjXs_WyrRrYh" /><figcaption><em>Figure 2 — Organization Policy</em></figcaption></figure><p>Then, in the “<em>Rules”</em> section, we have to allow the policy and configure the service account that we want to update. (see Figure 2.1)<em>:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*-LmrkAY2jqeFbTux" /><figcaption><em>Figure 2.1 — Organization Policy</em></figcaption></figure><p>To confirm that the constraint was implemented correctly, we will <a href="https://cloud.google.com/docs/authentication/use-service-account-impersonation">impersonate the service account</a> and extend the token lifetime:</p><pre># SA Impersonation<br>export GOOGLE_OAUTH_ACCESS_TOKEN=$(gcloud --impersonate-service-account=sa-gcve-poc@prj-gcve-poc.iam.gserviceaccount.com auth print-access-token --lifetime=21600)<br><br># Check SA token expiration lifetime<br>curl -s &quot;https://www.googleapis.com/oauth2/v1/tokeninfo?access_token=${GOOGLE_OAUTH_ACCESS_TOKEN}&quot;</pre><p>The lifetime parameter is expressed in seconds. If everything runs as expected, the output will be as follows:</p><pre>{<br>  …<br>  “expires_in” : 21600,<br>  “email: “sa-gcve-poc@prj-gcve-poc.iam.gserviceaccount.com”,<br>  …<br>}</pre><p>Now, we have to create a Cloud Build pipeline to deploy the infrastructure. We will create a simple pipeline to execute the Terraform code:</p><pre>steps:<br>- id: &#39;tf init&#39;<br>  name: &#39;hashicorp/terraform:1.3.0&#39;<br>  entrypoint: &#39;sh&#39;<br>  args: <br>  - &#39;-c&#39;<br>  - | <br>      cd ${_TF_BASE_DIR}<br>      terraform init<br><br>- id: &#39;tf plan&#39;<br>  name: &#39;hashicorp/terraform:1.3.0&#39;<br>  entrypoint: &#39;sh&#39;<br>  args: <br>  - &#39;-c&#39;<br>  - | <br>      cd ${_TF_BASE_DIR}<br>      terraform plan -out=/workspace/gcve-poc.tfplan<br><br>- id: &#39;tf apply&#39;<br>  name: &#39;hashicorp/terraform:1.3.0&#39;<br>  entrypoint: &#39;sh&#39;<br>  args: <br>  - &#39;-c&#39;<br>  - | <br>      cd ${_TF_BASE_DIR}<br>      terraform apply /workspace/gcve-poc.tfplan<br><br>timeout: 21600s<br>options:<br>  logging: CLOUD_LOGGING_ONLY</pre><p>As we can see in the example above, the timeout variable has been set to six hours.<br>To execute the pipeline, we have to create a <a href="https://cloud.google.com/build/docs/automating-builds/create-manage-triggers">Cloud Build trigger</a>. We can use the inline editor or create a cloudbuild.yaml file in our repository to create the pipeline shown in the example above.</p><p>In the “<em>Advanced</em>” section, we will add the pipeline variables and select the service account that will execute it (see Figure 3):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/0*jRXIlQXLeSxKrLl0" /><figcaption><em>Figure 3 — Cloud Build Trigger</em></figcaption></figure><p>Now, we’ll dive into the Terraform code and how to set the proper timeout values.</p><p>First, we need to configure the service account impersonation in the providers.tf<em> </em>file. Here, we have to configure the lifetime of the token. The following configuration will set it to six hours:</p><pre>terraform {<br>  required_providers {<br>    google = {<br>      source  = &quot;hashicorp/google&quot;<br>      version = &quot;5.35.0&quot;<br>    }<br>  }<br>}<br><br>locals {<br>  terraform_service_account = &quot;${var.project_sa_name}@${var.project_id}.iam.gserviceaccount.com&quot;<br>}<br><br>data &quot;google_service_account_access_token&quot; &quot;default&quot; {<br>  provider               = google.impersonation<br>  target_service_account = local.terraform_service_account<br>  scopes                 = [&quot;userinfo-email&quot;, &quot;cloud-platform&quot;]<br>  lifetime               = &quot;21600s&quot;<br>}<br><br>provider &quot;google&quot; {<br>  access_token = data.google_service_account_access_token.default.access_token<br>}<br><br>provider &quot;google&quot; {<br>  alias = &quot;impersonation&quot;<br>  scopes = [<br>    &quot;https://www.googleapis.com/auth/cloud-platform&quot;,<br>    &quot;https://www.googleapis.com/auth/userinfo.email&quot;,<br>  ]<br>}</pre><blockquote><strong>NOTE</strong>: For more information about service account impersonation, refer to: <a href="https://medium.com/@oredata-engineering/service-account-impersonation-in-google-cloud-77ba3f31b931">Service Account Impersonation in Google Cloud | by Oredata Engineering | Medium</a>.</blockquote><p>Based on the GCVE architecture, we will create a VEN. To do so, we will use a <a href="https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/vmwareengine_network">google_vmwareengine_network</a> Terraform resource:</p><pre>resource &quot;google_vmwareengine_network&quot; &quot;vmware_engine_network&quot; {<br>  project  = var.project_id<br>  name     = &quot;gcve-poc-ven&quot;<br>  location = &quot;global&quot;<br>  type     = &quot;STANDARD&quot;<br>}</pre><p>Keep in mind that the network type can be STANDARD or LEGACY, but only projects created <a href="https://cloud.google.com/vmware-engine/docs/networking/vmware-engine-network">before November 2023</a> can use Legacy VMware Engine Networks.</p><p>A network peering connects two VPC (Virtual Private Cloud) networks so the resources in each network can communicate with each other. When we create a network peering between two VPCs, we must create one peering resource in each VPC. In this case, we only need to create a network peering from GCVE. This process automatically creates both peerings, from VEN to VPC, and vice versa:</p><pre>resource &quot;google_vmwareengine_network_peering&quot; &quot;vmw-engine-network-peering&quot; {<br>  name                  = &quot;gcve-peer-ven-vpc&quot;<br>  project               = var.project_id<br>  vmware_engine_network = google_vmwareengine_network.vmware_engine_network.id<br>  peer_network          = data.google_compute_network.custom_vpc.id<br>  peer_network_type     = &quot;STANDARD&quot;<br>  export_custom_routes  = true<br>  import_custom_routes  = true<br>}</pre><p>There are three types of GCVE private clouds, <em>STANDARD</em>, <em>TIME-LIMITED, </em>and<em> STRETCHED</em>.<br>A <em>TIME-LIMITED</em> private cloud is a single cluster node cloud. This kind of cloud is a temporary resource that is automatically removed after 60 days. It is recommended for non-production usages, such as pilots and proof-of-concept evaluations. On the other hand, a <em>STANDARD</em> private cloud allows the cluster to be expanded to three nodes. Finally, a <em>STRETCHED</em> private cloud provides high availability of computing and storage, spanning across two zones:</p><pre>resource &quot;google_vmwareengine_private_cloud&quot; &quot;vmw_private_cloud&quot; {<br>  location = var.default_zone<br>  name     = &quot;gcve-priv-cloud&quot;<br>  type     = &quot;TIME_LIMITED&quot;<br><br>  network_config {<br>    management_cidr       = &quot;10.20.0.0/24&quot;<br>    vmware_engine_network = google_vmwareengine_network.vmware_engine_network.id<br>  }<br><br>  project = var.project_id<br><br>  management_cluster {<br>    cluster_id = &quot;gcve-vmw-poc-cluster&quot;<br>    node_type_configs {<br>      node_type_id      = &quot;standard-72&quot;<br>      node_count        = 1<br>      custom_core_count = 32<br>    }<br>  }<br><br>  timeouts {<br>    create = &quot;6h&quot;<br>    delete = &quot;6h&quot;<br>  }<br>}</pre><blockquote><strong>NOTE</strong>: You can find the complete code <a href="https://github.com/leonardorocca/terraform-examples/tree/main/gcve-pivate-cloud">here</a>.</blockquote><p>Once the private cloud is deployed, we can access the vCenter console through the URLs provided in the resource details. The credentials to access it are included alongside the URL (see Figure 4):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*--l5JIEUC9JhK_SK" /><figcaption><em>Figure 4 — GCVE Cluster Details</em></figcaption></figure><p>Since the private cloud is a private resource, it must be accessed through a bastion host or a <a href="https://cloud.google.com/network-connectivity/docs/interconnect/concepts/overview">Cloud Interconnect</a>. A bastion host allows us to have an entry point to access our private network. Once we gain access to the bastion host, we will be able to reach the instances deployed on our private networks. Refer to <a href="https://cloud.google.com/compute/docs/connect/ssh-using-bastion-host">Connect to Linux VMs using a bastion host</a> to learn more about this connection method.</p><p>On the other hand, Cloud Interconnect provides low-latency, high-availability connections. Between our cloud VPCs and other networks, such as on-premise or other cloud providers, it provides internal IP address communication.</p><p>Once we have our resources configured and deployed, we can access the vCenter console (see Figure 5):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wCvnz_2znmZNOJDg" /></figure><h3>Summary</h3><p>As we have seen, deploying a GCVE Private Cloud is not overly complex, but given that it’s a lengthy process, it can make deploying the solution difficult. This is because both the deployment time and the deletion time for the resources are equally long. Setting timeouts is crucial to avoid wasting time on trial-and-error deployments. Using Cloud Build as a deployment platform allows us to have uninterrupted deployments. This would not be the case if we were to use a dedicated terminal.</p><h3>References</h3><ul><li><a href="https://cloud.google.com/vmware-engine/docs/networking/vmware-engine-network">About VMware Engine networks</a></li><li><a href="https://docs.vmware.com/en/VMware-Cloud-Foundation/5.1/vcf-getting-started/GUID-07411CF9-AD3F-43EA-A348-A89940C2D4A2.html">VMware Cloud Foundation Overview</a></li><li><a href="https://github.com/GoogleCloudPlatform/gcve-iac-foundations">Google Cloud VMware Engine IaC Foundations — GitHub</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a14fb5649044" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/automating-google-cloud-vmware-engine-deployments-a14fb5649044">Automating Google Cloud VMware Engine Deployments</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Simplifying Log Management]]></title>
            <link>https://medium.com/globant/simplifying-log-management-d2bcbee442b8?source=rss-210da5ce9e00------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2bcbee442b8</guid>
            <category><![CDATA[logging]]></category>
            <category><![CDATA[gcp]]></category>
            <category><![CDATA[bigquery]]></category>
            <category><![CDATA[looker-studio]]></category>
            <category><![CDATA[cloudops]]></category>
            <dc:creator><![CDATA[Leo Rocca]]></dc:creator>
            <pubDate>Wed, 20 Dec 2023 13:41:32 GMT</pubDate>
            <atom:updated>2023-12-20T13:41:32.545Z</atom:updated>
            <content:encoded><![CDATA[<h4>How to Export and Analyze Logs in Looker Studio for Better Insights</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZzVXqGhRWaJg9H-R" /><figcaption>Photo by author</figcaption></figure><p>This article will explore how to route logs to <a href="https://cloud.google.com/bigquery/docs/introduction">BigQuery</a> and analyze them in <a href="https://cloud.google.com/looker-studio?hl=en">Looker Studio</a>. With this approach, we can simplify your log management and gain better insights.</p><p>BigQuery is <a href="https://cloud.google.com/?hl=en">Google Cloud Platform</a>’s (GCP) data warehouse solution. BigQuery’s serverless architecture lets you use SQL queries with zero infrastructure management. BigQuery’s scalable, distributed analysis engine enables you to query terabytes in seconds and petabytes in minutes.</p><p>Looker Studio, formerly Google Data Studio, is an online tool for visualizing and analyzing data through different sources. It can connect to several databases, such as BigQuery or Cloud SQL. <br>With Looker Studio, we can create fully customized and easily shared dashboards.</p><h3>Monitoring vs. Observability</h3><p>There is a lot of talking about monitoring and observability. Sometimes, people mix the concepts used as being the same. But what is the difference between them? <a href="https://dora.dev/devops-capabilities/technical/monitoring-and-observability/">DevOps Research and Assessment</a> (DORA) defines these two concepts:</p><ul><li><em>Monitoring</em> is tooling or a technical solution that allows teams to watch and understand the state of their systems. Monitoring is based on gathering predefined sets of metrics or logs.</li><li><em>Observability</em> is tooling or a technical solution that allows teams to actively debug their system. Observability is based on exploring properties and patterns not defined in advance.</li></ul><h3>Solution Architecture</h3><p>We will focus on log monitoring and how to get better insights. The architecture has two host projects, one per environment and three service projects to achieve this. Each service project has a Compute Instance deployed with an <a href="https://cloud.google.com/stackdriver/docs/solutions/agents/ops-agent">Ops Agent</a> installed. It collects telemetry data from Compute Engine instances. It’s capable of collecting logs, metrics, and traces. Among the logging features, we can find standard system logs collection, logs over TCP protocol, and Forward protocol. The monitoring features include system metrics, such as CPU, disk, memory, and network. It also includes third-party applications, Prometheus, OpenTelemetry Protocol, and NVIDIA metrics.</p><p>We can install Ops Agent manually, one VM at a time. We can also do it automatically during VM creation or using automation tools like Terraform, Ansible, Chef, or Puppet.</p><p>The non-production logging project gathers the logs sent by the non-production service projects. The production logging project prj-prod only gathers the production logs. This gives us a correct separation of duties to access the collected data only to the right team members. The solution follows the resource hierarchy described in Figure 1, which has one folder per environment and another folder for all the logging and monitoring resources.</p><p><strong><em>Note</em></strong><em>:</em> To keep the exercise simple, we will create one folder for networking resources and another one for logging and monitoring resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LDCokAjkwLCBsH7O" /><figcaption><em>Figure 1 — Resource hierarchy</em></figcaption></figure><h3>Log Routing</h3><p>In GCP, the logs can be routed from billing, organization, folders, and projects to different destinations. By default, each project has <a href="https://cloud.google.com/logging/docs/routing/overview#buckets">two sinks</a>:</p><p>The _Requiredlog bucket stores:</p><ul><li>Admin activity audit logs.</li><li>System event audit logs.</li><li>Access transparency logs.</li></ul><p>The _Defaultlog bucket stores:</p><ul><li>Data access audit logs.</li><li>Denied policies audit logs.</li></ul><p>To learn more about GCP logs, you can check out the <a href="https://cloud.google.com/logging/docs/audit#types">logging documentation</a>.</p><p>You can also create a custom Log Sink to send logs to different destinations (see Figure 2). A log sink is used to define which logs will route, defining inclusion or exclusion filters. According to our architecture, we will create three sinks at the folder level. Each sink will route logs to the logging projects prj-log-nprod and prj-log-prod. This solution allows routing all logs and storing them in two different BigQuery datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Jfq41cWNz0DOW6KX" /><figcaption><em>Figure 2 — How Cloud Logging routes and stores log entries</em></figcaption></figure><p>Cloud Logging routes logs to the default buckets. Creating a custom log sink allows us to choose other destinations, such as Cloud Storage, BigQuery, or Pub/Sub. We will use BigQuery as a destination to store logs. Once the logs have been stored in BigQuery, we can connect Looker Studio to analyze the data.</p><h3>Network Architecture</h3><p>As shown in Figure 3, the network architecture has three <a href="https://cloud.google.com/vpc/docs/shared-vpc">Shared VPCs</a>, one per environment. The Shared VPCs have a <em>host</em> project and one or more attached <em>service</em> projects. This solution allows us to have a good separation of duties. Deploy the network resources (VPCs and subnets) in the host projects first. Then, deploy the workload (<a href="https://cloud.google.com/compute/docs/instances">Compute Engine VM instances</a>) on the service projects.</p><p>As mentioned in the previous section, the log sinks route the logs to the logging projects. The <em>monitoring</em> projects have the service projects attached to monitor them and collect metrics.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Crvyn0JJewO1NLCq" /><figcaption><em>Figure 3 — Network architecture</em></figcaption></figure><h3>Let’s Get Started</h3><p>We need to create two BigQuery datasets to store logs from the non-production and production environments. Create the datasets for each project:</p><p>Non-production dataset:</p><pre>gcloud config set prj-log-nprod        # Set into non-production project<br>bq mk --location=US -d ds_nonprod_logs # Create the non production dataset</pre><p>Production dataset:</p><pre>gcloud config set prj-log-prod       # Set into non-production project<br>bq mk --location=US -d ds_prod_logs  # Create the production dataset</pre><p><strong><em>Note</em></strong><em>:</em> We will keep the default values to keep the exercise simple.</p><p>Now, we will create the <em>Logs Routers</em>. We can do it from <em>Cloud Logging -&gt; Logs Explorer</em> (See Figure 4). Log Explorer helps us to write a log filter and analyze the results before creating the sink:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bi25c-vE1A12c5Xm" /><figcaption><em>Figure 4 — Cloud Logging — Logs Explorer</em></figcaption></figure><p>Furthermore, we can create a sink from <em>Cloud Logging -&gt; Logs Router</em>. Here, we set up the <em>sink name, destination</em>, and the <em>inclusion</em> and <em>exclusion</em> filters.</p><h4>Step-by-Step Log Sink Setup</h4><p>To simplify the exercise, we will create a sink only for the development environment. First, go to <em>Cloud Logging -&gt; Logs Router</em> and select the <em>DEV</em> folder in the project selector. Click the “<em>Create Sink</em>” button and follow the step-by-step wizard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/578/0*UWcpP01_wgegxCQx" /><figcaption><em>Figure 5 — Sink configuration summary</em></figcaption></figure><p>After we have set up the sink, we will see the configuration summary shown in Figure 5. When we choose BigQuery as the destination, we select the destination dataset. Because we will create a sink at the folder level, we have to select <em>Other Resource</em> and set up the dataset link. The dataset link has the following pattern:</p><p>bigquery.googleapis.com/projects/[PROJECT_ID]/dataset/[DATASET_ID]</p><p>Now, we have to decide if we will route the logs generated by the current resource or by the child resources. To achieve this, select <em>Include child resources</em>. Repeat these steps in the <em>QA</em> and <em>PROD</em> folders. The production environment logs must be routed to the production logging project prj-log-prod.</p><p>Once the routing of the logs starts, we will see a new table (See Figure 6) in the dataset created in the beginning. The log ingestion will take a few minutes to start. If you don’t see any data, wait a few minutes and refresh the view:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*w-jvSTnhFKtOHXx2" /><figcaption><em>Figure 6 — Logs ingested in BigQuery</em></figcaption></figure><h4>Exploring The Data</h4><p>Now, we can explore and analyze the stored data. To do so, we will use Looker Studio without creating new tables or views in BigQuery. Data Studio can connect to different data sources to explore the data. We will keep all raw data in BigQuery and explore it in Looker Studio.</p><p>To open Looker Studio, click <em>Explore Data</em> and select <em>Explore with Looker Studio</em>. We will see a default dashboard with some data taken from BigQuery. On the right panel, we can see all the columns of the BigQuery table used as data sources. To add or update the data sources, go to <em>Resource -&gt; Manage added data sources</em> menu (See Figure 7):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/506/0*czoHdMSM83ABcAaT" /><figcaption><em>Figure 7 — Manage data sources</em></figcaption></figure><p>As shown in Figure 8, we can create a custom query by selecting the source project, dataset, and table:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/0*RLc1QN4HPYZitUVo" /><figcaption><em>Figure 8 — Looker Studio exploring data</em></figcaption></figure><p>At this point, we can add different types of charts, write new queries, or even filter data by date. That will make the dashboard update automatically (see Figure 9):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s9lOHCS0ZdWkivjZ" /><figcaption><em>Figure 9 — Non-production environment example dashboard.</em></figcaption></figure><h3>Summary</h3><p>The solution presented in this article allows us to achieve better log management by filtering logs, not only by their content but also by the environment. This allows us to have a better separation of duties.</p><p>By combining BigQuery and Looker Studio capabilities, we have better analysis capabilities for our environments and projects.</p><p>Looker Studio also helps us share the dashboards with users who do not necessarily have a GCP account. This is a differentiator with Cloud Monitoring dashboards, which can also share dashboards, but with users who already have access to GCP and the monitoring projects.</p><h3>References</h3><ul><li><a href="https://dora.dev/">DevOps Research and Assessment</a></li><li><a href="https://cloud.google.com/logging/docs">GCP — Cloud Logging documentation</a></li><li><a href="https://sre.google/sre-book/table-of-contents/">O’Reilly — Site Reliability Engineering</a></li><li><a href="https://sre.google/sre-book/monitoring-distributed-systems/">“Four Golden Signals” for monitoring systems</a></li><li><a href="https://sre.google/books/">Books For Site Reliability Engineering</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2bcbee442b8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/globant/simplifying-log-management-d2bcbee442b8">Simplifying Log Management</a> was originally published in <a href="https://medium.com/globant">Globant</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>