Loading...
No results found.

Google Cloud Skills Boost

Apply your skills in Google Cloud console

04

Deploy and Monitor in Google Cloud for Azure Professionals

Get access to 700+ labs and courses

Monitoring a Compute Engine using Ops Agent (Azure)

Lab 1 hour universal_currency_alt 5 Credits show_chart Introductory
info This lab may incorporate AI tools to support your learning.
Get access to 700+ labs and courses

As a cloud administrator, you are in charge of monitoring your infrastructure. You would like to monitor an Apache Web Server, and visualize data on a dashboard.

Some of your concerns are:

  • How to install and configure a monitor agent instance for the Apache Web Server
  • How to generate traffic and view metrics on the predefined Apache dashboard
  • How to create an alerting policy

The monitoring workflow in Azure Monitor is as shown in the diagram:

In Azure, you install an Apache Web Server over your virtual machine (VM). Then you connect an Azure Monitor Agent on this server to collect data. Using Azure Monitor, configure Log Analytics to set up the logs and metrics that you want to visualize in a dashboard. Then name the dashboard to keep it readily available. Within Azure Monitor, you can configure the alerts to initiate a call to Azure Functions that automates the response to an alert. An Alert can also be generated whenever the definition of an Azure policy is not met.

Overview

In this lab you will create a compute engine to install and configure an Ops Agent. You will generate traffic and view metrics on the predefined Apache dashboard and also create an alerting policy.

Objectives

In this lab, you learn how to perform the following tasks:

  • Create a Compute Engine VM instance.
  • Install an Apache Web Server.
  • Install and configure the Ops Agent for the Apache Web Server.
  • Generate traffic and view metrics on the predefined Apache dashboard.
  • Create an alerting policy.

Create a Compute Engine VM instance

  1. In Google Cloud console, go to Compute and then select Compute Engine.

  2. To create a VM instance, click Create instance.

  3. Fill in the fields for your instance as follows:

  • In the Name field, enter quickstart-vm.
  • In the Machine type field, select e2-small.
  • Ensure the Boot disk is configured for Debian GNU/Linux.
  • In the Firewall field, select both Allow HTTP traffic and Allow HTTPS traffic.

Leave the rest of the fields at their default values.

  1. Click Create. When your VM is ready, it appears in the list of instances in the Instances tab.

Click Check my progress to verify the objective.

Create a Compute Engine VM instance

Install an Apache Web Server

To deploy an Apache Web Server on your Compute Engine VM instance, do the following:

  1. To open a terminal to your instance, in the Connect column, click SSH.

  2. To update the package lists on your instance, run the following command:

sudo apt-get update
  1. To install an Apache2 HTTP Server, run the following command:
sudo apt-get install apache2 php7.0 Note: Note: If the previous command fails, then use sudo apt-get install apache2 php. If asked to continue the installation, enter Y.
  1. Open your browser and connect to your Apache2 HTTP server by using the URL http://EXTERNAL_IP, where EXTERNAL_IP is the external IP address of your VM. You can find this address in the External IP column of your VM instance.

Click Check my progress to verify the objective.

Install an Apache Web Server

Install and configure the Ops Agent

To collect logs and metrics from your Apache Web Server, install the Ops Agent by using the terminal:

  1. To open a terminal to your VM instance, in the Connect column, click SSH.

  2. To install the Ops Agent, run the following command:

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

You see google-cloud-ops-agent installation succeeded.

  1. Copy the following command, then paste it into the terminal:
# Configures Ops Agent to collect telemetry from the app and restart Ops Agent. set -e # Create a back up of the existing file so existing configurations are not lost. sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak # Configure the Ops Agent. sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF metrics: receivers: apache: type: apache service: pipelines: apache: receivers: - apache logging: receivers: apache_access: type: apache_access apache_error: type: apache_error service: pipelines: apache: receivers: - apache_access - apache_error EOF sudo service google-cloud-ops-agent restart sleep 60

The previous command creates the configuration to collect and ingest logs and metrics from the Apache Web Server. For more information about ingesting logs from the Apache Web Server, see Configure the Ops Agent for Apache Web Server.

Click Check my progress to verify the objective.

Install the Ops Agent

Generate traffic and view metrics

Monitoring dashboards let you view and analyze metrics related to your services. In this quickstart, you generate metrics on your Apache Web Server and view metric data on the automatically created Apache GCE Overview dashboard.

To generate metrics on your Apache Web Server, do the following:

  1. In the Google Cloud console, go to Compute Engine.

  2. In the Connect column, click SSH to open a terminal to your VM instance.

  3. To generate traffic on your Apache Web Server, run the following command:

timeout 120 bash -c -- 'while true; do curl localhost; sleep $((RANDOM % 4)) ; done'

The previous command generates traffic by making a request to the Apache Web Server every four seconds.

