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

如何在Grafana中按多字段关联Prometheus查询生成指定表格

Grafana表格面板配置:按channel+currency关联多PromQL查询结果

核心配置步骤

1. 切换所有查询为「即时查询」

每个PromQL查询右上角切换为**即时(Instant)**模式,确保每个查询仅返回channel+currency组合的单个聚合值,避免生成时间维度的重复行。

2. 给查询设置明确别名

点击查询行标题编辑别名,对应关系如下:

  • 历史最大值查询:Value #A
  • 积压总量查询:Value #B
  • 理论最大TPS查询:Value #C
  • 5分钟成功发送量查询:Value #D(注意修正查询内拼写错误:curreny改为currency)

3. 配置Join转换实现双字段关联

在面板「Transform」标签页操作:

  • 点击「Add transformation」,选择Join转换
  • 模式选择「Outer Join」(确保所有channel+currency组合都能显示,哪怕某条查询无对应数据)
  • 在「Join by fields」区域,点击「Add field」两次,分别选择channel和currency作为关联键(这是解决多currency列问题的核心)
  • 在「Fields to keep」中确认保留channel、currency以及四个别名对应的数值字段

4. 调整列顺序(可选)

添加「Organize fields」转换,拖拽列顺序,将channel和currency放在最左侧,后续依次排列Value #A至Value #D

修正后的完整查询语句

# Value #A: 历史最大成功发送量
max_over_time( sum (increase(voucher_send_total{status=~"success"}[5m])) by(channel, currency) )[2d]

# Value #B: 积压总量
sum (avg_over_time(voucher_backlog_total{})[5m]) by (channel, currency)

# Value #C: 5分钟理论最大TPS
300 / (avg by (channel, currency) (rate(voucher_requests_latency_seconds_sum{method="/voucher/send"}[5m]) / rate(voucher_requests_latency_seconds_count{method="/voucher/send"}[5m]))) * count by(channel, currency) (
 count by(channel, currency, id) (
  increase(voucher_wallets_total[24h]) > 0
 )
)

# Value #D: 5分钟成功发送量
sum (increase(voucher_send_total{status=~"success"}[5m])) by(channel, currency)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 06:25:17