資訊主頁和版面配置範例

本頁說明如何使用 Cloud Monitoring API 建立資訊主頁。每個範例都會顯示 JSON 中的資訊主頁定義和對應的資訊主頁。您可以同時向 Google Cloud CLI 和 Cloud Monitoring API 端點提供 JSON。

Cloud Monitoring 也會在 GitHub 上提供精選的資訊主頁定義。您可以在 Google Cloud 專案中安裝這些定義,做為自訂資訊主頁。如要瞭解這個存放區和安裝這些資訊主頁的方式,請參閱「安裝範例資訊主頁」。

使用 API 或 Google Cloud CLI 的時機

Cloud Monitoring API 和 Google Cloud CLI 可讓您一次管理多個資訊主頁。雖然您可以使用Google Cloud 控制台管理資訊主頁,但使用指令碼來大量管理自訂資訊主頁可能會更輕鬆。

如要將空白預留位置小工具新增至資訊主頁,也必須使用 API。

搭配 API 使用 MQL 或 PromQL

您可以使用 dashboards.create 方法建立資訊主頁。您會將 Dashboard 物件傳遞至 API 方法,該物件會為資訊主頁顯示的每個小工具提供一個項目。

當小工具顯示時間序列資料 (例如圖表小工具) 時,其在 Dashboard 物件中的項目會包含 TimeSeriesQuery 物件。這個物件會描述要繪製成圖表的時間序列資料,您可以使用監控篩選器MQL 查詢PromQL 查詢來指定資料:

  • 如要使用監控篩選器,請填入 timeSeriesField 欄位。本頁的範例使用 Cloud Monitoring 篩選器。

  • 如要使用 MQL 查詢,請填入 timeSeriesQueryLanguage 欄位。詳情請參閱「建構圖表」。

  • 如要使用 PromQL 查詢,請填入 prometheusQuery 欄位。如需一般資訊,請參閱「Cloud Monitoring 中的 PromQL」。

資訊主頁版面配置

本節將介紹可用的不同儀表板版面配置。

GridLayout 中的資訊主頁

這個資訊主頁會顯示含有三個小工具的 GridLayout

