To complete this lab, you need:
Internet access
Access to a supported Internet browser:
In this codelab you will learn how to use Stackdriver Monitoring to gain insight into applications that run on Google Cloud Platform.
To make cleanup easier, create a new google cloud project.
Remember the project ID, a unique name across all Google Cloud projects. It will be referred to later in this lab as PROJECT_ID
.
Now let's open the cloud shell. The cloud shell icon is at the top right:
A cloud shell session will open inside a new frame at the bottom of your browser.
Once connected to the cloud shell, you should see that you are already authenticated and that the project is already set to your PROJECT_ID
. If this is not the case, replace your PROJECT_ID
in the following command:
gcloud config set project PROJECT_ID
We need to create some resources within this Google Cloud Platform project before we can actually monitor them. Let's do that now.
We will create a few Nginx instances using a Bitnami Nginx Stack image, which includes a complete PHP, MySQL and Nginx development environment.
Let's create a few instances, by copying the following command in cloud shell:
for i in {1..3}; \
do \
gcloud compute instances create "nginxstack-$i" \
--machine-type "f1-micro" \
--tags nginxstack-tcp-443,nginxstack-tcp-80 \
--zone us-central1-f \
--image "https://www.googleapis.com/compute/v1/projects/bitnami-launchpad/global/images/bitnami-nginxstack-1-10-2-0-linux-debian-8-x86-64" \
--boot-disk-size "10" --boot-disk-type "pd-standard" \
--boot-disk-device-name "nginxstack-$i"; \
done
Next, let's create a firewall rule to allow external traffic to these instances
gcloud compute firewall-rules create nginx-firewall \
--allow tcp:80,tcp:443 \
--target-tags nginxstack-tcp-80,nginxstack-tcp-443
To use Stackdriver Monitoring with your project, do the following:
Select "Monitoring" on the Cloud Console's left navbar. This will redirect to the Stackdriver Monitoring Console.
You may be prompted to login again. If so, click "Log in with Google", and then choose your account to login.
Once logged in, Stackdriver will ask you to add the project to a Stackdriver account. Choose "Create a new Stackdriver account", and click Continue.
Click Create Account to create a Stackdriver account on this project
If you want to monitor other Google Cloud Platform projects under the same Stackdriver account, select the projects, and click Continue.
For extra credit, if you use AWS, you can also monitor AWS accounts with Stackdriver Monitoring. You can skip this section, click Continue.
We will not install the Stackdriver agents on this codelab, click Continue.
Stackdriver can send you reports on the performance of your application. For this codelab, select "No Reports", click Continue.
Stackdriver will then perform an initial collection task on your resources. Once it's done, click Launch monitoring.
You will see a Welcome dialog informing you that your Stackdriver account is in a free trial of the Premium Tier for 30 days. Click, Continue with the trial.
You should now be looking at the Stackdriver Monitoring Console. The information on the console will vary depending on the resources you are monitoring.
Select Dashboards on the left navbar, and click Create Dashboard.
Click on the Untitled Dashboard text field and replace the text with an appropriate dashboard title, like Codelab Dashboard
To add a chart to your dashboard, do the following:
Click the Add Chart button
As it name implies, the Metrics Explorer allows you to examine resources and metrics without having to create a chart on a dashboard.
Let's try to recreate the chart we just created with the Metrics Explorer:
You can set up alerting policies in Stackdriver Monitoring to determine when your applications are not operating normally.
To create an alerting policy, select Alerting on the left navbar, and click Create a Policy.
You can configure one or more notifications to contact specific people or services when an alerting policy is violated.
Take the next few minutes to disable or delete any Alerts you created. It may take some time for the service to stop sending messages.
You can delete the project.
©Google, Inc. or its affiliates. All rights reserved. Do not distribute.