Reviewing uptime checks

Using the Google Cloud Console

This page shows you how to do the following:

  • List all of your uptime checks.
  • Get a list of IP addresses used by uptime checks.

To create, update, and delete your uptime checks, see the Managing Uptime Checks page. To view pricing and limits on uptime checks, see Pricing and limits.

Listing uptime checks

Console

To list your current uptime checks, do the following:

  1. In the Cloud Console, select Monitoring:

    Go to Monitoring

  2. Select Uptime checks.

To view the details of an uptime check, click on its name.

To restrict the uptime checks that are listed, add filters. Each filter is composed of a name and a value. You can set the value to be an exact match for an uptime check name, or a partial match. Matches are not case sensitive. For example, to list all uptime checks whose name contains default, do the following:

  • Click Filter table and select Display name.
  • Enter default and then hit the return key.

If you have multiple filters, then the filters are automatically joined by a logical AND unless you insert an OR filter. In the following example,the OR filter is used so that an uptime check is listed if its name matches default or testing check:

Sample uptime checks overview with filters.

API

To get a list of your uptime configurations, call the projects.uptimeCheckConfigs.list method. Specify the following parameters:

  • parent: The project whose uptime checks you want to list. The format is:

    projects/[PROJECT_ID]
    

To get a specific uptime check, call the projects.uptimeCheckConfigs.get method. Specify the following parameter:

  • name: The full name of the uptime check configuration.

    projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]
    

    You can get the [UPTIME_CHECK_ID] from the response of a create or list method. The ID isn't shown in the Stackdriver Monitoring console.

C#

public static object ListUptimeCheckConfigs(string projectId)
{
    var client = UptimeCheckServiceClient.Create();
    var configs = client.ListUptimeCheckConfigs(
        new ProjectName(projectId).ToString());
    foreach (UptimeCheckConfig config in configs)
    {
        Console.WriteLine(config.Name);
    }
    return 0;
}

Java

private static void listUptimeChecks(String projectId) throws IOException {
  ListUptimeCheckConfigsRequest request = ListUptimeCheckConfigsRequest
      .newBuilder()
      .setParent(ProjectName.format(projectId))
      .build();
  try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {
    ListUptimeCheckConfigsPagedResponse response = client.listUptimeCheckConfigs(request);
    for (UptimeCheckConfig config : response.iterateAll()) {
      System.out.println(config.getDisplayName());
    }
  } catch (Exception e) {
    usage("Exception listing uptime checks: " + e.toString());
    throw e;
  }
}

Go


// list is an example of listing the uptime checks in projectID.
func list(w io.Writer, projectID string) error {
	ctx := context.Background()
	client, err := monitoring.NewUptimeCheckClient(ctx)
	if err != nil {
		return fmt.Errorf("NewUptimeCheckClient: %v", err)
	}
	defer client.Close()
	req := &monitoringpb.ListUptimeCheckConfigsRequest{
		Parent: "projects/" + projectID,
	}
	it := client.ListUptimeCheckConfigs(ctx, req)
	for {
		config, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListUptimeCheckConfigs: %v", err)
		}
		fmt.Fprintln(w, config)
	}
	fmt.Fprintln(w, "Done listing uptime checks")
	return nil
}

Node.js

// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');

// Creates a client
const client = new monitoring.UptimeCheckServiceClient();

/**
 * TODO(developer): Uncomment and edit the following lines of code.
 */
// const projectId = 'YOUR_PROJECT_ID';

const request = {
  parent: client.projectPath(projectId),
};

// Retrieves an uptime check config
const [uptimeCheckConfigs] = await client.listUptimeCheckConfigs(request);

uptimeCheckConfigs.forEach(uptimeCheckConfig => {
  console.log(`ID: ${uptimeCheckConfig.name}`);
  console.log(`  Display Name: ${uptimeCheckConfig.displayName}`);
  console.log(`  Resource: %j`, uptimeCheckConfig.monitoredResource);
  console.log(`  Period: %j`, uptimeCheckConfig.period);
  console.log(`  Timeout: %j`, uptimeCheckConfig.timeout);
  console.log(`  Check type: ${uptimeCheckConfig.check_request_type}`);
  console.log(
    `  Check: %j`,
    uptimeCheckConfig.httpCheck || uptimeCheckConfig.tcpCheck
  );
  console.log(
    `  Content matchers: ${uptimeCheckConfig.contentMatchers
      .map(matcher => matcher.content)
      .join(', ')}`
  );
  console.log(`  Regions: ${uptimeCheckConfig.selectedRegions.join(', ')}`);
});

PHP

use Google\Cloud\Monitoring\V3\UptimeCheckServiceClient;

/**
 * Example:
 * ```
 * list_uptime_checks($projectId);
 * ```
 */
function list_uptime_checks($projectId)
{
    $uptimeCheckClient = new UptimeCheckServiceClient([
        'projectId' => $projectId,
    ]);

    $pages = $uptimeCheckClient->listUptimeCheckConfigs(
        $uptimeCheckClient->projectName($projectId)
    );

    foreach ($pages->iteratePages() as $page) {
        foreach ($page as $uptimeCheck) {
            print($uptimeCheck->getName() . PHP_EOL);
        }
    }
}

Python

def list_uptime_check_configs(project_name):
    client = monitoring_v3.UptimeCheckServiceClient()
    configs = client.list_uptime_check_configs(project_name)

    for config in configs:
        pprint.pprint(config)

Ruby

def list_uptime_check_configs project_id
  require "google/cloud/monitoring/v3"

  client = Google::Cloud::Monitoring::V3::UptimeCheck.new
  project_name = Google::Cloud::Monitoring::V3::UptimeCheckServiceClient.project_path project_id
  configs = client.list_uptime_check_configs project_name

  configs.each { |config| puts config.name }
end

Getting uptime-check IP addresses

If you are checking a service that is behind a firewall, you can configure your service's firewall to accept traffic from the current set of IP addresses used for uptime checking. To get the IP addresses, use the following instructions:

Console

  1. In the Cloud Console, select Monitoring:

    Go to Monitoring

  2. Select Uptime checks.

  3. Click Download Source IPs .

API

  1. Call the uptimeCheckIps.list method of the Monitoring API.

  2. The method returns the following information for each IP address:

    • The region: USA, EUROPE, SOUTH_AMERICA, or ASIA_PACIFIC.
    • A more specific location within the region.
    • The IP address, not a range, in IPv4 or IPv6 format.

C#

public static object ListUptimeCheckIps()
{
    var client = UptimeCheckServiceClient.Create();
    var ips = client.ListUptimeCheckIps(new ListUptimeCheckIpsRequest());
    foreach (UptimeCheckIp ip in ips)
    {
        Console.WriteLine("{0,20} {1}", ip.IpAddress, ip.Location);
    }
    return 0;
}

Java

private static void listUptimeCheckIPs() throws IOException {
  try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {
    ListUptimeCheckIpsPagedResponse response =
        client.listUptimeCheckIps(ListUptimeCheckIpsRequest.newBuilder().build());
    for (UptimeCheckIp config : response.iterateAll()) {
      System.out.println(config.getRegion() + " - " + config.getIpAddress());
    }
  } catch (Exception e) {
    usage("Exception listing uptime IPs: " + e.toString());
    throw e;
  }
}

Go


// listIPs is an example of listing uptime check IPs.
func listIPs(w io.Writer) error {
	ctx := context.Background()
	client, err := monitoring.NewUptimeCheckClient(ctx)
	if err != nil {
		return fmt.Errorf("NewUptimeCheckClient: %v", err)
	}
	defer client.Close()
	req := &monitoringpb.ListUptimeCheckIpsRequest{}
	it := client.ListUptimeCheckIps(ctx, req)
	for {
		config, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListUptimeCheckIps: %v", err)
		}
		fmt.Fprintln(w, config)
	}
	fmt.Fprintln(w, "Done listing uptime check IPs")
	return nil
}

Node.js

// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');

// Creates a client
const client = new monitoring.UptimeCheckServiceClient();

// List uptime check IPs
const [uptimeCheckIps] = await client.listUptimeCheckIps();
uptimeCheckIps.forEach(uptimeCheckIp => {
  console.log(
    uptimeCheckIp.region,
    uptimeCheckIp.location,
    uptimeCheckIp.ipAddress
  );
});

PHP

use Google\Cloud\Monitoring\V3\UptimeCheckServiceClient;

/**
 * Example:
 * ```
 * list_uptime_check_ips($projectId);
 * ```
 */
