首页 > 解决方案 > 在普罗米修斯上如何根据特定标签提取指标

问题描述

团队,

我形成了一个查询,也有结果,但无法通过标签过滤它。

我想根据 mountpoint / 和 /raid 进一步过滤我的结果。我该怎么做?询问

(kube_pod_info{namespace="monitoring",node=~"(team|wkr).*"}
* 
on(pod) group_right(node) 
(
max by(instance, namespace, pod, device, mountpoint) (
(
  node_filesystem_size_bytes{fstype=~"ext[234]|btrfs|xfs|zfs"} 
  - 
  node_filesystem_avail_bytes{fstype=~"ext[234]|btrfs|xfs|zfs"}
) 
/ 
node_filesystem_size_bytes{fstype=~"ext[234]|btrfs|xfs|zfs"}
)
))

输出

{device="/dev/sdb1",instance="101.1.1.1:1401",mountpoint="/raid",namespace="monitoring",node="team11",pod="prometheus-node-exporter-dcp-173-4l2dr"} 
{device="/dev/sdb1",instance="101.1.1.1:1401",mountpoint="/",namespace="monitoring",node="team11",pod="prometheus-node-exporter-dcp-173-4l2dr"} 

我正在使用的工作如下

yes want to see based on either of those two [/ or /raid] like using grep on results obtained..but i figure out a work around by setting them in expression itself like below

```node_filesystem_size_bytes{fstype=~"ext[234]|btrfs|xfs|zfs", mountpoint="/raid"`

如此完整的表达将是

(kube_pod_info{namespace="monitoring",node=~"(team|wkr).*"}
* 
on(pod) group_right(node) 
(
max by(instance, namespace, pod, device, mountpoint) (
(
  node_filesystem_size_bytes{fstype=~"ext[234]|btrfs|xfs|zfs",mountpoint="/raid"} 
  - 
  node_filesystem_avail_bytes{fstype=~"ext[234]|btrfs|xfs|zfs",mountpoint="/raid"}
) 
/ 
node_filesystem_size_bytes{fstype=~"ext[234]|btrfs|xfs|zfs",mountpoint="/raid"}
)
))

标签: prometheus

解决方案


推荐阅读