• Login
Wednesday, June 18, 2025
The Cloud Guru
  • Home
  • AWS
  • Data Center
  • GCP
  • Technology
  • Tutorials
  • Blog
    • Blog
    • Reviews
No Result
View All Result
Wednesday, June 18, 2025
  • Home
  • AWS
  • Data Center
  • GCP
  • Technology
  • Tutorials
  • Blog
    • Blog
    • Reviews
No Result
View All Result
No Result
View All Result

Setup Cloud Monitoring on GCP

Team TCG by Team TCG
October 1, 2023
in GCP, Tutorials
0 0
0
Home GCP
0
SHARES
7
VIEWS
Share on FacebookShare on Twitter

Overview

Cloud Monitoring provides visibility into the performance, uptime, and overall health of cloud-powered applications. Cloud Monitoring collects metrics, events, and metadata from Google Cloud, Amazon Web Services, hosted uptime probes, application instrumentation, and a variety of common application components including Cassandra, Nginx, Apache Web Server, Elasticsearch, and many others. Cloud Monitoring ingests that data and generates insights via dashboards, charts, and alerts. Cloud Monitoring alerting helps you collaborate by integrating with Slack, PagerDuty, HipChat, Campfire, and more.

This lab shows you how to monitor a Compute Engine virtual machine (VM) instance with Cloud Monitoring. You’ll also install monitoring and logging agents for your VM which collects more information from your instance, which could include metrics and logs from 3rd party apps.

Set your region and zone

Certain Compute Engine resources live in regions and zones. A region is a specific geographical location where you can run your resources. Each region has one or more zones.Learn more about regions and zones and see a complete list in Regions & Zones documentation.

Run the following gcloud commands in Cloud Console to set the default region and zone for your lab:

gcloud config set compute/zone “ZONE” export ZONE=$(gcloud config get compute/zone) gcloud config set compute/region “REGION” export REGION=$(gcloud config get compute/region)

Task 1. Create a Compute Engine instance

  1. In the Cloud Console dashboard, go to Navigation menu > Compute Engine > VM instances, then click Create instance.
  2. Fill in the fields as follows, leaving all other fields at the default value:FieldValueNamelamp-1-vmRegionREGIONZoneZONESeriesE2Machine typee2-mediumBoot diskDebian GNU/Linux 11 (bullseye)FirewallCheck Allow HTTP traffic
  3. Click Create.Wait a couple of minutes, you’ll see a green check when the instance has launched.

Task 2. Add Apache2 HTTP Server to your instance

  1. In the Console, click SSH in line with lamp-1-vm to open a terminal to your instance.
  2. Run the following commands in the SSH window to set up Apache2 HTTP Server:

sudo apt-get update

sudo apt-get install apache2 php7.0

  1. When asked if you want to continue, enter Y.

Note: If you cannot install php7.0, use php5.sudo service apache2 restart

  1. Return to the Cloud Console, on the VM instances page. Click the External IP for lamp-1-vm instance to see the Apache2 default page for this instance.

Note: If you are unable to find External IP column then click on Column Display Options icon on the right side of the corner, select External IP checkbox and click OK.

Create a Monitoring Metrics Scope

Set up a Monitoring Metrics Scope that’s tied to your Google Cloud Project. The following steps create a new account that has a free trial of Monitoring.

  • In the Cloud Console, click Navigation menu Navigation menu icon > Monitoring.

When the Monitoring Overview page opens, your metrics scope project is ready.

Install the Monitoring and Logging agents

Agents collect data and then send or stream info to Cloud Monitoring in the Cloud Console.

The Cloud Monitoring agent is a collected-based daemon that gathers system and application metrics from virtual machine instances and sends them to Monitoring. By default, the Monitoring agent collects disk, CPU, network, and process metrics. Configuring the Monitoring agent allows third-party applications to get the full list of agent metrics. On the Google Cloud, Operations website, see Cloud Monitoring Documentation for more information.

In this section, you install the Cloud Logging agent to stream logs from your VM instances to Cloud Logging. Later in this lab, you see what logs are generated when you stop and start your VM.Note: It is best practice to run the Cloud Logging agent on all your VM instances.

  1. Run the Monitoring agent install script command in the SSH terminal of your VM instance to install the Cloud Monitoring agent:

