获取 CloudWatch 控制面板的详细信息 - Amazon CloudWatch
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅中国的 Amazon Web Services 服务入门

获取 CloudWatch 控制面板的详细信息

以下代码示例展示如何获取 Amazon CloudWatch 控制面板详细信息。

.NET
Amazon SDK for .NET

using System; using System.Threading.Tasks; using Amazon.CloudWatch; using Amazon.CloudWatch.Model; /// <summary> /// This example shows how to retrieve the details of an Amazon CloudWatch /// dashboard. The return value from the call to GetDashboard is a json /// object representing the widgets in the dashboard. The example was /// created using the AWS SDK for .NET version 3.7 and .NET Core 5.0. /// </summary> public class GetDashboard { public static async Task Main() { IAmazonCloudWatch cwClient = new AmazonCloudWatchClient(); string dashboardName = "CloudWatch-Default"; var body = await GetDashboardAsync(cwClient, dashboardName); Console.WriteLine(body); } /// <summary> /// Get the json that represents the dashboard. /// </summary> /// <param name="client">An initialized CloudWatch client.</param> /// <param name="dashboardName">The name of the dashboard.</param> /// <returns>The string containing the json value describing the /// contents and layout of the CloudWatch dashboard.</returns> public static async Task<string> GetDashboardAsync(IAmazonCloudWatch client, string dashboardName) { var request = new GetDashboardRequest { DashboardName = dashboardName, }; var response = await client.GetDashboardAsync(request); return response.DashboardBody; } }
  • GitHub 中查找说明和更多代码。

  • 有关 API 详细信息,请参阅 Amazon SDK for .NET API 参考中的 GetDashboard

有关 Amazon 开发工具包开发人员指南和代码示例的完整列表,包括帮助入门和有关早期版本的信息,请参阅 将 CloudWatch 与 Amazon 开发工具包结合使用