pydo.monitoring.get_droplet_cpu_metrics()

Description

To retrieve CPU metrics for a given droplet, send a GET request to /v2/monitoring/metrics/droplet/cpu.

Parameters

Name Type Required Description Default Value
host_id string True The droplet ID.
start string True UNIX timestamp to start metric window.
end string True UNIX timestamp to end metric window.

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))

resp = client.monitoring.get_droplet_cpu_metrics(host_id="17209102", start="1620683817", end="1620705417")

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

The response will be a JSON object with a key called data and status.

Click to expand an example response for CPU.
{
  "value": {
    "status": "success",
    "data": {
      "resultType": "matrix",
      "result": [
        {
          "metric": {
            "host_id": "222651441",
            "mode": "idle"
          },
          "values": [
            [
              1635386880,
              "122901.18"
            ],
            [
              1635387000,
              "123020.92"
            ],
            [
              1635387120,
              "123140.8"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "iowait"
          },
          "values": [
            [
              1635386880,
              "14.99"
            ],
            [
              1635387000,
              "15.01"
            ],
            [
              1635387120,
              "15.01"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "irq"
          },
          "values": [
            [
              1635386880,
              "0"
            ],
            [
              1635387000,
              "0"
            ],
            [
              1635387120,
              "0"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "nice"
          },
          "values": [
            [
              1635386880,
              "66.35"
            ],
            [
              1635387000,
              "66.35"
            ],
            [
              1635387120,
              "66.35"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "softirq"
          },
          "values": [
            [
              1635386880,
              "2.13"
            ],
            [
              1635387000,
              "2.13"
            ],
            [
              1635387120,
              "2.13"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "steal"
          },
          "values": [
            [
              1635386880,
              "7.89"
            ],
            [
              1635387000,
              "7.9"
            ],
            [
              1635387120,
              "7.91"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "system"
          },
          "values": [
            [
              1635386880,
              "140.09"
            ],
            [
              1635387000,
              "140.2"
            ],
            [
              1635387120,
              "140.23"
            ]
          ]
        },
        {
          "metric": {
            "host_id": "222651441",
            "mode": "user"
          },
          "values": [
            [
              1635386880,
              "278.57"
            ],
            [
              1635387000,
              "278.65"
            ],
            [
              1635387120,
              "278.69"
            ]
          ]
        }
      ]
    }
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}