You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在GCP仪表盘Table组件中展示单操作多指标值?

GCP仪表盘Table组件展示多指标值的MQL解决方案

可以在单个Table组件中展示多个指标值,你的思路方向正确,但当前写法的字段映射和聚合逻辑需要调整,避免值相加/相乘的异常。

调整后的MQL示例

{
  // 统计错误请求数
  fetch k8s_container
  | metric 'custom.googleapis.com/my_metric/count'
  | filter metric.error == 'error'
  | group_by 1d
  | every 1m
  | group_by [metric.operation, metric.error], [error_count: sum(value)];
  
  // 统计总请求行数
  fetch k8s_container
  | metric 'custom.googleapis.com/my_metric/count'
  | group_by 1d
  | every 1m
  | group_by [metric.operation, metric.error], [total_requests: row_count()]
}
| outer_join on [metric.operation, metric.error] 0, 0

关键提示

  • 确保两个子查询的分组维度完全一致(这里是metric.operation, metric.error),作为join的匹配键,避免数据错位
  • 为每个聚合结果指定唯一别名(如error_count、total_requests),Table组件会将这些别名作为独立列展示
  • 若不需要无匹配的行,用join替代outer_join,减少空值行
  • 在Table组件配置中,勾选所有需要展示的别名字段,可自定义列标题和排序规则

内容的提问来源于stack exchange,提问作者sebac13

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.08 12:07:07