Question

Understand CPU metrics in API

Posted November 5, 2021 81 views
API

I was playing a bit with the API, but I dont understand the response. I would like to build a graph similar to the one seen in the control panel, but i don see the same values returned from the api.

The API responds with different metrics: idle, iowait, irq, nice, softirq, steal, system, user. For each of this metrics, there an array containing a timestamp and a value. But for example, in my graph for the past hour values are between 0 and 1%, with a small spike to 3%.
This are the values I got from the API:

{
  "status": "success",
  "data": {
    "resultType": "matrix",
    "result": [{
      "metric": {
        "host_id": "myhost",
        "mode": "idle"
      },
      "values": [
        [1636125120, "83048.67"],
        [1636125240, "83168.59"],
        [1636125360, "83288.49"],
        [1636125480, "83408.32"],
        [1636125600, "83524.46"],
        [1636125720, "83644.33"],
        [1636125840, "83764.23"],
        [1636125960, "83883.97"],
        [1636126080, "84003.88"],
        [1636126200, "84123.79"],
        [1636126320, "84243.62"],
        [1636126440, "84363.52"],
        [1636126560, "84483.33"],
        [1636126680, "84603.19"],
        [1636126800, "84723.11"],
        [1636126920, "84842.96"],
        [1636127040, "84842.96"],
        [1636127160, "85082.74"],
        [1636127280, "85202.63"],
        [1636127400, "85322.53"],
        [1636127520, "85442.33"],
        [1636127640, "85562.24"],
        [1636127760, "85681.29"],
        [1636127880, "85801.19"],
        [1636128000, "85921.03"],
        [1636128120, "86040.89"],
        [1636128240, "86160.72"],
        [1636128360, "86280.58"],
        [1636128480, "86400.37"],
        [1636128600, "86520.19"],
        [1636128720, "86640.11"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "iowait"
      },
      "values": [
        [1636125120, "13.13"],
        [1636125240, "13.13"],
        [1636125360, "13.13"],
        [1636125480, "13.13"],
        [1636125600, "13.2"],
        [1636125720, "13.22"],
        [1636125840, "13.22"],
        [1636125960, "13.23"],
        [1636126080, "13.23"],
        [1636126200, "13.24"],
        [1636126320, "13.24"],
        [1636126440, "13.24"],
        [1636126560, "13.25"],
        [1636126680, "13.26"],
        [1636126800, "13.26"],
        [1636126920, "13.26"],
        [1636127040, "13.26"],
        [1636127160, "13.27"],
        [1636127280, "13.27"],
        [1636127400, "13.27"],
        [1636127520, "13.28"],
        [1636127640, "13.28"],
        [1636127760, "13.31"],
        [1636127880, "13.32"],
        [1636128000, "13.32"],
        [1636128120, "13.33"],
        [1636128240, "13.34"],
        [1636128360, "13.35"],
        [1636128480, "13.35"],
        [1636128600, "13.37"],
        [1636128720, "13.37"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "irq"
      },
      "values": [
        [1636125120, "0"],
        [1636125240, "0"],
        [1636125360, "0"],
        [1636125480, "0"],
        [1636125600, "0"],
        [1636125720, "0"],
        [1636125840, "0"],
        [1636125960, "0"],
        [1636126080, "0"],
        [1636126200, "0"],
        [1636126320, "0"],
        [1636126440, "0"],
        [1636126560, "0"],
        [1636126680, "0"],
        [1636126800, "0"],
        [1636126920, "0"],
        [1636127040, "0"],
        [1636127160, "0"],
        [1636127280, "0"],
        [1636127400, "0"],
        [1636127520, "0"],
        [1636127640, "0"],
        [1636127760, "0"],
        [1636127880, "0"],
        [1636128000, "0"],
        [1636128120, "0"],
        [1636128240, "0"],
        [1636128360, "0"],
        [1636128480, "0"],
        [1636128600, "0"],
        [1636128720, "0"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "nice"
      },
      "values": [
        [1636125120, "86.52"],
        [1636125240, "86.52"],
        [1636125360, "86.52"],
        [1636125480, "86.52"],
        [1636125600, "86.52"],
        [1636125720, "86.52"],
        [1636125840, "86.52"],
        [1636125960, "86.52"],
        [1636126080, "86.52"],
        [1636126200, "86.52"],
        [1636126320, "86.52"],
        [1636126440, "86.52"],
        [1636126560, "86.52"],
        [1636126680, "86.52"],
        [1636126800, "86.52"],
        [1636126920, "86.52"],
        [1636127040, "86.52"],
        [1636127160, "86.52"],
        [1636127280, "86.52"],
        [1636127400, "86.52"],
        [1636127520, "86.52"],
        [1636127640, "86.52"],
        [1636127760, "86.52"],
        [1636127880, "86.52"],
        [1636128000, "86.52"],
        [1636128120, "86.52"],
        [1636128240, "86.52"],
        [1636128360, "86.52"],
        [1636128480, "86.52"],
        [1636128600, "86.52"],
        [1636128720, "86.52"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "softirq"
      },
      "values": [
        [1636125120, "2.45"],
        [1636125240, "2.45"],
        [1636125360, "2.45"],
        [1636125480, "2.45"],
        [1636125600, "2.46"],
        [1636125720, "2.46"],
        [1636125840, "2.46"],
        [1636125960, "2.46"],
        [1636126080, "2.46"],
        [1636126200, "2.46"],
        [1636126320, "2.46"],
        [1636126440, "2.46"],
        [1636126560, "2.47"],
        [1636126680, "2.47"],
        [1636126800, "2.47"],
        [1636126920, "2.47"],
        [1636127040, "2.47"],
        [1636127160, "2.47"],
        [1636127280, "2.47"],
        [1636127400, "2.47"],
        [1636127520, "2.47"],
        [1636127640, "2.47"],
        [1636127760, "2.47"],
        [1636127880, "2.47"],
        [1636128000, "2.47"],
        [1636128120, "2.47"],
        [1636128240, "2.47"],
        [1636128360, "2.48"],
        [1636128480, "2.48"],
        [1636128600, "2.48"],
        [1636128720, "2.48"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "steal"
      },
      "values": [
        [1636125120, "13.3"],
        [1636125240, "13.3"],
        [1636125360, "13.31"],
        [1636125480, "13.32"],
        [1636125600, "13.33"],
        [1636125720, "13.34"],
        [1636125840, "13.35"],
        [1636125960, "13.36"],
        [1636126080, "13.37"],
        [1636126200, "13.37"],
        [1636126320, "13.38"],
        [1636126440, "13.4"],
        [1636126560, "13.42"],
        [1636126680, "13.43"],
        [1636126800, "13.44"],
        [1636126920, "13.44"],
        [1636127040, "13.44"],
        [1636127160, "13.46"],
        [1636127280, "13.46"],
        [1636127400, "13.47"],
        [1636127520, "13.48"],
        [1636127640, "13.51"],
        [1636127760, "13.53"],
        [1636127880, "13.54"],
        [1636128000, "13.55"],
        [1636128120, "13.57"],
        [1636128240, "13.59"],
        [1636128360, "13.6"],
        [1636128480, "13.61"],
        [1636128600, "13.62"],
        [1636128720, "13.63"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "system"
      },
      "values": [
        [1636125120, "145.96"],
        [1636125240, "145.98"],
        [1636125360, "145.99"],
        [1636125480, "146.07"],
        [1636125600, "146.82"],
        [1636125720, "146.84"],
        [1636125840, "146.85"],
        [1636125960, "146.94"],
        [1636126080, "146.95"],
        [1636126200, "146.98"],
        [1636126320, "147.03"],
        [1636126440, "147.07"],
        [1636126560, "147.12"],
        [1636126680, "147.16"],
        [1636126800, "147.18"],
        [1636126920, "147.2"],
        [1636127040, "147.2"],
        [1636127160, "147.26"],
        [1636127280, "147.29"],
        [1636127400, "147.3"],
        [1636127520, "147.34"],
        [1636127640, "147.35"],
        [1636127760, "147.54"],
        [1636127880, "147.55"],
        [1636128000, "147.61"],
        [1636128120, "147.63"],
        [1636128240, "147.65"],
        [1636128360, "147.69"],
        [1636128480, "147.77"],
        [1636128600, "147.81"],
        [1636128720, "147.83"]
      ]
    }, {
      "metric": {
        "host_id": "myhost",
        "mode": "user"
      },
      "values": [
        [1636125120, "261.21"],
        [1636125240, "261.26"],
        [1636125360, "261.3"],
        [1636125480, "261.35"],
        [1636125600, "264.33"],
        [1636125720, "264.36"],
        [1636125840, "264.41"],
        [1636125960, "264.53"],
        [1636126080, "264.56"],
        [1636126200, "264.59"],
        [1636126320, "264.66"],
        [1636126440, "264.7"],
        [1636126560, "264.8"],
        [1636126680, "264.85"],
        [1636126800, "264.88"],
        [1636126920, "264.95"],
        [1636127040, "264.95"],
        [1636127160, "265.08"],
        [1636127280, "265.12"],
        [1636127400, "265.16"],
        [1636127520, "265.26"],
        [1636127640, "265.32"],
        [1636127760, "265.99"],
        [1636127880, "266.02"],
        [1636128000, "266.08"],
        [1636128120, "266.16"],
        [1636128240, "266.23"],
        [1636128360, "266.27"],
        [1636128480, "266.35"],
        [1636128600, "266.43"],
        [1636128720, "266.47"]
      ]
    }]
  }
}

How are is the control panel graph calculated from this kind of values?
Thanks

Submit an answer

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!