![]() |
VOOZH | about |
Cloud monitoring is the process of reviewing and managing the operational workflow and processes within a cloud infrastructure or asset. These techniques confirm the performance of websites, servers, applications, and other cloud infrastructure.
The following steps create the monitor in the Google cloud console.
Step 1: Create a Compute Engine instance :
Navigation menu --> Compute Engine --> VM instances --> Create.
| Field | Value |
|---|---|
| Name | GeeksforGeeks |
| Region | us-central1 (Iowa) |
| Zone | us-central-a |
| Series | N1 |
| Machine type | n1-standard-2 |
| Firewall | check allow HTTP traffic |
Step 2: Add Apache2 HTTP Server to your instance
In the SSH of created instance, the following commands will set up Apache2 HTTP Server.
sudo apt-get update sudo apt-get install apache2 php7.0 sudo service apache2 restart👁 Image
To verify the setup, go to the external IP and view the successful deployment of the server.
Step 3: Create a Monitoring workspace
Navigation menu --> Monitoring
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-monitoring-agent-repo.sh sudo bash add-monitoring-agent-repo.sh sudo apt-get update sudo apt-get install stackdriver-agent
Run the Logging agent install script command in the SSH terminal of your VM instance to install the Cloud Logging agent
curl -sSO https://dl.google.com/cloudagents/add-logging-agent-repo.sh sudo bash add-logging-agent-repo.sh sudo apt-get install google-fluentd
Step 4: Create an uptime check
Cloud Console --> Uptime checks (in the left menu) --> Create Uptime Check
Set the following fields:
Title: GFG Uptime Check, then click Next. Protocol: HTTP Resource Type: Instance Applies to: Single, geeksforgeeks Path: leave at default Check Frequency: 1 min
After entering all the necessary fields, click "TEST" . If it responds the way depicted in the below picture, click "CREATE".
👁 ImageStep 5: Create an alerting policy
Step 6: Now select Network traffic (gce_instance+1). Be sure to choose the Network traffic resource with agent.googleapis.com/interface/traffic:
Step 7: Click on Next.
Step 8: Click on drop-down arrow next to Notification Channels, then click on Manage Notification Channels.
Step 9: Scroll down the page and click on ADD NEW for Email.
Step 10: In Create Email Channel dialog box, enter your personal email address in the Email Address field and a Display name. Click on Save.
Step 11: Go back to the previous Create alerting policy tab.
Step 12: Click on Notification Channels again, then click on the Refresh icon to get the display name you mentioned in the previous step.
Step 13: Now, select your Display name and click OK. Click Next.
Step 14: Mention the Alert name as Inbound Traffic Alert.
Step 15: Add a message in the documentation, which will be included in the emailed alert. Click on Save.
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.
👁 ImageTo display the metrics collected by Cloud Monitoring create your own charts and dashboards. In this section, you create the charts for the lab metrics and a custom dashboard.
Step 1: In the left menu select Dashboards, and then Create Dashboard.
Step 2: Name the dashboard Cloud Monitoring GeeksforGeeks.
Step 3: Add the first chart and Click the Line option in the Chart library.
Step 4: Name the chart title CPU Load.
Step 5: Set the Resource type to VM Instance.
Step 6: Set the Metric CPU load (1m). Refresh the tab to view the graph.
👁 ImageCloud Monitoring and Cloud Logging are closely integrated. Check out the logs for your lab.
Select Navigation menu --> Logging --> Logs Explorer.
Select the logs you want to see, in this case, you select the logs for the geeksforgeeks instance you created at the start of this lab:
Resource --> VM instances --> geeksforgeeks👁 Image
Step 1: Click "ADD"
Step 2: Click "Stream logs"
Step 3: You see the logs for your VM instance
Step 4: Open the Compute Engine window in a new browser window.
Select Navigation menu --> Compute Engine, right-click VM-instances --> Open link in new window.
Step 5: 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.
Step 6: In the Compute Engine window, select the geeksforgeeks instance, click Stop at the top of the screen, and then confirm to stop the instance.
👁 ImageStep 7: Watch in the Logs View tab for when the VM is stopped.
Step 8: In the VM instance details window, click Start at the top of the screen, and then confirm. It will take a few minutes for the instance to re-start. Watch the log messages to monitor the startup.