Skip to main content

Setting Up a Stackdriver Workspace for a VM

Hands-On Lab

 

Photo of Broadus Palmer

Broadus Palmer

Google Cloud Training Architect

Length

00:30:00

Difficulty

Beginner

Monitoring your infrastructure is incredibly important. When deploying instances with applications, you want to make sure you can maximize every opportunity to analyze, troubleshoot, and reduce costs. This is where Stackdriver comes into play. In this hands-on lab, we will learn how to monitor a VM with Stackdriver.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Setting Up a Stackdriver Workspace for a VM

Introduction

Monitoring your infrastructure is incredibly important. When deploying instances with applications, you want to make sure you can maximize every opportunity to analyze, troubleshoot, and reduce costs. This is where Stackdriver comes into play. In this hands-on lab, we will learn how to monitor a VM with Stackdriver.

How to Log in to Google Lab Accounts

On the lab page, right-click Open GCP Console and select the option to open it in a new private browser window (this option will read differently depending on your browser — e.g., in Chrome, it says "Open Link in Incognito Window"). Then, sign in to Google Cloud Platform using the credentials provided on the lab page.

On the Welcome to your new account screen, review the text, and click Accept. In the "Welcome L.A.!" pop-up once you're signed in, check to agree to the terms of service, choose your country of residence, and click Agree and Continue.

Create an HTTP Firewall Rule

  1. From the main console navigation, navigate to VPC network > Firewall rules.
  2. Click Create Firewall Rule.
  3. Set the following values:
    • Name: http-allow
    • Direction of traffic: Ingress
    • Action on match: Allow
    • Target tags: http-server
    • Source IP ranges: 0.0.0.0/0
    • Protocols and ports: Check tcp and enter 80
  4. Click Create.

Create a Compute Engine Instance

  1. Navigate to Compute Engine > VM instances.

  2. Click Create.

  3. Set the following values:

    • Name: apache
    • Region: us-central1 (Iowa)
    • Zone: us-central1-a
    • Machine type: f1-micro
  4. Click to expand Management, security, disks, networking, sole tenancy.

  5. Click the Networking tab.

  6. For Network tags, enter http-server.

  7. Click the Management tab.

  8. In the Startup script box, paste:

    sudo apt-get update
    sudo apt-get install apache2 -y
  9. Click Create.

  10. Once it's created, click the listed external IP and open it in a new browser tab to ensure Apache was installed. We should see an Apache2 Debian Default Page display.

Set Up a Stackdriver Workspace

  1. Back in the GCP console, navigate to Stackdriver > Monitoring. It may take a few minutes for the project to build in Stackdriver.

Verify Metrics from the Instance

  1. Hover over Resources, and click Instances.
  2. Click our listed apache instance. It will take a few minutes for metrics to populate on the dashboard.

Conclusion

Congratulations on successfully completing this hands-on lab!