In this lab, you will learn how to use Cloud Monitoring to gain insight into applications that run on Google Cloud.
In this lab, you learn how to perform the following tasks:
- Explore Cloud Monitoring
- Add charts to dashboards
- Create alerts with multiple conditions
- Create resource groups
- Create uptime checks
Task 1: Create a Cloud Monitoring workspace
Verify resources to monitor
Three VM instances have been created for you that you will monitor.
- In the Cloud Console, on the Navigation menu > click Compute Engine > VM instances. Notice the nginxstack-1, nginxstack-2 and nginxstack-3 instances.
Create a Monitoring workspace
You will now setup a Monitoring workspace that’s tied to your Qwiklabs GCP Project. The following steps create a new account that has a free trial of Monitoring.
- In the Google Cloud Platform Console, click on Navigation menu > Monitoring.
- Wait for your workspace to be provisioned.
When the Monitoring dashboard opens, your workspace is ready.
Task 2: Custom dashboards
Create a dashboard
- In the left pane, click Dashboards.
- Click +Create Dashboard.
- For New Dashboard Name, type My Dashboard.
Add a chart
- From Chart library, Select Line.
- For Title, give your chart a name (you can revise this before you save based on the selections you make).
- For Resource type, select VM Instance.
- For Metric, select a metric to chart for the Instance resource, such as CPU utilization or CPU usage.
- Click + Add Filter and explore the various options.
The Metrics Explorer allows you to examine resources and metrics without having to create a chart on a dashboard. Try to recreate the chart you just created using the Metrics Explorer.
- In the left pane, click Metrics Explorer.
- For Find resource type and metric, type a metric or resource name.
- Explore the various options and try to recreate the chart you created earlier.
Task 3: Alerting policies
Create an alert and add the first condition
- In the left pane, click Alerting.
- Click + Create Policy.
- Click Add Condition.
- For Find resource type and metric, select VM Instance.
If you cannot locate the VM Instance resource type, you might have to refresh the page.
5. Select a metric you are interested in evaluating, such as CPU usage or CPU Utilization.
6. Under Configuration, for Condition, select is above.
7. Specify the threshold value and for how long the metric must cross this set value before the alert is triggered. For example, for THRESHOLD, type 20 and set FOR to 1 minute.
8. Click ADD.
Add a second condition
- Click Add Condition.
- Repeat the steps above to specify the second condition for this policy. For example, repeat the condition for a different instance. Click ADD.
- In Policy Triggers, for Trigger when, click All conditions are met.
- Click Next.
Configure notifications and finish the alerting policy
- Click on dropdown arrow next to Notification Channels, then click on Manage Notification Channels.
A Notification channels page will open in new tab.
2. Scroll down the page and click on ADD NEW for Email.
3. Enter your personal email in the Email Address field and a Display name.
4. Click Save.
5. Go back to the previous Create alerting policy tab.
6. Click on Notification Channels again, then click on the Refresh icon to get the display name you mentioned in the previous step.
7. Now, select your Display name and click OK.
8. Click Next.
9. Enter a name of your choice in Alert name field.
10. Click Save.
Task 4: Resource groups
- In the left pane, click Groups.
- Click + Create Group.
- Enter a name for the group. For example: VM instances
- In the Criteria section, type nginx in the value field below Contains.
- Click DONE.
- Click CREATE.
- Review the dashboard Cloud Monitoring created for your group.
Task 5: Uptime monitoring
- In the Monitoring tab, click on Uptime Checks.
- Click + Create Uptime Check.
- Specify the following, and leave the remaining settings as their defaults:
4. Click on Next to leave the other details to default. Under Alert & Notification, select your Notification Channels from the dropdown.
5. Click Test to verify that your uptime check can connect to the resource.
6. When you see a green check mark everything can connect. Click Create.
7. The uptime check you configured takes a while for it to become active.
This concludes our lab — Resource Monitoring