【Linux】Prometheus 查询

参考资料

pod cpu

查询pod下container的cpu占用

1. 确定查询容器
container_cpu_usage_seconds_total{namespace="sock-shop",container="carts", id="/kubepods/burstable/pod42a15090-5083-4c90-93fe-77973f6fdbb7/298b492e238a7c885975362df24822afbf83cede7e6aa5a32d1d23423224d2b8"}
2. 计算公式
sum(irate(container_cpu_usage_seconds_total{id="/kubepods/burstable/pod42a15090-5083-4c90-93fe-77973f6fdbb7/298b492e238a7c885975362df24822afbf83cede7e6aa5a32d1d23423224d2b8"}[5m])*100)by(pod)
3. 这个准
sum(irate(container_cpu_usage_seconds_total{*****}[5m])*100)by(pod)/sum(container_spec_cpu_quota{*****}/container_spec_cpu_period{*****})by(pod)
id="/kubepods/burstable/pode5798637-d493-43f3-8306-580041fdeb12/ea8518bf58773dfd8800d075050aebcfb246f2f3e9327bfe2a509f59ccf02f1c"

A 
sum(irate(container_cpu_usage_seconds_total{    }[5m])*100)by(pod)/sum(container_spec_cpu_quota{   }/container_spec_cpu_period{   })by(pod)
B
container_memory_working_set_bytes{   }*100/container_spec_memory_limit_bytes{ } 
C
container_memory_usage_bytes{    }
D
irate(container_fs_io_time_seconds_total{   }[5m])

id="/kubepods/besteffort/pod7b192088-a12c-4b76-8c74-4da95491b19a/43bacab874606a4ee06a7fbd8a61c75e4e0e98ea07964a1cd627d3d38b0a5d05"
E
irate(container_network_transmit_bytes_total{   }[5m])
F
irate(container_network_receive_bytes_total{   }[1m])

1. cpu使用率
sum(irate(container_cpu_usage_seconds_total{*****}[5m])*100)by(pod)/sum(container_spec_cpu_quota{*****}/container_spec_cpu_period{*****})by(pod)

2. 内存使用率
https://www.cnblogs.com/suyj/p/15621392.html
https://wenku.baidu.com/view/33dc785332b765ce0508763231126edb6f1a76a6.html

container_memory_rss{*****}*100/container_spec_memory_limit_bytes{*****}
container_memory_working_set_bytes{*****}*100/container_spec_memory_limit_bytes{*****} 也或者这个?

3. 内存使用量
container_memory_usage_bytes{*****}

4. 每秒内IO用时
irate(container_fs_io_time_seconds_total{*****}[1m])

5. 每秒网络传输数据量
irate(container_network_transmit_bytes_total{*****}[5m])
6. 每秒网络接受数据量
irate(container_network_receive_bytes_total{*****}[1m])
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Linux上搭建Prometheus,可以按照以下步骤进行操作: 1. 首先,从Prometheus官方网站(https://prometheus.io/download)下载最新的二进制包。 2. 解压下载的二进制包。可以使用以下命令解压到当前目录: ``` tar xvfz prometheus-*.tar.gz ``` 3. 进入解压后的目录: ``` cd prometheus-* ``` 4. 创建一个存放配置文件的目录: ``` mkdir -p /etc/prometheus ``` 5. 将默认的配置文件复制到/etc/prometheus目录下: ``` cp prometheus.yml /etc/prometheus/ ``` 6. 编辑配置文件以定义您需要监控的目标。打开/etc/prometheus/prometheus.yml,并根据需要进行编辑。 7. (可选)如果您还想监控其他目标,可以在配置文件中添加相关的job配置。 8. 创建一个存放数据的目录: ``` mkdir -p /var/lib/prometheus ``` 9. (可选)为Prometheus创建一个非特权用户: ``` useradd --no-create-home --shell /bin/false prometheus ``` 10. 修改数据和配置文件的所有权: ``` chown -R prometheus:prometheus /var/lib/prometheus chown -R prometheus:prometheus /etc/prometheus ``` 11. 启动Prometheus服务: ``` ./prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/var/lib/prometheus --web.enable-admin-api ``` 12. 验证Prometheus是否正在运行。在Web浏览器中访问http://localhost:9090,并确保可以正常访问Prometheus的用户界面。 这样,您就在Linux上成功搭建了Prometheus。您可以继续配置和使用Prometheus来监控您的目标。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值