To generate a cost estimate based on your projected usage,
use thepricing calculator.
New Google Cloud users might be eligible for afree trial.
Monitoring is currently offered to beta users at no charge.
Before you begin
Sign in to your Google Cloud account. If you're new to
Google Cloud,create an accountto 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.
After you deploy your app,
you can use Monitoring to create an uptime check. The check
continually pings your deployed app to ensure that it's returning a healthy
response.
In the Google Cloud console, go to theUptime checkspage:
If you use the search bar to find this page, then select the result whose subheading isMonitoring.
ClickCreate Uptime Check.
Give your check a title, such asCheck Hello World,
and then clickNext.
In theTargetsection, you specify what the uptime check is to monitor:
Because you deployed to App Engine, changeResource TypetoApp Engineinstead ofURL. (URLis for generating a custom
URL on a Compute Engine instance.)
Select theServiceto be monitored by the uptime check.
LeavePathblank to default to the main index page.
LeaveCheck frequencyat the default of1minute.
ClickNext.
Leave theResponse Validationfields at their default values and
clickNext.
In theAlert & Notificationsection, you specify how you are notified
if an alert occurs:
Ensure that the toggle's label isAlerting is enabled.
Leave the name and duration fields at their default values.
To add a notification channel to the alerting policy, in the
text box labeledNotification channels, clickMenu.
Select the channels to add and clickOK.
The notifications are grouped alphabetically for each channel type.
To add an entry to the checkbox list, clickManage notification channelsand follow the instructions. When you
return to this dialog, clickRefreshrefresh.
ClickCreate. When the create action is successful, the messageCheck and alert createdis displayed and then theUptime checksdashboard page is displayed.
In the uptime checks dashboard, your new uptime check is listed. If you
click the check name, then you open the detail view for that uptime check.
This view displays several charts, shows the uptime percentage and the
configuration information, and lists the configured alert policies.
To view a policy, click its name.
You can also view the alert policy by starting at theAlertingpage.
From the alerting page, thePoliciespane lists a subset of policies.
To view a list of all policies, clickSee all policies.
Simulating an outage
Now that the uptime check is created, you can simulate an outage by changing
your app to respond with an HTTP404 Sorry, we can't find that pageerror
rather than an HTTP200 OKresponse.
The following code shows where the Hello World app returns only a 'Hello
World!' message, and that the status code of the response defaults to200 OK.
To view this code in the Hello World app, use the view function.
# Copyright 2019 Google LLC All Rights Reserved.## Licensed under the Apache License, Version 2.0 (the "License");# you may not use this file except in compliance with the License.# You may obtain a copy of the License at## http://www.apache.org/licenses/LICENSE-2.0## Unless required by applicable law or agreed to in writing, software# distributed under the License is distributed on an "AS IS" BASIS,# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.# See the License for the specific language governing permissions and# limitations under the License.fromflaskimportFlaskapp=Flask(__name__)@app.route('/',methods=['GET'])defsay_hello():return"Hello, world!"if__name__=='__main__':app.run(host='127.0.0.1',port=8080,debug=True)
To cause the Hello World app to return an HTTP404error code, change the
return line by adding a404value to the second part of the return value.
return'Hello World',404
Deploy the new, intentionally broken app.
gcloudappdeploy
Within half an hour, you'll receive an email message that states that your
uptime check is failing.
Clean up
To avoid incurring charges to your Google Cloud account for the resources used in this
tutorial, either delete the project that contains the resources, or keep the project and
delete the individual resources.
The easiest way to eliminate billing is to delete the project that you
created for the tutorial.
To delete the project:
In the Google Cloud console, go to theManage resourcespage.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-02 UTC."],[],[],null,["# Setting an uptime alert\n\n*** ** * ** ***\n\nThis tutorial shows how to set up an uptime alert for the\n[Python Hello World app](/python/getting-started/hello-world)\nrunning on App Engine flexible environment using\n[Cloud Monitoring](/monitoring/docs).\nUptime alerts let you know when your app is not serving traffic. You can also set\nuptime alerts for apps running on [Compute Engine](/compute)\nor [Google Kubernetes Engine (GKE)](/kubernetes-engine).\n\nObjectives\n----------\n\n- Run a basic Hello World app.\n- Create an uptime check that monitors whether the app returns an HTTP '200' status code.\n- Create an alert that sends an email message to you when the uptime check fails.\n- Restart the app to trigger the alert.\n\nCosts\n-----\n\n\n| **Important:** In this document, you use the following billable components of Google Cloud:\n|\n| - [App Engine](/appengine/pricing)\n| - [Cloud Monitoring](/stackdriver/pricing)\n|\n| To generate a cost estimate based on your projected usage, use the [pricing calculator](/products/calculator). New Google Cloud users might be eligible for a [free trial](/free). \n\nMonitoring is currently offered to beta users at no charge.\n\nBefore you begin\n----------------\n\n- Sign in to your Google Cloud account. If you're new to Google Cloud, [create an account](https://console.cloud.google.com/freetrial) to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n- In the Google Cloud console, on the project selector page,\n select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n-\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\nCloning the sample app\n----------------------\n\nThe sample app is available on GitHub at\n[`GoogleCloudPlatform/getting-started-python`](https://github.com/GoogleCloudPlatform/getting-started-python).\n\n1. Clone the repository.\n\n git clone https://github.com/GoogleCloudPlatform/getting-started-python.git\n\n2. Go to the sample directory.\n\n cd getting-started-python/gce\n\n3. Because the app only returns \"Hello World!\", it requires no configuration, and\n you can run it right away.\n\n gcloud app deploy\n\n4. To see the returned message, enter the following URL in your browser:\n\n `https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r.appspot.com`\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your Google Cloud project ID\n - \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e: A [code that App Engine assigns\n to your app](/appengine/docs/standard/python3/how-requests-are-routed#region-id)\n\nCreating an uptime check\n------------------------\n\nAfter you deploy your app,\nyou can use Monitoring to create an uptime check. The check\ncontinually pings your deployed app to ensure that it's returning a healthy\nresponse.\n\n1. In the Google Cloud console, go to the **Uptime checks** page:\n\n [Go to **Uptime checks**](https://console.cloud.google.com/monitoring/uptime)\n\n \u003cbr /\u003e\n\n If you use the search bar to find this page, then select the result whose subheading is\n **Monitoring**.\n2. Click **Create Uptime Check**.\n3. Give your check a title, such as `Check Hello World`,\n and then click **Next**.\n\n4. In the **Target** section, you specify what the uptime check is to monitor:\n\n 1. Because you deployed to App Engine, change **Resource Type** to **App Engine** instead of **URL** . (**URL** is for generating a custom URL on a Compute Engine instance.)\n 2. Select the **Service** to be monitored by the uptime check.\n 3. Leave **Path** blank to default to the main index page.\n 4. Leave **Check frequency** at the default of **1** minute.\n 5. Click **Next**.\n5. Leave the **Response Validation** fields at their default values and\n click **Next**.\n\n6. In the **Alert \\& Notification** section, you specify how you are notified\n if an alert occurs:\n\n - Ensure that the toggle's label is **Alerting is enabled**.\n - Leave the name and duration fields at their default values.\n - To add a notification channel to the alerting policy, in the\n text box labeled **Notification channels** , click **Menu** .\n Select the channels to add and click **OK**.\n The notifications are grouped alphabetically for each channel type.\n\n To add an entry to the checkbox list, click\n **Manage notification channels** and follow the instructions. When you\n return to this dialog, click\n **Refresh** *refresh*.\n7. Click **Create** . When the create action is successful, the message\n **Check and alert created** is displayed and then the **Uptime checks**\n dashboard page is displayed.\n\n In the uptime checks dashboard, your new uptime check is listed. If you\n click the check name, then you open the detail view for that uptime check.\n This view displays several charts, shows the uptime percentage and the\n configuration information, and lists the configured alert policies.\n To view a policy, click its name.\n\n You can also view the alert policy by starting at the **Alerting** page.\n From the alerting page, the **Policies** pane lists a subset of policies.\n To view a list of all policies, click **See all policies**.\n\nSimulating an outage\n--------------------\n\nNow that the uptime check is created, you can simulate an outage by changing\nyour app to respond with an HTTP `404 Sorry, we can't find that page` error\nrather than an HTTP `200 OK` response.\n\n1. The following code shows where the Hello World app returns only a 'Hello\n World!' message, and that the status code of the response defaults to `200 OK`.\n To view this code in the Hello World app, use the view function.\n\n # Copyright 2019 Google LLC All Rights Reserved.\n #\n # Licensed under the Apache License, Version 2.0 (the \"License\");\n # you may not use this file except in compliance with the License.\n # You may obtain a copy of the License at\n #\n # http://www.apache.org/licenses/LICENSE-2.0\n #\n # Unless required by applicable law or agreed to in writing, software\n # distributed under the License is distributed on an \"AS IS\" BASIS,\n # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n # See the License for the specific language governing permissions and\n # limitations under the License.\n\n from flask import Flask\n app = Flask(__name__)\n\n\n @app.route('/', methods=['GET'])\n def say_hello():\n return \"Hello, world!\"\n\n\n if __name__ == '__main__':\n app.run(host='127.0.0.1', port=8080, debug=True)\n\n2. To cause the Hello World app to return an HTTP `404` error code, change the\n return line by adding a `404` value to the second part of the return value.\n\n ```bash\n return 'Hello World', 404\n ```\n3. Deploy the new, intentionally broken app.\n\n ```bash\n gcloud app deploy\n ```\n\n Within half an hour, you'll receive an email message that states that your\n uptime check is failing.\n\nClean up\n--------\n\n\nTo avoid incurring charges to your Google Cloud account for the resources used in this\ntutorial, either delete the project that contains the resources, or keep the project and\ndelete the individual resources.\n\n\nThe easiest way to eliminate billing is to delete the project that you\ncreated for the tutorial.\n\nTo delete the project:\n\n| **Caution** : Deleting a project has the following effects:\n|\n| - **Everything in the project is deleted.** If you used an existing project for the tasks in this document, when you delete it, you also delete any other work you've done in the project.\n| - **Custom project IDs are lost.** When you created this project, you might have created a custom project ID that you want to use in the future. To preserve the URLs that use the project ID, such as an `appspot.com` URL, delete selected resources inside the project instead of deleting the whole project.\n|\n|\n| If you plan to explore multiple architectures, tutorials, or quickstarts, reusing projects\n| can help you avoid exceeding project quota limits.\n1. In the Google Cloud console, go to the **Manage resources** page.\n\n [Go to Manage resources](https://console.cloud.google.com/iam-admin/projects)\n2. In the project list, select the project that you want to delete, and then click **Delete**.\n3. In the dialog, type the project ID, and then click **Shut down** to delete the project.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\\\u003c Prev [Next \\\u003e](/python/monitor-and-debug/reporting-errors)"]]