Azure ダッシュボードの構造

このドキュメントでは、次のダッシュボードを例として、Azure のダッシュボードの構造を説明します。

Azure portal のサンプル ダッシュボードのスクリーンショット。

共有 Azure ダッシュボードは、リソースであるため、このダッシュボードを JSON として表すことができます。 Azure portal で [エクスポート] を選んでから [ダウンロード] を選ぶことで、ダッシュボードの JSON 表現をダウンロードできます。

次の JSON は、上で示したダッシュボードを表しています。

{
{
  "properties": {
    "lenses": {
      "0": {
        "order": 0,
        "parts": {
          "0": {
            "position": {
              "x": 0,
              "y": 0,
              "colSpan": 3,
              "rowSpan": 2
            },
            "metadata": {
              "inputs": [],
              "type": "Extension/HubsExtension/PartType/MarkdownPart",
              "settings": {
                "content": {
                  "settings": {
                    "content": "## Azure Virtual Machines Overview\r\nNew team members should watch this video to get familiar with Azure Virtual Machines.",
                    "markdownUri": null
                  }
                }
              }
            }
          },
          "1": {
            "position": {
              "x": 3,
              "y": 0,
              "colSpan": 8,
              "rowSpan": 4
            },
            "metadata": {
              "inputs": [],
              "type": "Extension/HubsExtension/PartType/MarkdownPart",
              "settings": {
                "content": {
                  "settings": {
                    "content": "This is the team dashboard for the test VM we use on our team. Here are some useful links:\r\n\r\n1. [Create a Linux virtual machine](https://docs.microsoft.com/azure/virtual-machines/linux/quick-create-portal)\r\n1. [Create a Windows virtual machine](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-portal)\r\n1. [Create a virtual machine scale set](https://docs.microsoft.com/azure/virtual-machine-scale-sets/quick-create-portal)",
                    "title": "Test VM Dashboard",
                    "subtitle": "Contoso",
                    "markdownUri": null
                  }
                }
              }
            }
          },
          "2": {
            "position": {
              "x": 0,
              "y": 2,
              "colSpan": 3,
              "rowSpan": 2
            },
            "metadata": {
              "inputs": [],
              "type": "Extension/HubsExtension/PartType/VideoPart",
              "settings": {
                "content": {
                  "settings": {
                    "src": "https://www.youtube.com/watch?v=rOiSRkxtTeU",
                    "autoplay": false
                  }
                }
              }
            }
          },
          "3": {
            "position": {
              "x": 0,
              "y": 4,
              "colSpan": 11,
              "rowSpan": 3
            },
            "metadata": {
              "inputs": [
                {
                  "name": "queryInputs",
                  "value": {
                    "timespan": {
                      "duration": "PT1H"
                    },
                    "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1",
                    "chartType": 0,
                    "metrics": [
                      {
                        "name": "Percentage CPU",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      }
                    ]
                  }
                }
              ],
              "type": "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart",
              "settings": {}
            }
          },
          "4": {
            "position": {
              "x": 0,
              "y": 7,
              "colSpan": 3,
              "rowSpan": 2
            },
            "metadata": {
              "inputs": [
                {
                  "name": "queryInputs",
                  "value": {
                    "timespan": {
                      "duration": "PT1H"
                    },
                    "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1",
                    "chartType": 0,
                    "metrics": [
                      {
                        "name": "Disk Read Operations/Sec",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      },
                      {
                        "name": "Disk Write Operations/Sec",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      }
                    ]
                  }
                }
              ],
              "type": "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart",
              "settings": {}
            }
          },
          "5": {
            "position": {
              "x": 3,
              "y": 7,
              "colSpan": 3,
              "rowSpan": 2
            },
            "metadata": {
              "inputs": [
                {
                  "name": "queryInputs",
                  "value": {
                    "timespan": {
                      "duration": "PT1H"
                    },
                    "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1",
                    "chartType": 0,
                    "metrics": [
                      {
                        "name": "Disk Read Bytes",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      },
                      {
                        "name": "Disk Write Bytes",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      }
                    ]
                  }
                }
              ],
              "type": "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart",
              "settings": {}
            }
          },
          "6": {
            "position": {
              "x": 6,
              "y": 7,
              "colSpan": 3,
              "rowSpan": 2
            },
            "metadata": {
              "inputs": [
                {
                  "name": "queryInputs",
                  "value": {
                    "timespan": {
                      "duration": "PT1H"
                    },
                    "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1",
                    "chartType": 0,
                    "metrics": [
                      {
                        "name": "Network In Total",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      },
                      {
                        "name": "Network Out Total",
                        "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                      }
                    ]
                  }
                }
              ],
              "type": "Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart",
              "settings": {}
            }
          },
          "7": {
            "position": {
              "x": 9,
              "y": 7,
              "colSpan": 2,
              "rowSpan": 2
            },
            "metadata": {
              "inputs": [
                {
                  "name": "id",
                  "value": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
                }
              ],
              "type": "Extension/HubsExtension/PartType/ResourcePart",
              "asset": {
                "idInputName": "id",
                "type": "VirtualMachine"
              }
            }
          }
        }
      }
    },
    "metadata": {
      "model": {
        "timeRange": {
          "value": {
            "relative": {
              "duration": 24,
              "timeUnit": 1
            }
          },
          "type": "MsPortalFx.Composition.Configuration.ValueTypes.TimeRange"
        }
      }
    }
  },
  "name": "Simple VM Dashboard",
  "type": "Microsoft.Portal/dashboards",
  "location": "INSERT LOCATION",
  "tags": {
    "hidden-title": "Simple VM Dashboard"
  },
  "apiVersion": "2015-08-01-preview"
}

一般的なリソースのプロパティ

JSON の関連するセクションを分割してみましょう。 上の例の末尾近くには、共通のリソース プロパティがあります。 これらのプロパティは、Azure リソースのすべての種類で共有されます。 これらは、ダッシュボードの特定のコンテンツには関係ありませ。

id

ID はダッシュボードの Azure リソース ID を表し、Azure リソースの名前付け規則に従います。 ポータルでダッシュボードを作成するときは、通常、GUID 形式の ID が選択されますが、プログラムでダッシュボードを作成するときは、任意の有効な名前を使用できます。

Azure portal からダッシュボードをエクスポートする場合、id フィールドは含まれません。 id フィールドを含む JSON ファイルをインポートして新しいダッシュボードを作成した場合、その値は無視され、新しい ID 値が新しいダッシュボードごとに割り当てられます。

名前

Azure portal がダッシュボードに使用するリソース名。

Type

すべてのダッシュボードは、Microsoft.Portal/dashboards の型です。

場所

他のリソースとは異なり、ダッシュボードにはランタイム コンポーネントがありません。 ダッシュボードの場合、`location` はダッシュボードの JSON 表現が格納されるプライマリの地理的場所を示します。 値は、サブスクリプション リソースの場所 API を使用してフェッチできる場所コードの 1 つです。

タグ

タグは、任意の名前値のペア別にリソースを整理するための Azure リソース共通の機能です。 ダッシュボードには、hidden-titleと呼ばれる 1 つの特別なタグが含まれます。 ダッシュボードにこのプロパティが設定されている場合は、その値がポータルのダッシュボードの表示名として使われます。 このタグを使うと、ダッシュボードに変更可能な表示名を指定できます

プロパティ

properties オブジェクトには、lensesmetadata という 2 つのプロパティが含まれます。 lenses プロパティには、ダッシュボード上のタイルに関する情報が含まれています。 metadata プロパティは、将来導入される可能性がある機能のために予約されています。

レンズ

lenses プロパティには、ダッシュボードが含まれています。 この例の lens オブジェクトには、"0" というプロパティが 1 つ含まれています。 レンズとは、現在は実装されていないグループ化の概念です。 この場合、すべてのダッシュボードの lens オブジェクトに、この単一の "0" プロパティがあります。

指定項目

"0" の下のオブジェクトには、orderparts の 2 つのプロパティが含まれます。 現在、order は常に 0 に設定されます。 parts プロパティには、ダッシュボード上の個々のパーツ (タイルとも呼ばれます) を定義するオブジェクトが含まれています。

parts オブジェクトには、プロパティ名が数字である、各パーツのプロパティが含まれています。 数値は重要ではありません。

個々の各パーツ オブジェクトには、positionmetadata が含まれます。

位置

position プロパティには、xyrowSpan、および colSpan で表されるパーツのサイズと場所情報が含まれています。 値は、グリッド単位です。 これらのグリッド単位は、ここで示すように、カスタマイズ モードのダッシュボードの場合に表示されます。

Azure portal でのダッシュボードのグリッド単位を示すスクリーンショット。

たとえば、タイルの幅を 2 グリッド単位、高さを 1 グリッド単位、位置をダッシュボードの左上隅に設定したい場合、position オブジェクトは次のようになります。

position: { x: 0, y: 0, rowSpan: 2, colSpan: 1 }

メタデータ

各パーツには metadata プロパティがあります。 オブジェクトの必須プロパティは type の 1 つだけです。 この文字列は、表示するタイルの種類をポータルに指定します。 このダッシュボードの例では、次の種類のタイルを使用します。

  1. Extension/Microsoft_Azure_Monitoring/PartType/MetricsChartPart – 監視しているメトリックの表示に使用します
  2. Extension[azure]/HubsExtension/PartType/MarkdownPart – リストやリンクなどの基本的な書式設定を使って、テキストや画像などのカスタマイズされたマークダウン コンテンツを表示するために使われます
  3. Extension[azure]/HubsExtension/PartType/VideoPart – YouTube、Channel 9、および HTML の video タグで動作する他の種類のビデオから動画を表示するために使われます。

パーツの種類ごとに、構成のための独自のオプションがあります。 使用可能な構成プロパティは、inputssettings、および asset です。

入力

入力オブジェクトには、一般に、リソース インスタンスにタイルをバインドする情報が含まれています。

この例の各 MetricsChartPart には、バインド先のリソースを表す 1 つの入力があり、VM の Azure リソース ID と、表示されるデータについての情報を表します。 たとえば、次に示すのは、Network In TotalNetwork Out Total メトリックを表示するタイルの inputs オブジェクトです。

"inputs":
[
  {
    "name": "queryInputs",
    "value": {
      "timespan": {
        "duration": "PT1H"
      },
      "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1",
      "chartType": 0,
      "metrics": [
        {
          "name": "Network In Total",
          "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
        },
        {
          "name": "Network Out Total",
          "resourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/SimpleWinVMResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
        }
      ]
    }
  }
]

Settings

設定オブジェクトには、パーツの構成可能な要素が含まれています。 このサンプル ダッシュボードのマークダウン パーツでは、settings を使って、カスタム マークダウン コンテンツと、構成可能なタイトルおよびサブタイトルを格納しています。

"settings": {
  "content": {
    "settings": {
      "content": "This is the team dashboard for the test VM we use on our team. Here are some useful links:\r\n\r\n1. [Create a Linux virtual machine](https://docs.microsoft.com/azure/virtual-machines/linux/quick-create-portal)\r\n1. [Create a Windows virtual machine](https://docs.microsoft.com/azure/virtual-machines/windows/quick-create-portal)\r\n1. [Create a virtual machine scale set](https://docs.microsoft.com/azure/virtual-machine-scale-sets/quick-create-portal)",
      "title": "Test VM Dashboard",
      "subtitle": "Contoso"
    }
  }
}

同様に、ビデオ タイルには、再生する動画へのポインター、自動再生設定、および省略可能なタイトル情報を含む独自の設定が含まれます。


"settings": {
  "content": {
    "settings": {
      "src": "https://www.youtube.com/watch?v=rOiSRkxtTeU",
      "autoplay": false
    }
  }
}

資産

ファースト クラスの管理可能なポータル オブジェクト (アセットと呼ばれます) にバインドされるタイルでは、asset オブジェクトによってこの関係が表されます。 このサンプル ダッシュボードでは、仮想マシン タイルに、この資産の説明が含まれています。 idInputName プロパティは、ID 入力に資産の一意識別子 (この場合は、リソース ID) が含まれていることをポータルに通知します。 ほとんどの種類の Azure リソースでは、資産がポータルで定義されています。

"asset": { "idInputName": "id", "type": "VirtualMachine" }

次のステップ