{
  "displayName": "Grid Layout Example",
  "gridLayout": {
    "columns": "2",
    "widgets": [
      {
        "title": "Widget 1",
        "xyChart": {
          "dataSets": {
            "timeSeriesQuery": {
              "timeSeriesFilter": {
                "filter": "metric.type=\"agent.googleapis.com/nginx/connections/accepted_count\"",
                "aggregation": {
                  "perSeriesAligner": "ALIGN_RATE"
                }
              },
              "unitOverride": "1"
            },
            "plotType": "LINE"
          },
          "timeshiftDuration": "0s",
          "yAxis": {
            "label": "y1Axis",
            "scale": "LINEAR"
          }
        }
      },
      {
        "text": {
          "content": "Widget 2"
        }
      },
      {
        "title": "Widget 3",
        "xyChart": {
          "dataSets": {
            "timeSeriesQuery": {
              "timeSeriesFilter": {
                "filter": "metric.type=\"agent.googleapis.com/nginx/connections/accepted_count\"",
                "aggregation": {
                  "perSeriesAligner": "ALIGN_RATE"
                }
              },
              "unitOverride": "1"
            },
            "plotType": "STACKED_BAR"
          },
          "timeshiftDuration": "0s",
          "yAxis": {
            "label": "y1Axis",
            "scale": "LINEAR"
          }
        }
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

採用格線版面配置的資訊主頁範例。

MosaicLayout 中的資訊主頁

這個資訊主頁顯示含有兩個小工具的 MosaicLayout

{
  "displayName": "Mosaic Layout Example",
  "mosaicLayout": {
    "columns": 12,
    "tiles": [
      {
        "xPos": 2,
        "yPos": 2,
        "width": 7,
        "height": 2,
        "widget": {
          "title": "CPU utilization in us-central1-a",
          "scorecard": {
            "timeSeriesQuery": {
              "timeSeriesFilter": {
                "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\" resource.label.zone=\"us-central1-a\"",
                "aggregation": {
                  "perSeriesAligner": "ALIGN_MEAN",
                  "crossSeriesReducer": "REDUCE_MAX"
                }
              },
              "unitOverride": "1"
            },
            "gaugeView": {
              "upperBound": 1.5
            },
            "thresholds": [
              {
                "value": 0.8,
                "color": "YELLOW",
                "direction": "ABOVE"
              },
              {
                "value": 1,
                "color": "RED",
                "direction": "ABOVE"
              }
            ]
          }
        }
      },
      {
        "xPos": 1,
        "yPos": 5,
        "width": 4,
        "height": 4,
        "widget": {
          "title": "My Chart",
          "xyChart": {
            "dataSets": [
              {
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\"",
                    "aggregation": {
                      "perSeriesAligner": "ALIGN_MEAN",
                      "crossSeriesReducer": "REDUCE_MAX",
                      "groupByFields": [
                        "resource.label.zone"
                      ]
                    }
                  },
                  "unitOverride": "'1'"
                },
                "plotType": "LINE",
                "minAlignmentPeriod": "60s"
              }
            ],
            "yAxis": {
              "label": "y1Axis",
              "scale": "LINEAR"
            }
          }
        }
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

採用馬賽克版面配置的資訊主頁範例。

RowLayout 中的資訊主頁

這個資訊主頁會顯示含有三個小工具的 RowLayout

{
  "displayName": "Row Layout Example",
  "rowLayout": {
    "rows": [
      {
        "weight": "1",
        "widgets": [
          {
            "text": {
              "content": "Widget 1",
              "format": "MARKDOWN"
            }
          },
          {
            "text": {
              "content": "Widget 2",
              "format": "MARKDOWN"
            }
          },
          {
            "text": {
              "content": "Widget 3",
              "format": "MARKDOWN"
            }
          }
        ]
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

採用列版面配置的資訊主頁範例。

ColumnLayout 中的資訊主頁

這個資訊主頁會顯示含有三個小工具的 ColumnLayout

{
  "displayName": "Column Layout Example",
  "columnLayout": {
    "columns": [
      {
        "weight": "1",
        "widgets": [
          {
            "text": {
              "content": "Widget 1",
              "format": "MARKDOWN"
            }
          },
          {
            "text": {
              "content": "Widget 2",
              "format": "MARKDOWN"
            }
          },
          {
            "text": {
              "content": "Widget 3",
              "format": "MARKDOWN"
            }
          }
        ]
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

採用資料欄版面配置的資訊主頁範例

啟用資訊主頁事件,並新增篩選器和標籤

本節將說明如何在資訊主頁中加入篩選器和標籤,以及如何設定資訊主頁以顯示事件。

在資訊主頁上啟用事件

您可以將 annotations 欄位加入 Dashboard 物件中,藉此設定資訊主頁顯示事件,例如 Google Kubernetes Engine 更新事件或虛擬機器故障事件。annotations 欄位包含 DashboardAnnotations 物件的例項,其中包含兩個欄位:

  • defaultResourceName 欄位會列出資訊主頁層級的預設值,供Google Cloud 專案搜尋事件。如果未指定這個欄位,系統會搜尋所選專案。

  • EventAnnotation 物件的陣列。每個物件都包含以下項目:

    • displayName 欄位,可讓您在特定事件切換按鈕上定義標籤。如果未指定這個欄位,或是這個欄位的值為空白字串,系統會顯示事件的預設名稱。
    • enabled 欄位,用於控制事件切換鈕的值。當 true 時,切換鈕會處於 on 位置,且資訊主頁會顯示事件。當 false 時,切換鈕會處於 off 位置。
    • eventType 欄位,其中包含 EventType 列舉的值。
    • filter 欄位,可讓您指定要附加至事件專屬查詢的查詢。如果這個欄位的值為空白字串,系統就會使用事件專屬查詢。
    • resourceNames 欄位,可讓您定義要搜尋事件的Google Cloud 專案清單。如果這個欄位是空陣列,系統會搜尋所選專案。

以下範例顯示指定 Google Kubernetes Engine 事件的 annotations 欄位:

{
  "displayName": "Annotation example",
  "annotations": {
    "defaultResourceNames": [],
    "eventAnnotations": [
      {
        "displayName": "",
        "enabled": true,
        "eventType": "GKE_CLUSTER_UPDATE",
        "filter": "resource.labels.cluster_name=my-cluster",
        "resourceNames": []
      }
    ]
  },
  "dashboardFilters": [],
  "mosaicLayout": {
  ...
  },
  "labels": {}
}

在前述範例中,filter 欄位用於將查詢限制在叢集 my-namedisplayName 欄位設為空白字串,因此事件類型的預設名稱會顯示在事件切換按鈕上。最後,由於 resourceNames 已設為空陣列,因此會查詢目前 Google Cloud 專案中的記錄項目。

新增資訊主頁篩選器和變數

如要控制資訊主頁上的小工具顯示哪些資料,您可以新增變數和固定篩選器。如需詳細資訊和範例,請參閱「資訊主頁篩選器」。

新增資訊主頁標籤

這個範例顯示指定名為 playbook 的標籤的 Dashboard 物件。

{
  "displayName": "Example",
  "mosaicLayout": {
    "columns": 12,
    "tiles": [
      ...
    ]
  },
  "dashboardFilters": [],
  "labels": {
    "playbook": ""
  }
}

如前述範例所示,labels 欄位會以 map 的形式實作,其中 keyvalue 欄位都是字串。在資訊主頁中新增標籤時,請將 key 設為標籤名稱,並將 value 欄位設為空字串。

您可以選擇是否要在資訊主頁中新增標籤。

含有 Widgets 的資訊主頁

本節提供包含不同類型小工具的資訊主頁範例。

含有 XyChart 的資訊主頁

這個資訊主頁會顯示含有基本 XyChart 的資訊主頁。如果您曾使用 Google Cloud 主控台在資訊主頁上建立圖表,這些圖表就是 XyChart 小工具的例項。

與 Google Cloud 控制台提供的功能類似,API 提供的選項可用於變更圖表的 PlotType 或設定圖表的檢視模式

{
  "dashboardFilters": [],
  "displayName": "Example line chart",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - CPU utilization [MEAN]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_MEAN",
                      "groupByFields": [
                        "resource.label.\"zone\""
                      ],
                      "perSeriesAligner": "ALIGN_MEAN"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24
      }
    ]
  }
}

資訊主頁上的圖表會類似下列範例:

XyChart 範例。

下一節將說明如何建立 Log Analytics 圖表小工具、如何在圖表上顯示閾值,以及如何設定圖表是否使用左 Y 軸、右 Y 軸或兩者皆用。

內含記錄檔分析圖表的資訊主頁

這個資訊主頁顯示含有 Log Analytics 圖表的資訊主頁。範例 JSON 包含 SQL 查詢。

{
  "displayName": "Example",
  "dashboardFilters": [],
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "width": 24,
        "height": 16,
        "widget": {
          "title": "Sample analytics chart",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "breakdowns": [],
                "dimensions": [
                  {
                    "column": "location",
                    "columnType": "STRING",
                    "maxBinCount": 5,
                    "sortColumn": "location",
                    "sortOrder": "SORT_ORDER_ASCENDING"
                  }
                ],
                "measures": [
                  {
                    "aggregationFunction": {
                      "parameters": [],
                      "type": "count"
                    },
                    "column": ""
                  }
                ],
                "plotType": "STACKED_BAR",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "opsAnalyticsQuery": {
                    "queryHandle": "",
                    "sql": "SELECT\n  CAST(JSON_VALUE(resource.labels.location) AS STRING) AS location,\n  severity,\nFROM\n  `TABLE_NAME_OF_LOG_VIEW`"
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        }
      }
    ]
  },
  "labels": {}
}

資訊主頁上的圖表會類似下列範例:

使用 Log Analytics SQL 查詢的 XY 圖表範例。

含有 XyChart 和門檻值的資訊主頁

這個資訊主頁顯示已設定基本 XyChart、閾值和左側 Y 軸的資訊主頁。

{
  "dashboardFilters": [],
  "displayName": "Example line with threshold",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - CPU utilization [MEAN]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_MEAN",
                      "groupByFields": [
                        "resource.label.\"zone\""
                      ],
                      "perSeriesAligner": "ALIGN_MEAN"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [
              {
                "label": "",
                "targetAxis": "Y1",
                "value": 0.2
              }
            ],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24
      }
    ]
  }
}

在上述範例中,JSON 會指定使用左側 Y 軸,因為它包含 y2Axis 結構。在 targetAxis 欄位中,將「Y1」用於右側 Y 軸,將「Y2」用於左側 Y 軸。如果省略 targetAxis 欄位,系統會使用右側 Y 軸。

這個資訊主頁上的圖表會類似下列範例:

使用左側 Y 軸且設有閾值的 XyChart 範例。

您可以建立圖表來顯示多種指標類型,並使用左右軸。上一個範例說明瞭包含單一指標類型的圖表,也就是 dataSets 陣列中只有一個元素。當您繪製兩種指標類型的圖表時,dataSets 陣列會包含兩個元素,每個元素都會指定其 targetAxis

資訊主頁包含 XyChartSTACKED_AREA PlotType

這個資訊主頁會顯示 XyChartSTACKED_AREA PlotType

{
  "dashboardFilters": [],
  "displayName": "Example stacked area",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - CPU utilization [MEAN]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "STACKED_AREA",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_MEAN",
                      "groupByFields": [
                        "resource.label.\"zone\""
                      ],
                      "perSeriesAligner": "ALIGN_MEAN"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24
      }
    ]
  }
}

資訊主頁上的圖表會類似下列範例:

含有堆疊面積圖的 XY 圖表範例。

包含 STACKED_BAR PlotType 的 XyChart 資訊主頁

這個資訊主頁會顯示 XyChartSTACKED_BAR PlotType

{
  "dashboardFilters": [],
  "displayName": "Example stacked bar",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - CPU utilization [MEAN]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "STACKED_BAR",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_MEAN",
                      "groupByFields": [
                        "resource.label.\"zone\""
                      ],
                      "perSeriesAligner": "ALIGN_MEAN"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

含有堆疊長條圖的 XY 圖範例。

含有基本 Scorecard 的資訊主頁

這個資訊主頁會顯示沒有量表或微格線的 Scorecard。這個範例顯示 Compute Engine CPU 使用率,且評量表有兩個門檻。一個閾值會使用黃色表示 CPU 使用率超過 70%,另一個閾值會使用紅色表示 CPU 使用率超過 90%。

由於目前的 CPU 使用率低於指定的門檻,因此顏色為綠色。

{
  "dashboardFilters": [],
  "displayName": "Example-basic scorecard",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 8,
        "widget": {
          "scorecard": {
            "thresholds": [
              {
                "color": "YELLOW",
                "direction": "ABOVE",
                "label": "",
                "value": 0.7
              },
              {
                "color": "RED",
                "direction": "ABOVE",
                "label": "",
                "value": 0.9
              }
            ],
            "timeSeriesQuery": {
              "outputFullDuration": true,
              "timeSeriesFilter": {
                "aggregation": {
                  "alignmentPeriod": "60s",
                  "crossSeriesReducer": "REDUCE_MEAN",
                  "groupByFields": [],
                  "perSeriesAligner": "ALIGN_MEAN"
                },
                "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\""
              }
            }
          },
          "title": "VM Instance - CPU utilization [MEAN]"
        },
        "width": 16
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

範例:含有評量表小工具的資訊主頁。

資訊主頁含有 ScorecardGaugeView

這個資訊主頁會在先前範例中的基本評量表中新增刻度圖。GaugeView 物件可指定上限和下限,以指定在量測儀上顯示的值範圍。由於評量表顯示的值介於 0 到 1 之間,因此這些上限和下限是合理的。如要新增刻度圖,請將下列內容加入基本評量表的 JSON:

  "gaugeView": {
    "lowerBound": 0,
    "upperBound": 1,
  },

以下是完整的修訂版資訊主頁規格:目前的值低於門檻,並在量測儀上以適當的顏色標示。

{
  "dashboardFilters": [],
  "displayName": "Example-Gauge",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 8,
        "widget": {
          "scorecard": {
            "gaugeView": {
              "lowerBound": 0,
              "upperBound": 1
            },
            "thresholds": [
              {
                "color": "YELLOW",
                "direction": "ABOVE",
                "label": "",
                "value": 0.7
              },
              {
                "color": "RED",
                "direction": "ABOVE",
                "label": "",
                "value": 0.9
              }
            ],
            "timeSeriesQuery": {
              "outputFullDuration": true,
              "timeSeriesFilter": {
                "aggregation": {
                  "alignmentPeriod": "60s",
                  "crossSeriesReducer": "REDUCE_MEAN",
                  "groupByFields": [],
                  "perSeriesAligner": "ALIGN_MEAN"
                },
                "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\""
              }
            }
          },
          "title": "VM Instance - CPU utilization [MEAN]"
        },
        "width": 16
      }
    ]
  }
}

這個資訊主頁上的圖表會類似下列範例:

範例資訊主頁,其中含有評量表小工具和 GaugeView。

資訊主頁含有 ScorecardSparkChartView

這個資訊主頁將先前範例中的量測儀替換為 Sparkline。SparkChartView 物件可在評量表上建立折線圖或長條圖。本範例使用的是線條。只要值未違反閾值,就會顯示為綠色。如要新增微型圖表,請將上一個圖表中的 gaugeView JSON 物件替換為以下內容:

  "sparkChartView": {
    "sparkChartType": "SPARK_LINE"
  },

分數卡如下所示:

範例資訊主頁,其中含有含有 SparkChartView 的評量表小工具。

內含 PieChart 小工具的資訊主頁

資訊主頁可使用圓餅圖顯示資料。每個時間序列都會為圓餅圖貢獻一個扇形。圓餅圖不會顯示隨時間變化的資料,只會顯示最新的值。

所有圓餅圖都由 PieChart 小工具指定。如要設定圖表,以便顯示最近測量值的總和,請將 chartType 欄位設為 DONUT。否則,請將這個欄位設為 PIE 的值。

"pieChart": {
  "chartType": "DONUT",
},

以下範例會設定含有兩個圓餅圖的資訊主頁,其中一個圓餅圖會設為圓環圖:

{
  "dashboardFilters": [],
  "displayName": "Example Pie Donut",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "pieChart": {
            "chartType": "DONUT",
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/read_bytes_count\" resource.type=\"gce_instance\"",
                    "secondaryAggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_MEAN"
                    }
                  }
                }
              }
            ]
          },
          "title": "VM Instance - Disk read bytes [MEAN]"
        },
        "width": 24
      },
      {
        "height": 16,
        "widget": {
          "pieChart": {
            "chartType": "PIE",
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/read_bytes_count\" resource.type=\"gce_instance\"",
                    "secondaryAggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_MEAN"
                    }
                  }
                }
              }
            ]
          },
          "title": "VM Instance - Disk read bytes [MEAN]"
        },
        "width": 24,
        "xPos": 24
      },
    ]
  }
}

