

Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 [AWS](https://github.com/awsdocs/aws-doc-sdk-examples)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# AWS SDK または CLI `GetDashboard`で を使用する
<a name="cloudwatch_example_cloudwatch_GetDashboard_section"></a>

次のサンプルコードは、`GetDashboard` を使用する方法を説明しています。

------
#### [ .NET ]

**SDK for .NET (v4)**  
 GitHub には、その他のリソースもあります。用例一覧を検索し、[AWS コード例リポジトリ](https://github.com/awsdocs/aws-doc-sdk-examples/tree/main/dotnetv4/CloudWatch#code-examples)での設定と実行の方法を確認してください。

```
    /// <summary>
    /// Get information on a dashboard.
    /// </summary>
    /// <param name="dashboardName">The name of the dashboard.</param>
    /// <returns>A JSON object with dashboard information.</returns>
    public async Task<string> GetDashboard(string dashboardName)
    {
        var dashboardResponse = await _amazonCloudWatch.GetDashboardAsync(
            new GetDashboardRequest()
            {
                DashboardName = dashboardName
            });

        return dashboardResponse.DashboardBody;
    }
```
+  API の詳細については、「*AWS SDK for .NET API リファレンス*」の「[GetDashboard](https://docs.aws.amazon.com/goto/DotNetSDKV4/monitoring-2010-08-01/GetDashboard)」を参照してください。

------
#### [ CLI ]

**AWS CLI**  
**ダッシュボードに関する情報を取得する方法**  
次の `get-dashboard` の例では、指定されたアカウントで `Dashboard-A` という名前のダッシュボードに関する情報が表示されます。  

```
aws cloudwatch get-dashboard \
    --dashboard-name Dashboard-A
```
出力:  

```
{
    "DashboardArn": "arn:aws:cloudwatch::123456789012:dashboard/Dashboard-A",
    "DashboardBody": "{\"widgets\":[{\"type\":\"metric\",\"x\":0,\"y\":0,\"width\":6,\"height\":6,\"properties\":{\"view\":\"timeSeries\",\"stacked\":false,\"metrics\":[[\"AWS/EC2\",\"NetworkIn\",\"InstanceId\",\"i-0131f062232ade043\"],[\".\",\"NetworkOut\",\".\",\".\"]],\"region\":\"us-east-1\"}}]}",
    "DashboardName": "Dashboard-A"
}
```
詳細については、「Amazon CloudWatch ユーザーガイド」の「[Amazon CloudWatch のダッシュボード](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Dashboards.html)」を参照してください。**  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetDashboard](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/cloudwatch/get-dashboard.html)」を参照してください。

------
#### [ PowerShell ]

**Tools for PowerShell V4**  
**例 1: 指定されたダッシュボードの本体である arn を返します。**  

```
Get-CWDashboard -DashboardName Dashboard1
```
**出力:**  

```
DashboardArn                                          DashboardBody
------------                                          -------------
arn:aws:cloudwatch::123456789012:dashboard/Dashboard1 {...
```
+  API の詳細については、「*AWS Tools for PowerShell Cmdlet リファレンス (V4)*」の「[GetDashboard](https://docs.aws.amazon.com/powershell/v4/reference)」を参照してください。

**Tools for PowerShell V5**  
**例 1: 指定されたダッシュボードの本体である arn を返します。**  

```
Get-CWDashboard -DashboardName Dashboard1
```
**出力:**  

```
DashboardArn                                          DashboardBody
------------                                          -------------
arn:aws:cloudwatch::123456789012:dashboard/Dashboard1 {...
```
+  API の詳細については、*AWS Tools for PowerShell コマンドレットリファレンス (V5)* の「[GetDashboard](https://docs.aws.amazon.com/powershell/v5/reference)」を参照してください。

------