我正在尝试为磁盘空间预测做一个仪表板。我有一个像这样的普罗米修斯:
predict_linear(
(1-(disk_volume_available_bytes{instance=~"$server"} / disk_volume_total_bytes{instance=~"$server"}))[32d:1d],
864000
) > 0.95
它可以很好地将磁盘列表切割到那些真正需要关注的磁盘。然后我想做的是有另一个查询(在同一个面板或不同的一个-对我来说无关紧要),从前面的列表中识别任何磁盘,并获得实际/观察到的指标。换句话说,如果预测磁盘的满率超过95%,那么我既需要预测线,也需要该磁盘的实际使用数据。如果预测低于95%,则不显示任何预测或实际的内容。
这可能吗?
下面的示例显示了CPU利用率超过30%(0.3)的实例的node_exporter_build_info
:
node_exporter_build_info # this is the metric you want to see filtered
and on (instance) # and the rest is the filter terms, you won't see this on the panel
((1 - avg by(instance) (rate(node_cpu_seconds_total{mode="idle"}[5m]))) > 0.3)
这里棘手的部分是在一些标签上连接度量级数,这样就没有多对一连接。在上面的示例中,唯一的标签是instance
,但在您的示例中也可能有device
或mountpoint
,因此您可能需要这样的内容:
the_metric_you_wanna_see
and on (instance, device, mountpoint) # put here a list of unique labels
(predict_linear(
(1-(disk_volume_available_bytes{instance=~"$server"} / disk_volume_total_bytes{instance=~"$server"}))[32d:1d],
864000
) > 0.95)
此外,由于所讨论的查询计算成本相当高,并且需要重复一次或两次,因此我建议让Prometheus预先计算它:https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/