// listIPs is an example of listing uptime check IPs.funclistIPs(wio.Writer)error{ctx:=context.Background()client,err:=monitoring.NewUptimeCheckClient(ctx)iferr!=nil{returnfmt.Errorf("NewUptimeCheckClient: %w",err)}deferclient.Close()req:=&monitoringpb.ListUptimeCheckIpsRequest{}it:=client.ListUptimeCheckIps(ctx,req)for{config,err:=it.Next()iferr==iterator.Done{break}iferr!=nil{returnfmt.Errorf("ListUptimeCheckIps: %w",err)}fmt.Fprintln(w,config)}fmt.Fprintln(w,"Done listing uptime check IPs")returnnil}
// Imports the Google Cloud client libraryconstmonitoring=require('@google-cloud/monitoring');// Creates a clientconstclient=newmonitoring.UptimeCheckServiceClient();// List uptime check IPsconst[uptimeCheckIps]=awaitclient.listUptimeCheckIps();uptimeCheckIps.forEach(uptimeCheckIp=>{console.log(uptimeCheckIp.region,uptimeCheckIp.location,uptimeCheckIp.ipAddress);});
deflist_uptime_check_ips()-> pagers.ListUptimeCheckIpsPager:"""Gets all locations and IP addresses used by uptime check servers Returns: A list of locations and IP addresses of uptime check servers. Iterating over this object will yield results and resolve additional pages automatically. """client=monitoring_v3.UptimeCheckServiceClient()ips=client.list_uptime_check_ips(request={})print(tabulate.tabulate([(ip.region,ip.location,ip.ip_address)foripinips],("region","location","ip_address"),))returnips
gem"google-cloud-monitoring"require"google/cloud/monitoring"deflist_ipsclient=Google::Cloud::Monitoring.uptime_check_service# Iterate over all results.client.list_uptime_check_ips({}).eachdo|element|puts"#{element.location}#{element.ip_address}"endend
正常运行时间检查可能来自其中的任一个 IP 地址,但对于每个时间间隔,每个地理位置上仅会用到一个地址。拨测信息中心中列出了地理位置(如上一部分中所示)。您还可以使用基于网络的免费服务来确定您下载的 IP 地址的注册位置。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-07-31。"],[],[],null,["# List uptime-check server IP addresses\n\nThis document shows you how to get a list of IP addresses used by uptime-check\nservers, and how you can identify traffic from the uptime-check servers in\nyour logs.\n\nList IP addresses\n-----------------\n\nWhen you're checking a service that is behind a firewall, you can configure your\nservice's firewall to accept traffic from the current set of IP addresses used\nfor uptime checking. To get these IP addresses, use the following instructions: \n\n### Console\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. In the toolbar of the Google Cloud console, select your Google Cloud project. For [App Hub](/app-hub/docs/overview) configurations, select the App Hub host project or the app-enabled folder's management project.\n3. In the **Uptime checks** menu, click *get_app* **Download** . A file `uptime-source-ips.txt` is downloaded and contains the IP addresses.\n\n### gcloud\n\nRun the [`gcloud monitoring uptime list-ips`](/sdk/gcloud/reference/monitoring/uptime/list-ips) command: \n\n gcloud monitoring uptime list-ips\n\nThe method returns the following information for each IP address:\n\n- The IP address, not a range, in IPv4 or IPv6 format.\n- The region: `USA`, `EUROPE`, `SOUTH_AMERICA`, or `ASIA_PACIFIC`.\n- The location within the region.\n\n### API\n\nCall the\n[`uptimeCheckIps.list`](/monitoring/api/ref_v3/rest/v3/uptimeCheckIps/list)\nmethod of the Monitoring API.\n\nThe method returns the following information for each IP address:\n\n- The region: `USA`, `EUROPE`, `SOUTH_AMERICA`, or `ASIA_PACIFIC`.\n- A more specific location within the region.\n- The IP address, not a range, in IPv4 or IPv6 format.\n\n### C#\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n public static object ListUptimeCheckIps()\n {\n var client = UptimeCheckServiceClient.Create();\n var ips = client.ListUptimeCheckIps(new ListUptimeCheckIpsRequest());\n foreach (UptimeCheckIp ip in ips)\n {\n Console.WriteLine(\"{0,20} {1}\", ip.IpAddress, ip.Location);\n }\n return 0;\n }\n\n### Java\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n private static void listUptimeCheckIps() throws IOException {\n try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {\n ListUptimeCheckIpsPagedResponse response =\n client.listUptimeCheckIps(ListUptimeCheckIpsRequest.newBuilder().build());\n for (UptimeCheckIp config : response.iterateAll()) {\n System.out.println(config.getRegion() + \" - \" + config.getIpAddress());\n }\n } catch (Exception e) {\n usage(\"Exception listing uptime IPs: \" + e.toString());\n throw e;\n }\n }\n\n### Go\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n\n // listIPs is an example of listing uptime check IPs.\n func listIPs(w io.Writer) error {\n \tctx := context.Background()\n \tclient, err := monitoring.NewUptimeCheckClient(ctx)\n \tif err != nil {\n \t\treturn fmt.Errorf(\"NewUptimeCheckClient: %w\", err)\n \t}\n \tdefer client.Close()\n \treq := &monitoringpb.ListUptimeCheckIpsRequest{}\n \tit := client.ListUptimeCheckIps(ctx, req)\n \tfor {\n \t\tconfig, err := it.Next()\n \t\tif err == iterator.Done {\n \t\t\tbreak\n \t\t}\n \t\tif err != nil {\n \t\t\treturn fmt.Errorf(\"ListUptimeCheckIps: %w\", err)\n \t\t}\n \t\tfmt.Fprintln(w, config)\n \t}\n \tfmt.Fprintln(w, \"Done listing uptime check IPs\")\n \treturn nil\n }\n\n### Node.js\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n // Imports the Google Cloud client library\n const monitoring = require('https://cloud.google.com/nodejs/docs/reference/monitoring/latest/overview.html');\n\n // Creates a client\n const client = new monitoring.https://cloud.google.com/nodejs/docs/reference/monitoring/latest/overview.html();\n\n // List uptime check IPs\n const [uptimeCheckIps] = await client.listUptimeCheckIps();\n uptimeCheckIps.forEach(uptimeCheckIp =\u003e {\n console.log(\n uptimeCheckIp.region,\n uptimeCheckIp.location,\n uptimeCheckIp.ipAddress\n );\n });\n\n### PHP\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n use Google\\Cloud\\Monitoring\\V3\\Client\\UptimeCheckServiceClient;\n use Google\\Cloud\\Monitoring\\V3\\ListUptimeCheckIpsRequest;\n\n /**\n * Example:\n * ```\n * list_uptime_check_ips($projectId);\n * ```\n */\n function list_uptime_check_ips(string $projectId): void\n {\n $uptimeCheckClient = new UptimeCheckServiceClient([\n 'projectId' =\u003e $projectId,\n ]);\n $listUptimeCheckIpsRequest = new ListUptimeCheckIpsRequest();\n\n $pages = $uptimeCheckClient-\u003elistUptimeCheckIps($listUptimeCheckIpsRequest);\n\n foreach ($pages-\u003eiteratePages() as $page) {\n $ips = $page-\u003egetResponseObject()-\u003egetUptimeCheckIps();\n foreach ($ips as $ip) {\n printf(\n 'ip address: %s, region: %s, location: %s' . PHP_EOL,\n $ip-\u003egetIpAddress(),\n $ip-\u003egetRegion(),\n $ip-\u003egetLocation()\n );\n }\n }\n }\n\n### Python\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n def list_uptime_check_ips() -\u003e pagers.ListUptimeCheckIpsPager:\n \"\"\"Gets all locations and IP addresses used by uptime check servers\n\n Returns:\n A list of locations and IP addresses of uptime check servers.\n Iterating over this object will yield results and resolve additional pages automatically.\n \"\"\"\n client = monitoring_v3.UptimeCheckServiceClient()\n ips = client.list_uptime_check_ips(request={})\n print(\n tabulate.tabulate(\n [(ip.region, ip.location, ip.ip_address) for ip in ips],\n (\"region\", \"location\", \"ip_address\"),\n )\n )\n return ips\n\n### Ruby\n\n\nTo authenticate to Monitoring, set up Application Default Credentials.\nFor more information, see\n\n[Set up authentication for a local development environment](/docs/authentication/set-up-adc-local-dev-environment).\n\n gem \"google-cloud-monitoring\"\n require \"google/cloud/monitoring\"\n\n def list_ips\n client = Google::Cloud::https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring-dashboard-v1/latest/Google-Cloud-Monitoring.html.https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring/latest/Google-Cloud-Monitoring.html\n\n # Iterate over all results.\n client.list_uptime_check_ips({}).each do |element|\n puts \"#{element.location} #{element.https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring-v3/latest/Google-Cloud-Monitoring-V3-UptimeCheckIp.html}\"\n end\n end\n\n\u003cbr /\u003e\n\nUptime checks can come from any of the IP addresses, but only one address from\neach geographic location is used for each time interval. The geographic\nlocations are listed in the uptime checks dashboard, as shown in the previous\nsection. You can also use free, web-based services to identify the registered\nlocations of the IP addresses you downloaded.\n\nIdentify uptime-check traffic in logs\n-------------------------------------\n\nYou can identify requests from the uptime-check servers by the following\ninformation in your service's [request logs](/logging/docs/view/logs-explorer-interface):\n\n- **ip** : The `ip` field contains one of the addresses used by the uptime-check servers. For information about how to list all IP addresses, see [List IP addresses](#get-ips).\n- **User-Agent** : The `User-Agent` header value is always the following:\n\n GoogleStackdriverMonitoring-UptimeChecks(https://cloud.google.com/monitoring)\n\n Specifying a `User-Agent` custom header results in a form validation error\n and prevents the check configuration from being saved.\n\nWhat's next\n-----------\n\n- [Manage uptime checks](/monitoring/uptime-checks/manage)\n- [Create alerting policies for uptime checks](/monitoring/uptime-checks/uptime-alerting-policies)\n- [Chart uptime-check metrics](/monitoring/charts/uptime-charts)"]]