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

如何用PromQL关联FortiGate主节点与受控交换机实例?

用PromQL关联FortiGate主节点与受控交换机数据

核心查询语句

要实现通过主节点序列号匹配对应instance,再关联受控交换机数据,可使用以下PromQL:

fortigate_managed_switch_info{status="Connected",state="Authorized"}
  * on(instance) group_left()
fortigate_ha_member_has_role{role="root_master"} == 1

逻辑说明

  • 第一部分fortigate_managed_switch_info{status="Connected",state="Authorized"}:筛选出已连接且处于授权状态的FortiSwitch数据
  • * on(instance) group_left():指定仅通过instance标签进行关联,group_left()确保保留左侧(交换机指标)的所有标签和数据,同时匹配右侧主节点指标的instance
  • 最后一部分fortigate_ha_member_has_role{role="root_master"} == 1:筛选出HA集群中的主节点,仅保留这些节点对应的instance

扩展需求:保留主节点序列号标签

如果需要在结果中同时显示主节点的序列号,可调整查询为:

fortigate_managed_switch_info{status="Connected",state="Authorized"}
  * on(instance) group_left(serial)
fortigate_ha_member_has_role{role="root_master"} == 1

该查询会将主节点的serial标签添加到交换机指标的结果中,方便直接对应到具体的FortiGate主设备。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 10:28:10