如下方螢幕截圖所示,兩個小工具都以圓餅圖的形式顯示資料,其中一個小工具會顯示最新值的總和:

**PieChart** 小工具範例。

內含 Treemap 小工具的資訊主頁

如要將最新資料以一系列巢狀矩形顯示,其中每個矩形對應至不重複的標籤值集合,請新增樹狀圖。假設您已依 zone 標籤匯總要繪製的資料。如果將小工具類型設為樹狀圖,則樹狀圖上的每個矩形都會對應至一個區域。矩形的色彩飽和度與其代表的值成正比。

瀏覽樹狀圖時,請使用指標啟用矩形的工具提示。

以下 JSON 會設定 Treemap 小工具,該小工具會依區域和儲存類型匯總時間序列:

{
  "displayName": "Example Treemap",
  "dashboardFilters": [],
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "xPos": 24,
        "height": 16,
        "width": 24,
        "widget": {
          "title": "VM Instance - Write read bytes [SUM]",
          "id": "",
          "treemap": {
            "dataSets": [
              {
                "breakdowns": [],
                "measures": [],
                "timeSeriesQuery": {
                  "outputFullDuration": true,
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_SUM",
                      "groupByFields": [
                        "resource.label.\"zone\"",
                        "metric.label.\"storage_type\""
                      ],
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" resource.type=\"gce_instance\""
                  },
                  "unitOverride": ""
                }
              }
            ],
            "treemapHierarchy": [
              "resource.label.\"zone\"",
              "metric.label.\"storage_type\""
            ]
          }
        }
      }
    ]
  }
}