function list_uptime_check_ips($projectId)
{
    $uptimeCheckClient = new UptimeCheckServiceClient([
        'projectId' => $projectId,
    ]);

    $pages = $uptimeCheckClient->listUptimeCheckIps();

    foreach ($pages->iteratePages() as $page) {
        $ips = $page->getResponseObject()->getUptimeCheckIps();
        foreach ($ips as $ip) {
            printf(
                'ip address: %s, region: %s, location: %s' . PHP_EOL,
                $ip->getIpAddress(),
                $ip->getRegion(),
                $ip->getLocation()
            );
        }
    }
}

Python

def list_uptime_check_ips():
    client = monitoring_v3.UptimeCheckServiceClient()
    ips = client.list_uptime_check_ips()
    print(tabulate.tabulate(
        [(ip.region, ip.location, ip.ip_address) for ip in ips],
        ('region', 'location', 'ip_address')
    ))

Ruby

def list_ips
  require "google/cloud/monitoring/v3"
  client = Google::Cloud::Monitoring::V3::UptimeCheck.new

  # Iterate over all results.
  client.list_uptime_check_ips.each do |element|
    puts "#{element.location} #{element.ip_address}"
  end
end

Uptime checks can come from any of the IP addresses, but only one address from each geographic location is used for each time interval. The geographic locations are listed in the uptime checks dashboard, as shown in the previous section. You can also use free, web-based services to identify the registered locations of the IP addresses you downloaded.

The IP addresses used by uptime checking might change, but typically not more than once per quarter and not without an announcement.

Identifying uptime-check traffic

You can identify requests from the uptime-check servers by the following information in your service's request logs:

  • ip: The ip field contains one of the addresses used by the uptime-check servers. See Getting IP addresses.
  • User-Agent: The User-Agent header value is always the following:

    GoogleStackdriverMonitoring-UptimeChecks(https://cloud.google.com/monitoring)
    

    Specifying a User-Agent custom header results in a form validation error and prevents the check configuration from being saved.

Using the Stackdriver Monitoring console

This page shows you how to do the following:

  • Review the status of your uptime checks.
  • Get a list of IP addresses used by uptime checks.

To create, update, and delete your uptime checks, see the Managing Uptime Checks page. You can have up to 100 uptime checks per Workspace.

Uptime check overview

Monitoring has an overview page that displays all your uptime checks, and detailed dashboards for individual checks.

To see the overview, do the following:

  1. In the Cloud Console, select Monitoring:

    Go to Monitoring

  2. Select Uptime Checks, and then select Uptime Checks Overview.

For each uptime check, you can see the last check result from each location, as shown in the following screenshot:

Uptime checks monitor

Dashboards

To get the detailed status of a single uptime check, click on any of the checks in the overview or in the list in the Uptime Checks menu. The following is a sample dashboard:

Uptime check details

The Location results region shows the results of the uptime check in all the applicable regions. A green dot next to a region indicates the last run of the check in that region succeeded; a red dot indicates failure. Moving your mouse over the dot displays the latency of the last run as well as the HTTP response code if applicable.

The Check config region includes a description of the uptime check, including the Check ID. This ID is assigned when the uptime check is created. The value corresponds to the [UPTIME_CHECK_ID] value in API calls.

API

To retrieve your existing uptime check configurations, use projects.uptimeCheckConfigs.list.

In the API, uptime checks are identified by their [UPTIME_CHECK_ID], which is a respelling of the uptime check's display name. For example, the display name "my uptime check" might become the ID "my-uptime-check", or the mapping might be more complicated.

You assign the display name that you see in the Uptime Overview in the Stackdriver Monitoring console.

Uptime percentage

The Uptime value is a percentage calculated as (S/T)*100, where S is the number of successful check responses and T is the total number of check responses, from all locations.

For group checks, the values of S and T 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, that means 25 of 150 requests failed.

Getting uptime-check IP addresses

If you are checking a service that is behind a firewall, you can configure your service's firewall to accept traffic from the current set of IP addresses used for uptime checking. To get the IP addresses, use the following instructions:

Console

  1. In the Cloud Console, select Monitoring:

    Go to Monitoring

  2. Select Uptime Checks, and then select Uptime Checks Overview.

  3. Click Download Source IPs .

API

  1. Call the uptimeCheckIps.list method of the Monitoring API.

  2. The method returns the following information for each IP address:

    • The region: USA, EUROPE, SOUTH_AMERICA, or ASIA_PACIFIC.
    • A more specific location within the region.
    • The IP address, not a range, in IPv4 or IPv6 format.

C#

public static object ListUptimeCheckIps()
{
    var client = UptimeCheckServiceClient.Create();
    var ips = client.ListUptimeCheckIps(new ListUptimeCheckIpsRequest());
    foreach (UptimeCheckIp ip in ips)
    {
        Console.WriteLine("{0,20} {1}", ip.IpAddress, ip.Location);
    }
    return 0;
}

Java

private static void listUptimeCheckIPs() throws IOException {
  try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {
    ListUptimeCheckIpsPagedResponse response =
        client.listUptimeCheckIps(ListUptimeCheckIpsRequest.newBuilder().build());
    for (UptimeCheckIp config : response.iterateAll()) {
      System.out.println(config.getRegion() + " - " + config.getIpAddress());
    }
  } catch (Exception e) {
    usage("Exception listing uptime IPs: " + e.toString());
    throw e;
  }
}

Go


// listIPs is an example of listing uptime check IPs.
func listIPs(w io.Writer) error {
	ctx := context.Background()
	client, err := monitoring.NewUptimeCheckClient(ctx)
	if err != nil {
		return fmt.Errorf("NewUptimeCheckClient: %v", err)
	}
	defer client.Close()
	req := &monitoringpb.ListUptimeCheckIpsRequest{}
	it := client.ListUptimeCheckIps(ctx, req)
	for {
		config, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("ListUptimeCheckIps: %v", err)
		}
		fmt.Fprintln(w, config)
	}
	fmt.Fprintln(w, "Done listing uptime check IPs")
	return nil
}