curl -sSO https://dl.google.com/cloudagents/add-google-cloud-ops-agent-repo.sh

sudo bash add-google-cloud-ops-agent-repo.sh –also-install

  1. If asked if you want to continue, press Y.
  2. Run the Logging agent install script command in the SSH terminal of your VM instance to install the Cloud Logging agent:

sudo systemctl status google-cloud-ops-agent”*”

Press q to exit the status.sudo apt-get update

Task 3. Create an uptime check

Uptime checks verify that a resource is always accessible. For practice, create an uptime check to verify your VM is up.

  1. In the Cloud Console, in the left menu, click Uptime checks, and then click Create Uptime Check.
  2. For Protocol, select HTTP.
  3. For Resource Type, select Instance.
  4. For Instance, select lamp-1-vm.
  5. For Check Frequency, select 1 minute.
  6. Click Continue.
  7. In Response Validation, accept the defaults and then click Continue.
  8. In Alert & Notification, accept the defaults, and then click Continue.
  9. For Title, type Lamp Uptime Check.
  10. Click Test to verify that your uptime check can connect to the resource.When you see a green check mark everything can connect.
  11. Click Create.The uptime check you configured takes a while for it to become active. Continue with the lab, you’ll check for results later. While you wait, create an alerting policy for a different resource.

Task 4. Create an alerting policy

Use Cloud Monitoring to create one or more alerting policies.

  1. In the left menu, click Alerting, and then click +Create Policy.
  2. Click on Select a metric dropdown. Disable the Show only active resources & metrics.
  3. Type Network traffic in filter by resource and metric name and click on VM instance > Interface. Select Network traffic (agent.googleapis.com/interface/traffic) and click Apply. Leave all other fields at the default value.
  4. Click Next.
  5. Set the Threshold position to Above threshold, Threshold value to 500 and Advanced Options > Retest window to 1 min. Click Next.
  6. Click on the drop down arrow next to Notification Channels, then click on Manage Notification Channels.

A Notification channels page will open in a new tab.

  1. Scroll down the page and click on ADD NEW for Email.
  2. In the Create Email Channel dialog box, enter your personal email address in the Email Address field and a Display name.
  3. Click on Save.
  4. Go back to the previous Create alerting policy tab.
  5. Click on Notification Channels again, then click on the Refresh icon to get the display name you mentioned in the previous step.
  6. Click on Notification Channels again if necessary, select your Display name and click OK.
  7. Add a message in documentation, which will be included in the emailed alert.
  8. Mention the Alert name as Inbound Traffic Alert.
  9. Click Next.
  10. Review the alert and click Create Policy.

You’ve created an alert! While you wait for the system to trigger an alert, create a dashboard and chart, and then check out Cloud Logging.

Task 5. Create a dashboard and chart

You can display the metrics collected by Cloud Monitoring in your own charts and dashboards. In this section you create the charts for the lab metrics and a custom dashboard.

  1. In the left menu select Dashboards, and then +Create Dashboard.
  2. Name the dashboard Cloud Monitoring LAMP Start Dashboard.

Add the first chart

  1. Click the Line option in the Chart library.
  2. Name the chart title CPU Load.
  3. Click on Resource & Metric dropdown. Disable the Show only active resources & metrics.
  4. Type CPU load (1m) in filter by resource and metric name and click on VM instance > Cpu. Select CPU load (1m) and click Apply. Leave all other fields at the default value. Refresh the tab to view the graph.

Add the second chart

  1. Click + Add Chart and select Line option in the Chart library.
  2. Name this chart Received Packets.
  3. Click on Resource & Metric dropdown. Disable the Show only active resources & metrics.
  4. Type Received packets in filter by resource and metric name and click on VM instance > Instance. Select Received packets and click Apply. Refresh the tab to view the graph.
  5. Leave the other fields at their default values. You see the chart data.

Task 6. View your logs