下圖顯示使用上述設定的樹狀圖小工具:

**Treemap** 小工具範例。

在螢幕截圖中,矩形會顯示工具提示。

內含 TimeSeriesTable 小工具的資訊主頁

資訊主頁可以表格格式顯示資料,每個不重複標籤值組合會對應一個資料列。資料表不會顯示隨時間變化的資料,而是顯示最新值或匯總值。

所有表格都會透過 TimeSeriesTable 小工具指定:

  • 如要設定要顯示的時間序列,請使用 dataSets 欄位。dataSets 陣列中的每個物件都對應至單一指標類型。如果您查詢多種指標類型, Google Cloud 控制台會嘗試在同一表格列中顯示每項查詢的最新值。詳情請參閱「資料表如何合併多種指標類型的資料」。

    • TimeSeriesQuery 欄位會指定指標類型。
    • 如果您希望表格顯示匯總值 (即以資訊主頁設定的時間範圍值匯總資料),請將 timeSeriesQuery.outputFullDuration 欄位設為 true
  • 如要設定要顯示的列數上限,請設定 pickTimeSeriesFilter 欄位。舉例來說,如要只顯示過去 10 分鐘內平均值最大的兩個時間序列,請加入以下內容:

    "pickTimeSeriesFilter": {
        "direction": "TOP",
        "numTimeSeries": 2,
        "rankingMethod": "METHOD_MEAN"
    },
    

    如果省略 pickTimeSeriesFilter 欄位,表格最多會顯示 300 列。

  • 如要設定表格顯示資料的方式,請使用 metricVisualization 欄位:

    • 如要只顯示「25%」這類值,請省略這個欄位或將值設為 "NUMBER"。使用這項設定時,Google Cloud 主控台會將小工具顯示為 Table 小工具。
    • 如要顯示值和與可能值範圍比較的值視覺化指標,請將這個欄位的值設為 "BAR"。使用這項設定時,Google Cloud 主控台會將小工具顯示為「熱門清單」小工具。
  • 如要設定要顯示哪些資料欄以及資料欄的屬性,請使用 columnSettings 陣列。如果未指定這個欄位,則表格會為每個標籤顯示一欄。

    "column" 欄位的值必須設為標籤鍵或 value,後者是指時間序列的最新值。您可以為資料欄設定顯示名稱,並設定表格儲存格內資料的對齊方式:

    • 如要自訂欄標題,請設定 displayName 欄位。
    • 如要根據值與閾值的比較結果,為顯示最新值的儲存格著色,請新增 thresholds 物件。
    • 如要變更文字對齊方式,請新增 alignment 欄位。

    以下範例說明兩個資料欄:

    "columnSettings": [
      {
        "column": "device_name",
        "displayName": "Device",
        "visible": true
      },
      {
        "alignment": "CENTER",
        "column": "value",
        "displayName": "Disk Write Bytes",
        "thresholds": [
          {
            "color": "YELLOW",
            "direction": "ABOVE",
            "value": 4000
          },
          {
            "color": "RED",
            "direction": "ABOVE",
            "value": 5000
          }
        ],
        "visible": true
      }
    ],
    

