Utilizzo ListDashboards con un AWS SDK o una CLI - Amazon CloudWatch

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

Utilizzo ListDashboards con un AWS SDK o una CLI

Gli esempi di codice seguenti mostrano come utilizzare ListDashboards.

.NET
SDK per .NET
Nota

C'è altro su. GitHub Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

/// <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; }
  • Per i dettagli sull'API, ListDashboardsconsulta AWS SDK per .NET API Reference.

CLI
AWS CLI

Per recuperare un elenco di dashboard

L'list-dashboardsesempio seguente elenca tutte le dashboard dell'account specificato.

aws cloudwatch list-dashboards

Output:

{ "DashboardEntries": [ { "DashboardName": "Dashboard-A", "DashboardArn": "arn:aws:cloudwatch::123456789012:dashboard/Dashboard-A", "LastModified": "2024-10-11T18:40:11+00:00", "Size": 271 }, { "DashboardName": "Dashboard-B", "DashboardArn": "arn:aws:cloudwatch::123456789012:dashboard/Dashboard-B", "LastModified": "2024-10-11T18:44:41+00:00", "Size": 522 } ] }

Per ulteriori informazioni, consulta i CloudWatch dashboard di Amazon nella Amazon CloudWatch User Guide.

Java
SDK per Java 2.x
Nota

C'è altro su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

/** * Lists the available dashboards. * * @return a {@link CompletableFuture} that completes when the operation is finished. * The future will complete exceptionally if an error occurs while listing the dashboards. */ public CompletableFuture<Void> listDashboardsAsync() { ListDashboardsRequest listDashboardsRequest = ListDashboardsRequest.builder().build(); ListDashboardsPublisher paginator = getAsyncClient().listDashboardsPaginator(listDashboardsRequest); return paginator.subscribe(response -> { response.dashboardEntries().forEach(entry -> { logger.info("Dashboard name is: {} ", entry.dashboardName()); logger.info("Dashboard ARN is: {} ", entry.dashboardArn()); }); }).exceptionally(ex -> { logger.info("Failed to list dashboards: {} ", ex.getMessage()); throw new RuntimeException("Error occurred while listing dashboards", ex); }); }
  • Per i dettagli sull'API, ListDashboardsconsulta AWS SDK for Java 2.x API Reference.

Kotlin
SDK per Kotlin
Nota

C'è altro su GitHub. Trova l'esempio completo e scopri di più sulla configurazione e l'esecuzione nel Repository di esempi di codice AWS.

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}") } } }
  • Per i dettagli sull'API, ListDashboardsconsulta AWS SDK for Kotlin API reference.

PowerShell
Strumenti per V4 PowerShell

Esempio 1: restituisce la raccolta di dashboard per il tuo account.

Get-CWDashboardList

Output:

DashboardArn DashboardName LastModified Size ------------ ------------- ------------ ---- arn:... Dashboard1 7/6/2017 8:14:15 PM 252

Esempio 2: restituisce la raccolta di dashboard per il tuo account i cui nomi iniziano con il prefisso 'dev'.

Get-CWDashboardList -DashboardNamePrefix dev
  • Per i dettagli sull'API, vedere ListDashboardsin AWS Strumenti per PowerShell Cmdlet Reference (V4).

Strumenti per V5 PowerShell

Esempio 1: restituisce la raccolta di dashboard per il tuo account.

Get-CWDashboardList

Output:

DashboardArn DashboardName LastModified Size ------------ ------------- ------------ ---- arn:... Dashboard1 7/6/2017 8:14:15 PM 252

Esempio 2: restituisce la raccolta di dashboard per il tuo account i cui nomi iniziano con il prefisso 'dev'.

Get-CWDashboardList -DashboardNamePrefix dev
  • Per i dettagli sull'API, vedere ListDashboardsin AWS Strumenti per PowerShell Cmdlet Reference (V5).

Per un elenco completo delle guide per sviluppatori AWS SDK e degli esempi di codice, vedere. Utilizzo CloudWatch con un AWS SDK Questo argomento include anche informazioni su come iniziare e dettagli sulle versioni precedenti dell'SDK.