An uptime check is a request sent to a resource to see if it responds. You can use uptime checks to determine the availability of a VM instance, an App Engine service, a URL, or an AWS load balancer.
You can monitor the availability of a resource by creating an alerting policy that creates an incident if the uptime check fails. The alerting policy can be configured to notify you by email or through a different channel, and that notification can include details about the resource that failed to respond. You also have the option to observe the results of uptime checks in the Monitoring uptime-check dashboards.
This page shows you how to do the following:
- Create a new uptime check.
- View the dashboard for an uptime check.
- Edit an uptime check.
- Delete an uptime check.
See the What's next section for links to pricing pages and to pages that describe monitoring your uptime checks.
Before you begin
Your use of uptime checks is affected by any firewalls protecting your service.
- If the resource you are checking isn't publicly available, you must configure the resource's firewall to permit incoming traffic from the uptime-check servers. See Getting IP addresses to download a list of the IP addresses.
- If the resource you are checking doesn't have an external IP address, uptime checks are unable to reach it.
The uptime check doesn't load page assets or run JavaScript, and the default configuration of an uptime check doesn't include authentication.
For HTTP and HTTPS, if the response is a redirection to another URL, the check retrieves the data from that URL. Lastly, the uptime check evaluates the data to determine if the check succeeded or failed.
To succeed, these conditions must be met:
- The HTTP status is
Success
. - The data has no required content or the required content is present.
- The HTTP status is
Creating an uptime check
This section explains how to create and configure uptime checks.
Console
To create an uptime check by using the Google Cloud Console, do the following:
In the Cloud Console, select Monitoring:
Click Uptime checks.
Click Create Uptime check.
Enter a descriptive title for the Uptime check and then click Next.
Specify the target of the uptime check:
Select the protocol. You have the options of HTTP, HTTPS, and TCP.
Choose one of the following resource types:
- URL: Any IPv4 address or hostname. Path and port are entered separately.
- App Engine: App Engine applications (modules).
- Instance: Compute Engine or AWS EC2 instances.
- Elastic Load Balancer: AWS load balancer.
Enter the protocol-specific fields:
For TCP checks, enter the port.
For HTTP and HTTPS checks, you have the option to enter a path within your host or resource. All uptime checks that use these protocols send a request to
http://target/path
. In this expression, for a URL resource,target
is a hostname or IP address. For an App Engine resource,target
is a hostname derived from the service name. For instance and load balancer resources,target
is an IP address derived from the name you provided for the resource or the group of resources.If you leave the
path
field blank or if you set the value to/
, then the request is issued tohttp://target/
.To issue an uptime check to the URL resource
example.com/tester
, set the hostname field toexample.com
and the path field to/tester
.Suppose you've deployed a server to App Engine with a dispatcher that supports
/
and/hello
. If you leave the path field empty, then the uptime check is sent to the/
handler. To issue the uptime check to the/hello
handler, set the value of the path field to/hello
.
Enter the resource-specific fields:
For URL resources, enter the host name in the Hostname field. For example, enter
example.com
.For App Engine resources, enter the service name in the Service field.
For Elastic Load Balancer and Instance resources, complete the following fields:
- To issue an uptime check to a single instance or load balancer, in the Applies to field, select Single and then use the menu to select the specific instance or load balancer.
- To issue an uptime check to a Monitoring group, in the Applies to field, select Group, and then use the menu to select the group name.
The field Check frequency controls how often the uptime check executes. You can leave at the default value or select a value from the menu of options.
To configure checker regions, or to configure SSL certificates, authentication, headers, and ports for HTTP and HTTPS checks, click More target options:
- Regions: Select the regions where the uptime checks are to receive requests. An uptime check must have at least 3 checkers. There is 1 checker in all regions except the United States, which has 3 checkers. The default setting, Global includes all regions.
- General: Fill this field in to check virtual hosts. This field isn't available for TCP checks.
- Port: Specify a port number.
Custom Headers: Supply custom headers, and encrypt them if desired. Encryption hides the headers' values in the form. Use encryption for headers related to authentication that you don't want visible to others.
Authentication: Provide a single username and password. These values are sent as an Authorization header. If you set values here, don't set a separate Authorization header; if you set an Authorization header, don't set values here. Passwords are always hidden in the form. This field isn't available for TCP checks.
SSL Certificate Validation: If you selected HTTPS for a URL resource, then by default, the service attempts to connect over HTTPS and validates the SSL certificate. The uptime check fails if a URL has an invalid certificate. Reasons for an invalid certificate include an expired certificate, a self-signed certificate, a certificate with a domain-name mistmach, and a certificate that uses the AIA extension.
To force an HTTPS uptime check to validate the SSL certificate, ensure that Validate SSL certificates is selected.
To disable SSL certificate validation, ensure that Validate SSL certificates is clear.
If you have SSL Certificates with Authority Information Access (AIA) Extensions, then you must disable SSL certificate validation. These types of certificates aren't supported and fail the validation sequence. Typically, the error message is "Responded with SSL handshake Error in 10000 ms".
You can use the metric
monitoring.googleapis.com/uptime_check/time_until_ssl_cert_expires
to create an alert that notifies you before your certificate expires. For more information, see Sample policies: Uptime-check policy.Select Validate SSL certificates checkbox.
Click Next.
Configure the response requirements:
Select the Response Timeout from the menu of options. You can choose any value between
1
to60
seconds. An uptime check fails if no response is received from more than one location within this timeout.For content matching, ensure that the toggle label is Content matching is enabled:
- Select the Response content match type from the menu of options.
This field determines how the response content is compared to the
returned data. For example, if the response content is
abcd
and the content match type is Contains, then the uptime check is successful if the response data containsabcd
. The uptime check fails if the response doesn't containabcd
. - Enter the Response content. This must be a string no longer
than 1024 bytes. In the API, this is the
ContentMatcher
object.
- Select the Response content match type from the menu of options.
This field determines how the response content is compared to the
returned data. For example, if the response content is
If you don't want uptime checks sent to Cloud Logging, then uncheck Log check failures.
Click Next
Create an alerting policy. When your uptime check is monitored by an alerting policy, if the uptime fails, then an incident is created and a notification is sent to all notification channels attached to the policy. For example, if you add an email address to the policy, then an email is sent to that address. You can create the alerting policy in this step, or you can create an alerting policy after the check is created.
If you don't want to create an alerting policy as part of this flow, then ensure the text of the toggle button is Do not create an alert. Click the button to change the toggle state,
To create an alerting policy as part of this flow, do the following:
Ensure the toggle button text is Create an alert. Click the button if necessary.
In the name field, enter a name for the alerting policy or use the default name.
To add one or more notification channels to the alerting policy, in the text box labeled Notification channels, click Menu arrow_drop_down. Select the channels to add and click OK. The notifications channels are grouped alphabetically for each channel type.
If a notification channel that you want to add to the alerting policy isn't listed, click Manage notification channels.
You are taken to the Notification channels window in a new browser tab. Add the notification channels and then return to this tab, click Refresh refresh, and then select the notification channels to add to the alerting policy.
In the duration field, select how long the uptime checks must fail before an incident is created. By default, the alerting policy is configured to create an incident if at least 2 regions report uptime check failures for a duration of 1 minute.
See Managing policies for information on disabling, editing, and deleting alerting policies.
To verify your uptime check configuration, click Test. If the result isn't what you expect, see the Check failures section below, correct your configuration, and then repeat the verification step.
Click Create. If required data is missing, the save action fails and a list of fields that require data is displayed next to the dialog buttons. After you save your changes, the Uptime check created dialog is displayed.
API
Call the projects.uptimeCheckConfigs.create
method. Set the method's parameters as follows:
parent: Required. This must be the name of the project in which to create the uptime check. Replace
PROJECT_ID
with your Google Cloud project ID. The format is:projects/PROJECT_ID
The request body must contain an
UptimeCheckConfig
object for the new uptime check. This page provides information on only a few fields. For complete documentation on this object and its fields, seeUptimeCheckConfig
:Leave the
name
field of the configuration object blank. The system sets this field when it constructs the response configuration object.If you are configuring an HTTP or HTTPS check, then you must populate the
HttpCheck
field of theUptimeCheckConfig
object. In this object, set therequestMethod
field asGET
orPOST
. If this field is omitted or set toMETHOD_UNSPECIFIED
, then aGET
request is issued.If you are configuring a
POST
request, then complete thecontentType
andbody
fields.
The create
method returns the UptimeCheckConfig
object for the new configuration.
If the created uptime configuration doesn't work as expected, see the Check failures section on this page.
C#
Java
Go
Node.js
PHP
Python
Ruby
There can be a delay of up to 5 minutes before the uptime check results start to flow into Monitoring. During that time, the uptime check dashboard reports the status as "no data available."
Identifiers for uptime checks
When your uptime check is created, Monitoring assigns it an identifier, referred to as the uptime-check ID. This identifier is embedded in the resource name for the new uptime check:
projects/PROJECT_ID/uptimeCheckConfigs/UPTIME_CHECK_ID
You can get the uptime-check ID from the response of a method invocation to create or list uptime checks. You can also find the uptime-check ID on the Uptime details window under the section titled Configuration.
Verify your uptime check
When you create an uptime check in the Cloud Console, you can test the configuration before saving.
Check success
An uptime check is successful if two conditions are true:
- The HTTP status is
Success
. - The response has no required content or, a search of the response for the required content is successful.
Check failure
The following are some possible causes of an uptime check failure:
- Connection Error - Refused: If you are using the default HTTP connection type, check that you have a web server installed that is responding to HTTP requests. This can happen on a new instance if you haven't installed a web server; see the Quickstart for Compute Engine. If you use an HTTPS connection type, you might have to perform additional configuration steps. For firewall issues, see Getting IP addresses.
- Name or service not found: The host name might be incorrect.
- 403 Forbidden: The service is returning an error code to the uptime checker. For example, the default Apache web server configuration returns this code under Amazon Linux, but it returns code 200 (Success) under some other Linux versions. See the LAMP tutorial for Amazon Linux or your web server's documentation.
- 404 Not found: The path might be incorrect.
- 408 Request timeout, or no response: The port number might be incorrect, the service might not be running, the service might be inaccessible, or the timeout might be too low. Check that your firewall allows traffic from the uptime servers; see Getting IP addresses. The timeout limit is specified as part of the Response Validation options.
Viewing an uptime check
To view an uptime check, do the following:
Console
To view the detailed status of a single uptime check, do the following:
In the Cloud Console, select Monitoring:
Click Uptime checks.
To view the Uptime details window, locate the uptime check that you want to view, then click the uptime check name.
The following screenshot shows the uptime details for an uptime check with the name "My Uptime Check":
The Uptime details window contains the following information:
- The selected time interval. By default, the interval is 1 hour.
- The name of the uptime check. In the sample, the name is My Uptime Check.
The uptime percentage and the average latency. The Percent uptime value is a percentage calculated as
(S/T)*100
, whereS
is the number of successful check responses andT
is the total number of check responses, from all locations. For group checks, the values ofS
andT
are summed across all current group members.For example, over a 25-minute period, an uptime check with a one-minute period running from all regions would get 25 requests from each of 6 locations, for a total of 150 requests. If the dashboard reports an 83.3% uptime, then 125 of 150 requests succeeded.
The Passed checks and Uptime check latency panes graphically display the number of passed checks and latency of each check as a function of time.
The Current status pane displays the status of the most recent checks. A green circle with a check next to a region indicates the last run of the check in that region succeeded; a red circle with an x indicates failure.
The Configuration pane shows the configuration of the uptime check. This data is assigned when the uptime check is created. The Check Id value corresponds to the
UPTIME_CHECK_ID
value in API calls.The Alert Policies pane lists information about associated alert policies. In the sample dashboard, one alert policy is configured.
C#
Java
Go
Node.js
PHP
Python
Ruby
Editing an uptime check
The uptime check protocol, resource type, and the resource being monitored cannot be changed. If you want to modify these fields, you must create an uptime check with the proper configuration. However, all other fields in an uptime check can be modified after the check is created.
To edit an alerting policy that is associated with an uptime check, in the Monitoring navigation pane, click notifications Alerting, select the policy to be edited, and click Edit.
To edit an uptime check, do the following:
Console
In the Cloud Console, select Monitoring:
Click Uptime checks.
Locate the uptime check that you want to edit, then do one of the following:
- Click More more_vert and select Edit.
- View the uptime check details, and then click Edit.
Change the values of the fields as needed. You can't modify all fields. If the custom header values of a check are hidden, you cannot make them viewable.
To verify if the check works, click Test. If the test fails, see Check failures for possible causes.
Click Save.
API
Call the
projects.uptimeCheckConfigs.patch
method. Set the parameters to the method as follows:
uptimeCheckConfig.name: Required. This is part of the REST URL. It is the resource name of the uptime check to edit:
projects/PROJECT_ID/uptimeCheckConfigs/UPTIME_CHECK_ID
You can get the UPTIME_CHECK_ID from the response of a
create
orlist
method. The ID isn't shown in the Cloud Console.updateMask: Optional. This is a query parameter:
?updateMask=[FIELD_LIST]
.[FIELD_LIST]
is a comma-separated list of fields in theUptimeCheckConfig
object that should be changed. For example:"resource.type,httpCheck.path"
The request body must contain an
UptimeCheckConfig
with the new field values.
If updateMask
is set, then only the fields listed in updateMask
replace
the corresponding fields in the existing configuration. If a field has
subfields, and the field is listed in the field mask but none of its subfields
are, then all subfields of that field replace the corresponding fields.
If updateMask
isn't set, then the configuration in the request body
replaces the entire existing configuration.
The patch
method returns the
UptimeCheckConfig
object for the altered configuration.
C#
Java
Go
Node.js
PHP
Python
Ruby
There can be a delay of up to 5 minutes before you see the new uptime check results. During that time, the results of the former uptime check are displayed in the dashboards and used in alerting policies.
Deleting an uptime check
If you attempt to delete an uptime check by using the Cloud Console, and there exists an alerting policy that depends on the uptime check, the delete operation fails. Retry the delete after you have removed the uptime check from all alerting policies that use the check.
If you attempt to delete an uptime check by using the Cloud Monitoring API, the uptime check is deleted even if there are alerting policies that depend upon the check. No error is generated. No incident is created for the missing check. Before you delete an uptime check, ensure that there are no alerting polcies that depend upon this check.
To delete an uptime check, do the following:
Console
In the Cloud Console, select Monitoring:
Click Uptime checks.
Locate the uptime check that you want to edit, then do one of the following:
- Click More more_vert and select Delete.
- View the uptime check details, and then click Delete delete
API
Call the
projects.uptimeCheckConfigs.delete
method. Fill out the parameter as follows:
name: Required. This is the resource name of the uptime check configuration to delete:
projects/PROJECT_ID/uptimeCheckConfigs/UPTIME_CHECK_ID
You can get the UPTIME_CHECK_ID from the response of a
create
orlist
method. The ID isn't shown in the Cloud Console.
C#
Java
Go
Node.js
PHP
Python
Ruby
What's next
- To view pricing and limits on uptime checks, see Pricing and limits.
- To view a list of all uptime checks, see Reviewing uptime checks.
- To get a list of the IP addresses that might be used to perform uptime checks, see Getting IP addresses.
- To determine the status of your uptime checks using the API, monitor the
metric
monitoring.googleapis.com/uptime_check/check_passed
. See Google Cloud metrics list for details.