下列 JSON 說明包含兩個資料表的資訊主頁。第一個表格會顯示兩種指標類型:從執行個體讀取的位元組數,以及寫入執行個體的位元組數。匯總值會與參考長條一併顯示。第二個表格顯示某個指標類型的最新值,且值欄已設定為根據值與門檻的比較結果,為儲存格加上顏色代碼:

{
  "displayName": "Example",
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "width": 44,
        "height": 17,
        "widget": {
          "title": "VM Instance - Disk read bytes [RATE], Disk write bytes [RATE]",
          "timeSeriesTable": {
            "dataSets": [
              {
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/read_bytes_count\" resource.type=\"gce_instance\"",
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE",
                      "groupByFields": []
                    },
                    "pickTimeSeriesFilter": {
                      "rankingMethod": "METHOD_MEAN",
                      "numTimeSeries": 30,
                      "direction": "TOP"
                    }
                  },
                  "unitOverride": "",
                  "outputFullDuration": true
                },
                "tableTemplate": "",
                "minAlignmentPeriod": "60s"
              },
              {
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" resource.type=\"gce_instance\"",
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE",
                      "groupByFields": []
                    },
                    "pickTimeSeriesFilter": {
                      "rankingMethod": "METHOD_MEAN",
                      "numTimeSeries": 30,
                      "direction": "TOP"
                    }
                  },
                  "unitOverride": "",
                  "outputFullDuration": true
                },
                "tableTemplate": "",
                "minAlignmentPeriod": "60s"
              }
            ],
            "metricVisualization": "BAR",
            "columnSettings": [
              {
                "column": "Name (from instance_id)",
                "visible": true
              },
              {
                "column": "zone",
                "visible": true
              },
              {
                "column": "device_name",
                "visible": true
              },
              {
                "column": "storage_type",
                "visible": true
              },
              {
                "column": "device_type",
                "visible": true
              },
              {
                "column": "value",
                "visible": true,
                "displayName": "Read bytes"
              },
              {
                "column": "value-1",
                "visible": true,
                "displayName": "Written bytes"
              }
            ],
            "opsAnalyticsSettings": {
              "maxRows": "0",
              "showFilterBar": false,
              "pageSize": "0"
            },
            "displayColumnType": false
          },
          "id": ""
        }
      },
      {
        "yPos": 17,
        "width": 44,
        "height": 16,
        "widget": {
          "title": "VM Instance - Disk write bytes [RATE]",
          "timeSeriesTable": {
            "columnSettings": [
              {
                "column": "device_name",
                "displayName": "Device",
                "visible": true
              },
              {
                "alignment": "LEFT",
                "column": "instance_name",
                "displayName": "Instance name",
                "visible": true
              },
              {
                "column": "storage_type",
                "displayName": "Storage type",
                "visible": true
              },
              {
                "column": "device_type",
                "displayName": "Device Type",
                "visible": true
              },
              {
                "alignment": "CENTER",
                "column": "value",
                "displayName": "Disk Write Bytes",
                "thresholds": [
                  {
                    "color": "YELLOW",
                    "direction": "ABOVE",
                    "label": "",
                    "value": 4000
                  },
                  {
                    "color": "RED",
                    "direction": "ABOVE",
                    "label": "",
                    "value": 5000
                  }
                ],
                "visible": true
              },
              {
                "alignment": "LEFT",
                "column": "Name (from instance_id)",
                "displayName": "ID",
                "visible": true
              }
            ],
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "displayColumnType": false,
            "metricVisualization": "NUMBER",
            "opsAnalyticsSettings": {
              "maxRows": "0",
              "pageSize": "0",
              "showFilterBar": false
            }
          }
        }
      }
    ]
  },
  "dashboardFilters": [],
  "labels": {}
}

下圖顯示先前定義的資料表:

含有資料表小工具的資訊主頁範例。

內含 Text 小工具的資訊主頁

這個範例顯示含有 Text 小工具的資訊主頁。

{
  "dashboardFilters": [],
  "displayName": "DB2+TE",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
    ...
      {
        "height": 16,
        "widget": {
          "text": {
            "content": "# Support information\n\n\nContact information: my-support-team@example.com\nOnline help: [Playbooks](https://example.com)\n\n",
            "format": "MARKDOWN",
            "style": {
              "backgroundColor": "",
              "fontSize": "FS_LARGE",
              "horizontalAlignment": "H_LEFT",
              "padding": "P_EXTRA_SMALL",
              "textColor": "",
              "verticalAlignment": "V_TOP"
            }
          }
        },
        "width": 24,
        "yPos": 14
      }
    ]
  }
}

文字小工具的樣式如下:

文字小工具範例。

內含 AlertChart 小工具的資訊主頁

這個資訊主頁顯示含有 AlertChart 小工具的資訊主頁:

{
  "category": "CUSTOM",
  "displayName": "Alerting policy chart example",
  "mosaicLayout": {
    "columns": 12,
    "tiles": [
      {
        "height": 4,
        "widget": {
          "alertChart": {
            "name": "projects/my-project/alertPolicies/14205854094151528373"
          }
        },
        "width": 6,
      }
    ]
  }
}

與其他資訊主頁小工具不同,您不需要為這些小工具指定標題或指標篩選器。而是指定警告政策的資源名稱。name 欄位中的最後一個項目是警告政策 ID。

資訊主頁上的圖表會類似下列範例:

快訊政策圖表範例。

在這個範例中,快訊政策會監控兩部不同虛擬機器的 CPU 使用率。虛線表示條件門檻,目前設為 50%。標示為 No incidents 的綠色方塊表示快訊政策沒有未解決事件。如果將游標放在事件方塊上,系統會開啟連結至基礎警報政策的對話方塊。

內含 ErrorReportingPanel 小工具的資訊主頁

這個資訊主頁顯示含有 ErrorReportingPanel 小工具的資訊主頁:

{
  "dashboardFilters": [],
  "displayName": "Error reporting widget",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "errorReportingPanel": {
            "projectNames": [
              "projects/my-project"
            ],
            "services": [],
            "versions": []
          },
          "title": "Error Reporting Panel"
        },
        "width": 24,
      }
    ]
  }
}

建議您將錯誤回報面板的高度設為至少 16 個單位,寬度則設為至少 24 個單位。在前述範例中,小工具的高度為 16 個單位,寬度為 24 個單位。

錯誤回報面板會顯示所選專案的錯誤群組,且可將錯誤群組限制為特定資源類型、服務或服務版本。以下範例說明錯誤回報面板:

範例:錯誤回報面板設定窗格。

內含 IncidentList 小工具的資訊主頁

這個資訊主頁顯示含有 IncidentList 小工具的資訊主頁:

{
  "category": "CUSTOM",
  "dashboardFilters": [],
  "displayName": "Incident widget",
  "labels": {},
  "mosaicLayout": {
    "columns": 12,
    "tiles": [
      {
        "height": 5,
        "widget": {
          "incidentList": {
            "monitoredResources": [],
            "policyNames": []
          },
          "title": "Incidents"
        },
        "width": 8,
        "xPos": 0,
        "yPos": 0
      }
    ]
  }
}