To view the Apache GCE Overview dashboard, do the following:

  1. In the Google Cloud console, search for Monitoring in the top search bar and navigate to the Monitoring service.

  2. In the navigation pane, select Dashboards.

  3. In All Dashboards, select the Apache GCE Overview dashboard. The dashboard opens.

In the dashboard, there are several charts that contain information about your Apache and Compute Engine integration:

Create an alerting policy

  1. To set up an email notification channel, do the following:
  • In the Google Cloud console > Monitoring select Alerting and then click Edit notification channels.
  • In the Email section, click Add new and enter your desired Email Address.
  • Name the Email Channel: An email address you have access to

To create an alerting policy that monitors a metric and sends an email notification when the traffic rate on your Apache Web Server exceeds 4 KiB/s, do the following:

  1. In the Google Cloud console > Monitoring select Alerting and then click Create policy.

  2. Select the time series to be monitored:

  • Click Select a metric and enter VM instance into the filter bar.
  • In the Active metric categories list, select Apache.
  • In the Active metrics list, select workload/apache.traffic.

The chart for Apache traffic is shown.

  1. In the Transform data section, select the following values:
  • Rolling window: 1 min
  • Rolling window function: rate
  1. In the Configure alert trigger section, select the following values and click Next:
  • Alert trigger: Any time series violates
  • Threshold position: Above threshold
  • Threshold value: 4000
  1. In the Configure notifications and finalize alert section, select the following values:
  • Notification channels: An email address you have access to
  • Incident autoclose duration: 30 min
  • Name the alert policy: Apache traffic above threshold
  1. Click Create policy. Your alerting policy is now active.

Click Check my progress to verify the objective.

Create an alerting policy

Test the alerting policy

To test the alerting policy you just created, do the following:

  1. Navigate to Cloud Console > Compute Engine.

  2. In the Connect column, click SSH to open a terminal to your VM instance.

  3. In the terminal, enter the following command:

timeout 120 bash -c -- 'while true; do curl localhost; sleep $((RANDOM % 4)) ; done'

The previous command generates traffic in your Apache Web Server.

After the traffic rate threshold value of 4 KiB/s is exceeded in your Apache Web Server, an email notification is sent. It might take several minutes for this process to complete.

The email notification you receive looks similar to the following:

Congratulations!

In this lab, you learned how to install Ops Agent on a VM and use it to set an alerting policy to notify a recipient of potential issues with the instance.

Ops Agent, similar to Azure Monitor Agent, is used to collect telemetry data from your Virtual machine instances. Here are some similarities and differences between the two services:

Similarities:

  • Both Azure Monitor and Google Cloud’s operations suite Ops Agent support alerting and notification capabilities that can notify customers when certain conditions are met, such as high CPU usage or low disk space.
  • Both Azure Monitor and Ops Agent provide integration with other tools and services, such as dashboards, analytics, and automation tools.

Differences:

  • In Azure, you configure LogAnalytics to collect data from your resources. Ops Agent uses a built-in configuration that defines the default log collections for metrics and logs. This default configuration can be overridden to include new configuration elements.
  • In Azure, you create a log analytics workspace for storing and analyzing the logs sent by the agent. In Google Cloud, you use the Cloud logging to view and analyze the log data.
  • The Ops Agent offers tracing capabilities with OpenCensus and has built-in support for Google Cloud’s operations suite (formerly Stackdriver). Azure Monitor offers Application Insights, a tool for monitoring the performance of applications running on Azure.

End your lab

When you have completed your lab, click End Lab. Google Cloud Skills Boost removes the resources you’ve used and cleans the account for you.

You will be given an opportunity to rate the lab experience. Select the applicable number of stars, type a comment, and then click Submit.

The number of stars indicates the following:

  • 1 star = Very dissatisfied
  • 2 stars = Dissatisfied
  • 3 stars = Neutral
  • 4 stars = Satisfied
  • 5 stars = Very satisfied

You can close the dialog box if you don't want to provide feedback.

For feedback, suggestions, or corrections, please use the Support tab.

Copyright 2022 Google LLC All rights reserved. Google and the Google logo are trademarks of Google LLC. All other company and product names may be trademarks of the respective companies with which they are associated.

Previous Next

Before you begin

  1. Labs create a Google Cloud project and resources for a fixed time
  2. Labs have a time limit and no pause feature. If you end the lab, you'll have to restart from the beginning.
  3. On the top left of your screen, click Start lab to begin

This content is not currently available

We will notify you via email when it becomes available

Great!

We will contact you via email if it becomes available

One lab at a time

Confirm to end all existing labs and start this one

Use private browsing to run the lab

Use an Incognito or private browser window to run this lab. This prevents any conflicts between your personal account and the Student account, which may cause extra charges incurred to your personal account.
Preview