Node.js

// Imports the Google Cloud client library
const monitoring = require('@google-cloud/monitoring');

// Creates a client
const client = new monitoring.UptimeCheckServiceClient();

// List uptime check IPs
const [uptimeCheckIps] = await client.listUptimeCheckIps();
uptimeCheckIps.forEach(uptimeCheckIp => {
  console.log(
    uptimeCheckIp.region,
    uptimeCheckIp.location,
    uptimeCheckIp.ipAddress
  );
});

PHP

use Google\Cloud\Monitoring\V3\UptimeCheckServiceClient;

/**
 * Example:
 * ```
 * list_uptime_check_ips($projectId);
 * ```
 */
function list_uptime_check_ips($projectId)
{
    $uptimeCheckClient = new UptimeCheckServiceClient([
        'projectId' => $projectId,
    ]);

    $pages = $uptimeCheckClient->listUptimeCheckIps();

    foreach ($pages->iteratePages() as $page) {
        $ips = $page->getResponseObject()->getUptimeCheckIps();
        foreach ($ips as $ip) {
            printf(
                'ip address: %s, region: %s, location: %s' . PHP_EOL,
                $ip->getIpAddress(),
                $ip->getRegion(),
                $ip->getLocation()
            );
        }
    }
}

Python

def list_uptime_check_ips():
    client = monitoring_v3.UptimeCheckServiceClient()
    ips = client.list_uptime_check_ips()
    print(tabulate.tabulate(
        [(ip.region, ip.location, ip.ip_address) for ip in ips],
        ('region', 'location', 'ip_address')
    ))

Ruby

def list_ips
  require "google/cloud/monitoring/v3"
  client = Google::Cloud::Monitoring::V3::UptimeCheck.new

  # Iterate over all results.
  client.list_uptime_check_ips.each do |element|
    puts "#{element.location} #{element.ip_address}"
  end
end

Uptime checks can come from any of the IP addresses, but only one address from each geographic location is used for each time interval. The geographic locations are listed in the uptime checks dashboard, as shown in the previous section. You can also use free, web-based services to identify the registered locations of the IP addresses you downloaded.

The IP addresses used by uptime checking might change, but typically not more than once per quarter and not without an announcement.

Identifying uptime check traffic

You can identify requests from the uptime-check servers by the following information in your service's request logs:

  • ip: The ip field contains one of the addresses used by the uptime-check servers. See Getting IP addresses.
  • User-Agent: The User-Agent header value is always the following:

    GoogleStackdriverMonitoring-UptimeChecks(https://cloud.google.com/monitoring)
    

    Specifying a User-Agent custom header results in a form validation error and prevents the check configuration from being saved.

Czy ta strona była pomocna? Podziel się z nami swoją opinią:

Wyślij opinię na temat...

Stackdriver Monitoring