稼働時間チェックを一覧表示する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
稼働時間チェックの構成を一覧表示する方法を示します。
もっと見る
このコードサンプルを含む詳細なドキュメントについては、以下をご覧ください。
コードサンプル
C#
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
Go
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
Java
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
Node.js
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
PHP
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
Python
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
Ruby
Monitoring で認証を行うには、アプリケーションのデフォルト認証情報を設定します。詳細については、ローカル開発環境の認証の設定をご覧ください。
特に記載のない限り、このページのコンテンツはクリエイティブ・コモンズの表示 4.0 ライセンスにより使用許諾されます。コードサンプルは Apache 2.0 ライセンスにより使用許諾されます。詳しくは、Google Developers サイトのポリシーをご覧ください。Java は Oracle および関連会社の登録商標です。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["わかりにくい","hardToUnderstand","thumb-down"],["情報またはサンプルコードが不正確","incorrectInformationOrSampleCode","thumb-down"],["必要な情報 / サンプルがない","missingTheInformationSamplesINeed","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["その他","otherDown","thumb-down"]],[],[],[],null,["Demonstrates how to list uptime check configs.\n\nExplore further\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Manage uptime checks](/monitoring/uptime-checks/manage)\n\nCode sample \n\nC#\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 ListUptimeCheckConfigs(string projectId)\n {\n var client = UptimeCheckServiceClient.Create();\n var configs = client.ListUptimeCheckConfigs(new ProjectName(projectId));\n foreach (UptimeCheckConfig config in configs)\n {\n Console.WriteLine(config.Name);\n }\n return 0;\n }\n\nGo\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 // list is an example of listing the uptime checks in projectID.\n func list(w io.Writer, projectID string) 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.ListUptimeCheckConfigsRequest{\n \t\tParent: \"projects/\" + projectID,\n \t}\n \tit := client.ListUptimeCheckConfigs(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(\"ListUptimeCheckConfigs: %w\", err)\n \t\t}\n \t\tfmt.Fprintln(w, config)\n \t}\n \tfmt.Fprintln(w, \"Done listing uptime checks\")\n \treturn nil\n }\n\nJava\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 listUptimeChecks(String projectId) throws IOException {\n ListUptimeCheckConfigsRequest request =\n ListUptimeCheckConfigsRequest.newBuilder().setParent(ProjectName.format(projectId)).build();\n try (UptimeCheckServiceClient client = UptimeCheckServiceClient.create()) {\n ListUptimeCheckConfigsPagedResponse response = client.listUptimeCheckConfigs(request);\n for (UptimeCheckConfig config : response.iterateAll()) {\n System.out.println(config.getDisplayName());\n }\n } catch (Exception e) {\n usage(\"Exception listing uptime checks: \" + e.toString());\n throw e;\n }\n }\n\nNode.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 /**\n * TODO(developer): Uncomment and edit the following lines of code.\n */\n // const projectId = 'YOUR_PROJECT_ID';\n\n const request = {\n parent: client.projectPath(projectId),\n };\n\n // Retrieves an uptime check config\n const [uptimeCheckConfigs] = await client.listUptimeCheckConfigs(request);\n\n uptimeCheckConfigs.forEach(uptimeCheckConfig =\u003e {\n console.log(`ID: ${uptimeCheckConfig.name}`);\n console.log(` Display Name: ${uptimeCheckConfig.displayName}`);\n console.log(' Resource: %j', uptimeCheckConfig.monitoredResource);\n console.log(' Period: %j', uptimeCheckConfig.period);\n console.log(' Timeout: %j', uptimeCheckConfig.timeout);\n console.log(` Check type: ${uptimeCheckConfig.check_request_type}`);\n console.log(\n ' Check: %j',\n uptimeCheckConfig.httpCheck || uptimeCheckConfig.tcpCheck\n );\n console.log(\n ` Content matchers: ${uptimeCheckConfig.contentMatchers\n .map(matcher =\u003e matcher.content)\n .join(', ')}`\n );\n console.log(` Regions: ${uptimeCheckConfig.selectedRegions.join(', ')}`);\n });\n\nPHP\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\\ListUptimeCheckConfigsRequest;\n\n /**\n * Example:\n * ```\n * list_uptime_checks($projectId);\n * ```\n */\n function list_uptime_checks(string $projectId): void\n {\n $projectName = 'projects/' . $projectId;\n $uptimeCheckClient = new UptimeCheckServiceClient([\n 'projectId' =\u003e $projectId,\n ]);\n $listUptimeCheckConfigsRequest = (new ListUptimeCheckConfigsRequest())\n -\u003esetParent($projectName);\n\n $pages = $uptimeCheckClient-\u003elistUptimeCheckConfigs($listUptimeCheckConfigsRequest);\n\n foreach ($pages-\u003eiteratePages() as $page) {\n foreach ($page as $uptimeCheck) {\n print($uptimeCheck-\u003egetName() . PHP_EOL);\n }\n }\n }\n\nPython\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_configs(project_id: str) -\u003e pagers.ListUptimeCheckConfigsPager:\n \"\"\"Gets all uptime checks defined in the Google Cloud project\n\n Args:\n project_id: Google Cloud project id\n\n Returns:\n A list of configurations.\n Iterating over this object will yield results and resolve additional pages automatically.\n \"\"\"\n client = monitoring_v3.UptimeCheckServiceClient()\n configs = client.list_uptime_check_configs(request={\"parent\": project_id})\n\n for config in configs:\n pprint.pprint(config)\n return configs\n\nRuby\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_uptime_check_configs project_id\n client = Google::Cloud::https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring/latest/Google-Cloud-Monitoring.html.https://cloud.google.com/ruby/docs/reference/google-cloud-monitoring/latest/Google-Cloud-Monitoring.html\n project_name = client.project_path project: project_id\n configs = client.list_uptime_check_configs parent: project_name\n\n configs.each { |config| puts config.name }\n end\n\nWhat's next\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=monitoring)."]]