Cloud Monitoring and Cloud Logging are closely integrated. Check out the logs for your lab.

  1. Select Navigation menu > Logging > Logs Explorer.
  2. Select the logs you want to see, in this case, you select the logs for the lamp-1-vm instance you created at the start of this lab:
    • Click on Resource.
    • Select VM Instance > lamp-1-vm in the Resource drop-down menu.
    • Click Apply.
    • Leave the other fields with their default values.
    • Click the Stream logs.

You see the logs for your VM instance.

Check out what happens when you start and stop the VM instance.

To best see how Cloud Monitoring and Cloud Logging reflect VM instance changes, make changes to your instance in one browser window and then see what happens in the Cloud Monitoring, and then Cloud Logging windows.

  1. Open the Compute Engine window in a new browser window. Select Navigation menu > Compute Engine, right-click VM instances > Open link in new window.
  2. Move the Logs Viewer browser window next to the Compute Engine window. This makes it easier to view how changes to the VM are reflected in the logs
  3. In the Compute Engine window, select the lamp-1-vm instance, click the three vertical dots at the right of the screen and then click Stop, and then confirm to stop the instance.It takes a few minutes for the instance to stop.
  4. Watch in the Logs View tab for when the VM is stopped.
  5. In the VM instance details window, click the three vertical dots at the right of the screen and then click Start/resume, and then confirm. It will take a few minutes for the instance to re-start. Watch the log messages to monitor the start up.

Task 7. Check the uptime check results and triggered alerts

  1. In the Cloud Logging window, select Navigation menu > Monitoring > Uptime checks. This view provides a list of all active uptime checks, and the status of each in different locations.You will see Lamp Uptime Check listed. Since you have just restarted your instance, the regions are in a failed status. It may take up to 5 minutes for the regions to become active. Reload your browser window as necessary until the regions are active.
  2. Click the name of the uptime check, Lamp Uptime Check.Since you have just restarted your instance, it may take some minutes for the regions to become active. Reload your browser window as necessary.

Check if alerts have been triggered

  1. In the left menu, click Alerting.
  2. You see incidents and events listed in the Alerting window.
  3. Check your email account. You should see Cloud Monitoring Alerts.

Note: Remove the email notification from your alerting policy. The resources for the lab may be active for a while after you finish, and this may result in a few more email notifications getting sent out.

Congratulations! You have successfully set up and monitored a VM with Cloud Monitoring on GCP.

Tags: 2Min'sGCPHow tomonitoringTutorials
Previous Post

Setting Up Cost Control with Quota

Next Post

AWS DataSync vs. AWS Storage Gateway: Choosing the Right Data Transfer Service

Team TCG

Team TCG

Related Posts

Driving Success with Google Cloud: Real-World Hybrid and Multi-Cloud Case Studies

Hybrid and multi-cloud adoption has become the new norm for enterprises seeking to harness the power of cloud computing while...

by thecloudguru
November 28, 2023

Unleashing the Power of Google Cloud’s Hybrid and Multi-Cloud Solutions for Your Enterprise

In today's ever-evolving IT landscape, enterprises are seeking innovative solutions to harness the benefits of hybrid and multi-cloud environments. Google...

by thecloudguru
November 21, 2023

Mastering the Hybrid Cloud: Common Architecture Patterns and Implementation Strategies

The hybrid cloud has emerged as a dynamic solution for organizations seeking to balance flexibility, scalability, and control in their...

by thecloudguru
October 31, 2023
GCP

Setting Up Cost Control with Quota

In this lab you will complete the following tasks: Queried a public dataset and explore associated costs. Modified BigQuery API...

by Team TCG
December 21, 2024
GCP

Distributed Load Testing Using Kubernetes

Activate Cloud Shell Cloud Shell is a virtual machine that is loaded with development tools. It offers a persistent 5GB...

by Team TCG
October 1, 2023
GCP

Deploying Memcached on Kubernetes Engine

Overview In this lab, you'll learn how to deploy a cluster of distributed Memcached servers on Kubernetes Engine using Kubernetes, Helm, and Mcrouter. Memcached is one of...

by Team TCG
October 1, 2023
Next Post

AWS DataSync vs. AWS Storage Gateway: Choosing the Right Data Transfer Service

