Skip to content

cpu metric采集问题 #11

@milkwine

Description

@milkwine

代码里默认cadvisor采集间隔为为 1s(1,000,000,000 nanoseconds)
Falcon中使用率都乘了100, 所以这里是1,000,000,000/100 = 10000000

if err := pushCount("cpu.busy", cpuuage1, cpuuage2, `{"total":`, `,"per_cpu_usage":`, countNum, timestamp, tags, containerId, endpoint, 10000000*float64(cpuNum)); err != nil {
return err
}
if err := pushCount("cpu.user", cpuuage1, cpuuage2, `"user":`, `,"sy`, countNum, timestamp, tags, containerId, endpoint, 10000000*float64(cpuNum)); err != nil {
return err
}
if err := pushCount("cpu.system", cpuuage1, cpuuage2, `"system":`, `},`, countNum, timestamp, tags, containerId, endpoint, 10000000*float64(cpuNum)); err != nil {
return err
}

cadvisor中计算方式: https://github.com/google/cadvisor/blob/76538e77a5cbec2f55376dec9836ecfd7cd5dd8a/pages/assets/js/containers.js#L215-L233

  1. 实际情况中接口http://localhost:8080/api/v1.2/docker 获取到的数据并不是严格的1s, 并且依赖cadvisor 运行时参数--housekeeping_interval默认为1s. 虽然可能没太大的影响, 但在能获取到时间戳的情况下,这样做实在不是一个科学的方式
  2. 关于cpuNum, cpu使用率是否要平均到每个core上有争议.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions