Get notified if your app stops responding
Learn how to get notified if your application stops responding to HTTP requests by completing the following tasks:
- Create an email notification channel.
- Create an uptime check and an alerting policy.
- View the uptime check dashboard.
- Force the uptime check to fail.
- View the email notification and the incident.
- Clean up.
To follow step-by-step guidance for this task directly in the Google Cloud console, click Guide me:
Before you begin
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Monitoring API.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Monitoring API.
Create an email notification channel
Before you create an alerting policy, configure the notification channels that you want the alerting policy to use. Cloud Monitoring supports many different types of notification channels, including email, Slack, PagerDuty, and Pub/Sub. For more information, see Create and manage notification channels. To get notifications by e-mail, do the following:-
In the Google Cloud console, go to the notifications Alerting page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
- In the toolbar, click Edit Notification Channels.
- On the Notification channels page, scroll to
Email , and then click Add new. - Enter your email address, a display name such as
My email
, and then click Save.
Create an uptime check and alerting policy
To be notified when an application fails to respond to requests, configure an uptime check to send requests to the application, and then configure an alerting policy to monitor the responses to the uptime check:
-
In the Google Cloud console, go to the Uptime checks page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
- In the toolbar, click Create uptime check.
- For the Resource Type, select URL.
- For the Hostname, enter a valid URL for your company, or enter
cloud.google.com
. - If you entered the URL for your company, leave the Path field empty.
Otherwise, enter
/monitoring/docs
.The uptime check is configured to either send requests to the URL for your company, or to
cloud.google.com/monitoring/docs
. - Click Continue to advance to the Response validation
section.
For information about these settings, see Validate response data.
- Click Continue to advance to the Alert & Notification section.
- Expand the Notification channels menu and select your notification channel.
- Click Continue to advance to the Review section.
- Enter a title, such as
My check
, for the uptime check. To verify your uptime check configuration, click
Test .If you receive an error, see Verify your uptime check.
- Click Create.
Your uptime check and alerting policy are created, and your new uptime check is listed on the Uptime checks page.
View the uptime check dashboard
The Uptime checks page displays a list of your uptime checks and the status of each check. To view the detailed status of the uptime check you created, do the following:
-
In the Google Cloud console, go to the Uptime checks page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
Click the name of the uptime check to open the uptime-check's dashboard.
Because your uptime check hasn't executed, the charts are empty and the status for the uptime check is No checks have run.
In the toolbar, enable auto-refresh on the charts by clicking
Enable auto refresh.Wait until a few data points appear on the charts, and then refresh the page.
When the status for each location is
Pass, proceed to the next step. Otherwise, wait a minute and refresh the page to update the status pane.
Force the uptime check to fail
To force the uptime-check to fail, modify the Path such that the URL tested by the uptime check is invalid:
- In the toolbar, click Edit.
- In the Path field, append or enter HelloWorld.
- Click Save.
- In the toolbar, enable auto-refresh on the charts by clicking Enable auto refresh.
Wait until the data points on the Passed Checks chart goes to zero, and then refresh the page.
When the status for each location is
Fail. proceed to the next step. Otherwise, wait a minute and refresh the page to update the status pane.
View the notification and incident
After the alerting policy determines that the uptime check has had two consecutive failures, Cloud Monitoring creates an incident and sends notifications. An incident is a record of an alerting policy that triggers, and it contains information that is useful for troubleshooting failures. To view the notification and incident, do the following:
- Open your email account, and view the message whose title starts with
[ALERT] Failure of uptime check_id
. To get details about the failure, in the notification, click View incident.
The Incident details page opens in a new page of the Cloud console.
You have successfully created an uptime check and an alerting policy, you forced the uptime check to fail, and you've received a notification. You can now close the browser page that displays the Incident details page,
Clean up
To avoid incurring charges to your Google Cloud account for the resources used on this page, follow these steps.
If you created a new project and you no longer need the project, then delete the project.
If you used an existing project, then do the following:
Delete the uptime check that you created:
-
In the Google Cloud console, go to the Uptime checks page:
If you use the search bar to find this page, then select the result whose subheading is Monitoring.
- Select the uptime check that you created, and then click
Delete .When you delete an uptime check, you also delete the alerting policy that monitors that uptime check.
-
What's next
To learn how to view and customize dashboards for your VMs, see the quickstart View and customize VM instance dashboards.
To learn about testing your applications, see Synthetic monitoring overview.
To learn how to install the Ops Agent and collect metrics from an Apache server, see the quickstart Collect Apache metrics with the Ops Agent.
To learn about the Ops Agent, see Ops Agent overview.
To learn about creating custom dashboards, see Manage custom dashboards.