Hi Readers, In previous blog we understood the need and role of GCP Cloud monitoring, logging, error debugging and so on. In this blog we will see how we can work with GCP Cloud Operations to create dashboards and alerts to get notified in case of any event happening against our set alert policy.
Step-1 :Create a simple instance with Firewalls to allow HTTP traffic
Step-2 :SSH to it and install apache2 and php
sudo apt-get update sudo apt-get install apache2 php7.0
Step:3 Verify apache2 is running
sudo systemctl status apache2
In a browser, navigate to http://[EXTERNAL_IP]
Step:4 Install the agent itself now
Create a file with this content, this will install the monitoring and logging agents inside our compute engine.
curl -sSO https://dl.google.com/cloudagents/install-monitoring-agent.sh sudo bash install-monitoring-agent.sh curl -sSO https://dl.google/com/cloudagents/install-logging-agent.sh sudo bash install-logging-agent.sh
Step 5: Go to Navigation Menu > Operations > Monitoring > Dashboard
Here we will need to create a dashboard and then we can add a chart to it as well. To keep it simple we will select Stacked bar option here.
Step 6: Go to Navigation Menu > Operations > Monitoring > Alerting
Here we will need to create an alert policy in order to monitor the created VM.
This policy will send an alert via SMS on phone whenever the CPU usage is above 0.010%. 0.010% is very low, but it is good enough to test the functionality locally.
After this whenever the CPU usage will cross the threshold limit we will get an SMS alert on phone like this,
That’s all for this blog. In this blog we understood the basics monitoring and logging for our virtual machines.
Thank you for following this blog till end. If you found this blog helpful do share this blog with your colleagues. In case of any feedback, suggestion or question reach out to me at email@example.com.