How to do it...

In this recipe we'll create an alerting policy to see if the application is up and running. Additionally, we'll also set up an uptime check to see whether the server is up and running:

  1. Select your project in the GCP Console and navigate to Stackdriver | Monitoring.
  2. If monitoring is not setup for your project, you'll see the following screen:
  1. You can either create a new Stackdriver account or add the project to an existing account as per your need.
  2. Let's create a new Stackdriver account by clicking on Create Account:
  1. In the next step, add the GCP project to be monitored and click on Continue:
  1. You can skip the following AWS setup and continue to the install the Stackdriver agents step. Copy the installation steps to your favorite editor; we'll be using the steps later in the recipe. Click on Continue to proceed.

 

  1. Select an interval to receive the Stackdriver reports and continue:
  1. Click on Launch monitoring to view the Stackdriver Monitoring page:
  1. Now, let's create two CentOS 7 and f1-micro instances and monitor them. Make sure you allow HTTP and HTTPS traffic to the machine:
  1. SSH into the first instance and install the Stackdriver Monitoring and Stackdriver Logging agents:
$ curl -sSO https://repo.stackdriver.com/stack-install.sh
$ sudo bash stack-install.sh --write-gcm
Installing agents for RHEL or CentOS.
warning: /var/cache/yum/x86_64/7/stackdriver/packages/stackdriver-agent-5.5.2-379.sdl.el7.centos.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 7b190bd2: NOKEY
...
...
Using Cloud Monitoring API
Restarting services
Restarting stackdriver-agent (via systemctl): [ OK ]
$ curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh
$ sudo bash install-logging-agent.sh
==============================================================================
Starting installation of google-fluentd
==============================================================================
Installing agents for RHEL or CentOS.
Importing GPG key 0xA7317B0F:
...
...
Starting google-fluentd (via systemctl): [ OK ]
Restarting google-fluentd (via systemctl): [ OK ]
==============================================================================
Installation of google-fluentd complete.
...
You can monitor the logging agent's logfile at:
/var/log/google-fluentd/google-fluentd.log
==============================================================================
  1. Verify that the stackdriver-agent is in running state:
$ sudo systemctl status stackdriver-agent
  1. Install the Apache webserver and start it:
$ sudo yum install -y httpd
$ sudo systemctl enable httpd
$ sudo systemctl start httpd
  1. In your favorite browser, the external IP of the instances should present the Testing 123.. page of the Apache webserver:
  1. Now, let's set up an uptime check for the first instance, instance-1. In the Stackdriver Monitoring console, navigate to the Uptime Checks menu and click on Create an Uptime Check:
  1. Enter a name for the resource type and select Instance. Select the instance in the Applies To section of the menu. With the other fields as default, click on the Save button:
  1. You can also create an alerting policy associated with the uptime check:
  1. The condition for the alerting policy is filled when you navigate from the uptime check:
  1. Update the name of the alerting policy and click on Save Policy:
  1. The alerting policy is created successfully:
  1. Next, let's create a dashboard to view the instance's performance. Navigate to the Dashboards menu and click on Create Dashboard and give a name to the dashboard.

 

  1. Click on the ADD CHART button to view the CPU usage on the GCP instances. Select the resource type as GCE VM Instance and CPU usage as the metric. Then, click on the Save button:
  1. You can now view the various monitoring setups. The following screenshot shows the uptime check policy:
  1. The following screenshot shows the Uptime Check Latency:
  1. The following screenshot shows the dashboard:
  1. You can try stopping the first instance (instance-1) and re-verify the monitoring alerts and dashboard.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.6.154