Leave a Reply Cancel reply

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

  • Trending
  • Comments
  • Latest

Comparing AWS Storage Services: S3 vs. EBS vs. EFS vs. FSx vs. S3 Glacier vs. Storage Gateway

September 30, 2023

AWS DataSync vs. AWS Storage Gateway: Choosing the Right Data Transfer Service

September 30, 2023

Comparing AWS Compute Services: EC2 vs. ECS vs. EKS vs. Fargate vs. Lambda

September 30, 2023

How Duolingo’s AWS-Powered Language Learning Platform?

October 30, 2023

AWS SnowMobile

0

Passwordless Login Using SSH Keygen in 5 Easy Steps

0

Create a new swap partition on RHEL system

0

Configuring NTP using chrony

0

Azure Case Study: How Spotify Uses Azure

March 16, 2025

Quick Tip: Troubleshooting Common Azure Errors

March 15, 2025

Azure Cognitive Services: Adding AI Capabilities to Your Applications

March 15, 2025

Azure IoT Hub: Connecting IoT Devices to the Cloud

March 15, 2025

Recommended

Azure Case Study: How Spotify Uses Azure

March 16, 2025

Quick Tip: Troubleshooting Common Azure Errors

March 15, 2025

Azure Cognitive Services: Adding AI Capabilities to Your Applications

March 15, 2025

Azure IoT Hub: Connecting IoT Devices to the Cloud

March 15, 2025

About Us

Let's Simplify the cloud for everyone. Whether you are a technologist or a management guru, you will find something very interesting. We promise.

Categories

  • 2 Minute Tutorials (7)
  • AI (3)
  • Ansible (1)
  • Architecture (3)
  • Artificial Intelligence (3)
  • AWS (168)
  • Azure (3)
  • books (2)
  • Consolidation (4)
  • Containers (1)
  • Data Analytics (1)
  • Data Center (11)
  • Design (1)
  • GCP (13)
  • HOW To's (17)
  • Innovation (1)
  • Kubernetes (8)
  • LifeStyle (2)
  • LINUX (6)
  • Microsoft (2)
  • news (3)
  • People (4)
  • Reviews (1)
  • RHEL (2)
  • Security (2)
  • Self-Improvement and Professional Development (1)
  • Serverless (2)
  • Social (2)
  • Switch (1)
  • Technology (133)
  • Terraform (3)
  • Tools (1)
  • Tutorials (13)
  • Uncategorized (8)
  • Video (1)
  • Videos (1)

Tags

2Min's (7) Agile (1) AI (5) Appication Modernization (1) Application modernization (1) Architecture (1) AWS (43) AZURE (4) BigQuery (1) books (2) Case Studies (17) CI/CD (1) Cloud Computing (185) Cloud Optimization (1) Comparo (17) Consolidation (1) Courses (1) Data Analytics (1) Data Center (8) Emerging (1) GCP (11) Generative AI (1) How to (14) Hybrid Cloud (5) Innovation (2) Kubernetes (4) LINUX (5) lunch&learn (133) memcache (1) Microsoft (1) monitoring (1) NEWS (2) NSX (1) Opinion (3) SDDC (2) security (1) Self help (2) Shorties (1) Stories (1) Team Building (1) Technology (3) Tutorials (20) vmware (3) vSAN (1) Weekend Long Read (1)
  • About
  • Advertise
  • Privacy & Policy

© 2023 The Cloud Guru - Let's Simplify !!

No Result
View All Result
  • Home
  • AWS
  • HOW To’s
  • Tutorials
  • GCP
  • 2 Minute Tutorials
  • Data Center
  • Artificial Intelligence
  • Azure
  • Videos
  • Innovation

© 2023 The Cloud Guru - Let's Simplify !!

Welcome Back!

Sign In with Facebook
Sign In with Google
Sign In with Linked In
OR

Login to your account below

Forgotten Password?

Create New Account!

Sign Up with Facebook
Sign Up with Google
Sign Up with Linked In
OR

Fill the forms bellow to register

All fields are required. Log In

Retrieve your password

Please enter your username or email address to reset your password.

Log In