上一個範例將 title 欄位設為 Incidents,並設定小工具,以便顯示 gce_instance 類型資源的所有事件。設定這個小工具時,您可以選取多個快訊政策或多種資源類型。

資訊主頁上的事件小工具會顯示類似下列範例的內容:

事件小工具範例。

內含 LogsPanel 小工具的資訊主頁

這個資訊主頁顯示含有 LogsPanel 小工具的資訊主頁:

{
  "category": "CUSTOM",
  "displayName": "Logs Panel",
  "mosaicLayout": {
    "columns": 12,
    "tiles": [
      {
        "height": 4,
        "widget": {
          "logsPanel": {
            "filter": "",
            "resourceNames": [
              "projects/012012012012"
            ]
          },
          "title": "Logs Panel"
        },
        "width": 6,
        "xPos": 0,
        "yPos": 0
      }
    ]
  }
}

建議您將記錄面板的高度設為至少 3 個單位,寬度則設為至少 4 個單位。在前述範例中,小工具的高度為 4 個單位,寬度為 6 個單位。

「Logs」面板會顯示 resourceNames 欄位中列出的 Google Cloud 專案記錄。上一個範例只指定一個專案,但您可以在這個清單中加入多個專案。

記錄面板如下所示:

含有記錄面板小工具的資訊主頁範例。

如需疑難排解資訊,請參閱「API 呼叫以建立含有記錄面板的資訊主頁失敗」。

內含 CollapsibleGroup 小工具的資訊主頁

這個資訊主頁顯示含有 CollapsibleGroup 小工具的資訊主頁:

{
  "category": "CUSTOM",
  "displayName": "Group testing",
  "mosaicLayout": {
    "columns": 12,
    "tiles": [
      {
        "height": 4,
        "widget": {
          "collapsibleGroup": {
            "collapsed": false
          },
          "title": "My group"
        },
        "width": 12,
        "xPos": 0,
        "yPos": 0
      },
      {
        "height": 4,
        "widget": {
          "title": "VM Instance - CPU utilization [MEAN]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "apiSource": "DEFAULT_CLOUD",
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_NONE",
                      "perSeriesAligner": "ALIGN_MEAN"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/cpu/utilization\" resource.type=\"gce_instance\"",
                    "secondaryAggregation": {
                      "alignmentPeriod": "60s",
                      "crossSeriesReducer": "REDUCE_NONE",
                      "perSeriesAligner": "ALIGN_NONE"
                    }
                  }
                }
              }
            ],
            "thresholds": [],
            "timeshiftDuration": "0s",
            "yAxis": {
              "label": "y1Axis",
              "scale": "LINEAR"
            }
          }
        },
        "width": 6,
        "xPos": 0,
        "yPos": 0
      }
    ]
  }
}

在前述範例中,可摺疊群組小工具包含單一圖表,用於顯示 VM 執行個體的 CPU 使用率。可收合的群組小工具會橫跨整個表格資料列。如果群組的 (x,y) 位置和高度規格包含小工具的 (x,y) 位置,則小工具就會包含在群組中。在上一個範例中,群組位於 (0,0) 位置,高度為 4。xyChart 位於 (0,0) 位置,因此會納入群組。不過,如果該圖表的位置變更為 (0,5),則系統會將該圖表從群組中排除。最後,當小工具的 (x,y) 位置導致小工具納入群組時,可摺疊群組小工具的高度可能會展開。

如要在資訊主頁上加入群組小工具,該資訊主頁必須有 MosaicLayout

可摺疊群組小工具的樣式如下所示:

含有可摺疊群組小工具的資訊主頁範例。

內含 SingleViewGroup 小工具的資訊主頁

SingleViewGroup 小工具一次只會顯示一個群組成員。您可以指定群組中的圖表和其他小工具。此外,您也可以使用 SingleViewGroup 小工具上的選單,控制群組中要顯示哪些小工具。

SingleViewGroup 小工具支援兩種顯示樣式:DROPDOWNTAB。這兩種樣式的差異在於您如何選取要顯示的群組成員。採用 DROPDOWN 樣式的小工具會提供選單。採用 TAB 樣式的小工具會在小工具的工具列上提供分頁:

{
  "dashboardFilters": [],
  "displayName": "Example",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "singleViewGroup": {
            "displayType": "DROPDOWN"
          },
          "title": "Untitled group"
        },
        "width": 24,
        "yPos": 16
      },
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - Disk read bytes [RATE]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/read_bytes_count\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24,
        "yPos": 16
      },
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - Disk write bytes [RATE]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24,
        "yPos": 16
      }
    ]
  }
}

如上一個範例所示,tiles 陣列包含一個 SingleViewGroup 物件,但該物件並未指定所包含的物件。SingleViewGroup 物件的成員資格則由 widthyPos 欄位的值決定。SingleViewGroup 物件包含 widthyPos 欄位值與 SingleViewGroup 物件值相符的物件。在上述範例中,SingleViewGroup 物件包含兩個圖表。

內含 SectionHeader 小工具的資訊主頁

