promQL 之 聚合函数

聚合函数

格式:<aggr-op>([parameter,] <vector expression>) [without|by (<label list>)]

  • sum 求和

    sum(kube_pod_container_status_restarts_total)
  • max 求最大值

    max(kube_pod_container_status_restarts_total)
  • mix 求最小值

    min(kube_pod_container_status_restarts_total)
  • avg 求平均

    avg(kube_pod_container_status_restarts_total)
  • count 计数

    count(kube_pod_container_status_restarts_total)
  • count_values 计数(符合指定值)

    示例中对重启次数为0 的 进行计数

    stdvar(0,kube_pod_container_status_restarts_total)
  • bottomk 统计后3

    bottomk(3,kube_pod_container_status_restarts_total)
  • topk 统计前3

    topk(3,kube_pod_container_status_restarts_total)
  • quantile 统计分位数

    什么是分位数?

    quantile(0,kube_pod_container_status_restarts_total)
  • stddev 求标准方差

    什么是标准方差?

    stddev(kube_pod_container_status_restarts_total)
  • stdvar 求方差

    stdvar(kube_pod_container_status_restarts_total)

上面是聚合函数的基本使用,promQL还支持使用 without,by 等参数对结果进行过滤

如果你使用过 sql 语句可以把它理解为groupby

sum(kube_pod_container_status_restarts_total) by(namespace)
sum(kube_pod_container_status_restarts_total) without(pod)
posted @   mingtian是吧  阅读(305)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· 葡萄城 AI 搜索升级:DeepSeek 加持,客户体验更智能
· 什么是nginx的强缓存和协商缓存
· 一文读懂知识蒸馏
点击右上角即可分享
微信分享提示