列出 CloudWatch 控制面板
以下代码示例展示如何列出 Amazon CloudWatch 控制面板。
- .NET
-
- Amazon SDK for .NET
-
注意
在 GitHub 上查看更多内容。在 Amazon 代码示例存储库
中查找完整示例,了解如何进行设置和运行。 /// <summary> /// Get a list of dashboards. /// </summary> /// <returns>A list of DashboardEntry objects.</returns> public async Task<List<DashboardEntry>> ListDashboards() { var results = new List<DashboardEntry>(); var paginateDashboards = _amazonCloudWatch.Paginators.ListDashboards( new ListDashboardsRequest()); // Get the entire list using the paginator. await foreach (var data in paginateDashboards.DashboardEntries) { results.Add(data); } return results; }
-
有关 API 详细信息,请参阅《Amazon SDK for .NET API 参考》中的 ListDashboards。
-
- Java
-
- SDK for Java 2.x
-
注意
查看 GitHub,了解更多信息。查找完整示例,学习如何在 Amazon 代码示例存储库
中进行设置和运行。 public static void listDashboards(CloudWatchClient cw) { try { ListDashboardsIterable listRes = cw.listDashboardsPaginator(); listRes.stream() .flatMap(r -> r.dashboardEntries().stream()) .forEach(entry -> { System.out.println("Dashboard name is: " + entry.dashboardName()); System.out.println("Dashboard ARN is: " + entry.dashboardArn()); }); } catch (CloudWatchException e) { System.err.println(e.awsErrorDetails().errorMessage()); System.exit(1); } }
-
有关 API 详细信息,请参阅《Amazon SDK for Java 2.x API 参考》中的 ListDashboards。
-
- Kotlin
-
- 适用于 Kotlin 的 SDK
-
注意
在 GitHub 上查看更多内容。查找完整示例,学习如何在 Amazon 代码示例存储库
中进行设置和运行。 suspend fun listDashboards() { CloudWatchClient { region = "us-east-1" }.use { cwClient -> cwClient.listDashboardsPaginated({}) .transform { it.dashboardEntries?.forEach { obj -> emit(obj) } } .collect { obj -> println("Name is ${obj.dashboardName}") println("Dashboard ARN is ${obj.dashboardArn}") } } }
-
有关 API 详细信息,请参阅《Amazon SDK for Kotlin API 参考》中的 ListDashboards
。
-
有关 Amazon SDK 开发人员指南和代码示例的完整列表,请参阅 将 CloudWatch 与 Amazon SDK 结合使用。本主题还包括有关入门的信息以及有关先前的 SDK 版本的详细信息。
获取指标统计数据
列出指标