SectionHeader 小工具會在資訊主頁中建立水平分隔線,並在資訊主頁的內容表中建立項目。您可以自訂目錄中的項目,並在小工具中加入其他資訊。您也可以設定小工具,在章節標題項目後方加入目錄分隔符。

這個資訊主頁顯示包含單一圖表和 SectionHeader 小工具的資訊主頁:

{
  "dashboardFilters": [],
  "displayName": "Example",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "title": "VM Instance - Disk write bytes [RATE]",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "minAlignmentPeriod": "60s",
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "alignmentPeriod": "60s",
                      "perSeriesAligner": "ALIGN_RATE"
                    },
                    "filter": "metric.type=\"compute.googleapis.com/instance/disk/write_bytes_count\" resource.type=\"gce_instance\""
                  }
                }
              }
            ],
            "thresholds": [],
            "yAxis": {
              "label": "",
              "scale": "LINEAR"
            }
          }
        },
        "width": 24,
        "yPos": 4
      },
      {
        "height": 4,
        "widget": {
          "sectionHeader": {
            "dividerBelow": true,
            "subtitle": "Instance metrics"
          },
          "title": "Metrics"
        },
        "width": 48
      }
    ]
  }
}

SectionHeader 物件中,小工具和目錄都會顯示 title 欄位的值。只有小工具會顯示 subtitle 欄位的值。如果 dividerBelow 的值為 true,則目錄會新增分隔線。

含有服務等級目標小工具的資訊主頁

這個資訊主頁會顯示含有 SLO 小工具的資訊主頁:

{
  "dashboardFilters": [],
  "displayName": "Example",
  "labels": {},
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "height": 16,
        "widget": {
          "title": "SLO Error Budget: 99.5% - Distribution Cut - Calendar month",
          "xyChart": {
            "chartOptions": {
              "mode": "COLOR"
            },
            "dataSets": [
              {
                "breakdowns": [],
                "dimensions": [],
                "legendTemplate": "Remaining error requests before SLO is burned",
                "measures": [],
                "plotType": "LINE",
                "targetAxis": "Y1",
                "timeSeriesQuery": {
                  "timeSeriesFilter": {
                    "aggregation": {
                      "perSeriesAligner": "ALIGN_NEXT_OLDER"
                    },
                    "filter": "select_slo_budget(\"projects/Project_Number/services/SERVICE_ID/serviceLevelObjectives/SLO_ID\")",
                  },
                  "unitOverride": "1"
                }
              }
            ],
            "thresholds": []
          }
        },
        "width": 24
      }
    ]
  }
}

如上方 JSON 所示,SLO 圖表會以 XyChart 物件表示。這些物件會指定所有匯總欄位、門檻,以及 filter 欄位的值,也就是時間序列選取器。如要進一步瞭解這些選取器,請參閱「擷取 SLO 資料」。

SLO 小工具如下圖所示:

含 SLO 小工具的資訊主頁範例。

含有空白小工具的資訊主頁

此範例顯示資訊主頁,其中包含空白的預留位置小工具。小工具會顯示 displayName 欄位的值。

{
  "displayName": "Demo Dashboard",
  "gridLayout": {
    "widgets": [
      {
        "blank": {}
      }
    ]
  }
}

資訊主頁會顯示類似下列範例的內容:

含空白小工具的資訊主頁範例。

已設定小工具顯示設定的資訊主頁

這個資訊主頁包含文字小工具和變數。變數的值會決定文字小工具是否顯示或隱藏:

  • 名為 show 的變數預設值為 a。變數的值定義為 abc。由於 valueType 欄位為 STRING_ARRAY,因此變數也可以設為 a or b 等值。

  • 在文字小工具中,標示為 visibilityCondition 的項目會定義小工具的顯示設定。當變數 show 的值包含 b 時,系統會顯示文字小工具。否則系統不會顯示文字小工具。


{
  "displayName": "Conditional Widget Example",
  "mosaicLayout": {
    "columns": 48,
    "tiles": [
      {
        "yPos": 16,
        "width": 24,
        "height": 16,
        "widget": {
          "title": "A text widget",
          "text": {
            "content": "Example showing how to use a custom variable to control visibility.",
            "format": "MARKDOWN",
            "style": {
              "backgroundColor": "#FFFFFF",
              "fontSize": "FS_LARGE",
              "horizontalAlignment": "H_LEFT",
              "padding": "P_EXTRA_SMALL",
              "pointerLocation": "POINTER_LOCATION_UNSPECIFIED",
              "textColor": "#212121",
              "verticalAlignment": "V_TOP"
            }
          },
          "visibilityCondition": {
            "templateVariableCondition": {
              "templateVariable": "show",
              "templateVariableValue": "b",
              "comparator": "REGEX_FULL_MATCH"
            }
          }
        }
      }
    ]
  },
  "dashboardFilters": [
    {
      "labelKey": "",
      "templateVariable": "show",
      "stringArrayValue": {
        "values": [
          "a"
        ]
      },
      "filterType": "VALUE_ONLY",
      "valueType": "STRING_ARRAY",
      "stringArray": {
        "values": [
          "a",
          "b",
          "c"
        ]
      }
    }
  ],
  "labels": {}
}

如要瞭解設定小工具可見度時的限制,請參閱「設定小工具的可見度」。