# Get a server's metrics

Get the server's CPU, memory, disk space, disk reads and writes, and uptime.

[endpoint]
method = "GET"
base_url = "https://{availability_zone}.betterstackcloud.com"
path = "/v1/servers/{id}/metrics"

[[path_param]]
name = "id"
required = true
type = "string"
description = "The ID of the server."

[[query_param]]
name = "from"
type = "datetime"
description = "The start of the range. Defaults to 24 hours before `to`. Sending `from` or `to` returns a series over time. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[query_param]]
name = "to"
type = "datetime"
description = "The end of the range. Defaults to now. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[header]]
name = "Authorization"
description = "Bearer `$TOKEN`"
required = true
type = "string"
[/endpoint]

[responses]
[[response]]
status = 200
description = "Without `from` and `to`, you get a live reading, and the server must be running. Send `from` or `to` to get a series over time instead, which works in any status. A range longer than a day has one point per hour."
body = '''
{
  "server_id": "123456789",
  "server_name": "Example",
  "sampled_at": "2026-07-01T12:00:00.000Z",
  "uptime": {
    "started_at": "2026-07-01T12:00:00.000Z",
    "seconds": 1
  },
  "cpu": {
    "usage_percent": 1.5,
    "vcpus": 1
  },
  "memory": {
    "used_bytes": 1,
    "total_bytes": 1,
    "usage_percent": 1.5
  },
  "disk": {
    "space": {
      "used_bytes": 1,
      "total_bytes": 1,
      "usage_percent": 1.5
    },
    "io": {
      "read_bytes_per_second": 1,
      "write_bytes_per_second": 1
    }
  },
  "cpu_credits": {
    "balance_vcpu_minutes": 1.5,
    "cap_vcpu_minutes": 1.5,
    "baseline_vcpus": 1.5,
    "baseline_percent": 1,
    "capped": false,
    "cap_reason": "example",
    "updated_at": "2026-07-01T12:00:00.000Z"
  },
  "from": "2026-07-01T12:00:00.000Z",
  "to": "2026-07-01T12:00:00.000Z",
  "resolution": "raw",
  "data": [
    {
      "dt": "2026-07-01T12:00:00.000Z",
      "cpu": {
        "usage_percent": 1.5,
        "vcpus": 1
      },
      "memory": {
        "used_bytes": 1,
        "total_bytes": 1,
        "usage_percent": 1.5
      },
      "disk": {
        "space": {
          "used_bytes": 1,
          "total_bytes": 1,
          "usage_percent": 1.5
        },
        "io": {
          "read_bytes_per_second": 1,
          "write_bytes_per_second": 1
        }
      },
      "uptime_seconds": 1,
      "traffic": {
        "bytes_in": 1,
        "bytes_out": 1,
        "bytes_in_intra_az": 1,
        "bytes_out_intra_az": 1
      }
    }
  ]
}
'''

[[response]]
status = 400
description = "The body isn't valid JSON."
body = '''
{
  "error": {
    "message": "Malformed JSON body.",
    "code": "bad_request"
  }
}
'''

[[response]]
status = 401
description = "The API token is missing or invalid."
body = '''
{
  "error": {
    "message": "Missing or invalid token.",
    "code": "unauthorized"
  }
}
'''

[[response]]
status = 402
description = "The organization hasn't made its first payment yet, and the request creates a resource we charge for. The code is `payment_required`. A request that creates a server, load balancer, object cache, database, reserved IP or volume can also return `first_purchase`. The `url` in `first_purchase` opens a page where you make the payment. The resource is created after the payment. The page works until `expires_at`, 24 hours after the response."
body = '''
{
  "error": {
    "message": "We require at least one successful credit card transaction before allowing billable actions via the API. This significantly helps us to prevent fraud. Once your first transaction is processed, you will be able to use the API unrestricted. Please add credit to your account at https://betterstack.com/settings/billing/card/new?credits=10&activate_api=true. Need help? We're here for you at hello@betterstack.com.",
    "code": "payment_required"
  }
}
'''

[[response]]
status = 403
description = "A rule of the resource forbids the request."

[[response]]
status = 404
description = "The resource doesn't exist, it's in another zone, or your token can't access it."
body = '''
{
  "error": {
    "message": "Resource not found.",
    "code": "not_found"
  }
}
'''

[[response]]
status = 409
description = "You asked for a live reading, but the server isn't running. The code is `server_not_running`."

[[response]]
status = 422
description = "The range can't be read, ends before it starts or is longer than 366 days. The code is `invalid_range`."

[[response]]
status = 423
description = "We've locked the resource, with the code `locked`. Every change to a locked resource is refused, and so is a change that involves one."

[[response]]
status = 429
description = "Too many requests, with the code `rate_limited`. We limit requests per client IP and per organization, and some costly endpoints have a stricter limit. Wait as long as the `Retry-After` header says."

[[response]]
status = 500
description = "An unexpected, temporary error on our side, with the code `internal_error`. Try again."
body = '''
{
  "error": {
    "message": "The request could not be completed right now. Please try again in a few moments.",
    "code": "internal_error"
  }
}
'''

[[response]]
status = 503
description = "We couldn't read the metrics. The code is `metrics_unavailable`. Try again."
[/responses]

[params]
title = "Response attributes"

[[param]]
name = "server_id"
type = "string"
description = "The server's ID, a UUID. Both a live reading and a series have it."

[[param]]
name = "server_name"
type = "string"
description = "The server's name. Both a live reading and a series have it."

[[param]]
name = "sampled_at"
type = "datetime or null"
description = "When we read the values. Only a live reading has it. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "uptime"
type = "object or null"
description = "How long the server has run since it last started. Only a live reading has it."

[[param]]
name = "uptime.started_at"
type = "datetime or null"
description = "In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "uptime.seconds"
type = "integer or null"
description = "The seconds."

[[param]]
name = "cpu"
type = "object or null"
description = "CPU use as a percentage of all the server's vCPUs. Only a live reading has it, and each point of a series has its own."

[[param]]
name = "cpu.usage_percent"
type = "number or null"
description = "The usage percent."

[[param]]
name = "cpu.vcpus"
type = "integer"
description = "The vcpus."

[[param]]
name = "memory"
type = "object or null"
description = "The server's memory use. Only a live reading has it, and each point of a series has its own."

[[param]]
name = "memory.used_bytes"
type = "integer or null"
description = "The used bytes."

[[param]]
name = "memory.total_bytes"
type = "integer"
description = "The total bytes."

[[param]]
name = "memory.usage_percent"
type = "number or null"
description = "The usage percent."

[[param]]
name = "disk"
type = "object or null"
description = "The disk space used out of the root disk, and the disk read and write rates. Only a live reading has it, and each point of a series has its own."

[[param]]
name = "disk.space"
type = "object"
description = "The space."

[[param]]
name = "disk.space.used_bytes"
type = "integer or null"
description = "The used bytes."

[[param]]
name = "disk.space.total_bytes"
type = "integer"
description = "The total bytes."

[[param]]
name = "disk.space.usage_percent"
type = "number or null"
description = "The usage percent."

[[param]]
name = "disk.io"
type = "object"
description = "The io."

[[param]]
name = "disk.io.read_bytes_per_second"
type = "integer or null"
description = "The read bytes per second."

[[param]]
name = "disk.io.write_bytes_per_second"
type = "integer or null"
description = "The write bytes per second."

[[param]]
name = "cpu_credits"
type = "object or null"
description = "The CPU credit balance of a shared or spot server. Only a live reading has it. A dedicated server doesn't have it, and neither does a server in a zone without a CPU budget."

[[param]]
name = "cpu_credits.balance_vcpu_minutes"
type = "number"
description = "The balance vcpu minutes."

[[param]]
name = "cpu_credits.cap_vcpu_minutes"
type = "number"
description = "The cap vcpu minutes."

[[param]]
name = "cpu_credits.baseline_vcpus"
type = "number"
description = "The baseline vcpus."

[[param]]
name = "cpu_credits.baseline_percent"
type = "integer"
description = "The baseline percent."

[[param]]
name = "cpu_credits.capped"
type = "boolean"
description = "The capped."

[[param]]
name = "cpu_credits.cap_reason"
type = "string or null"
description = "The cap reason."

[[param]]
name = "cpu_credits.updated_at"
type = "datetime or null"
description = "In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "from"
type = "datetime or null"
description = "The start of the range returned. Only a series has it. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "to"
type = "datetime or null"
description = "The end of the range returned. Only a series has it. In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "resolution"
type = "string or null"
description = "How far apart the points are. Only a series has it.<br/>Valid values:<br/>`raw`: One point per minute, for a range of up to one day.<br/>`hourly`: One point per hour, for a longer range."

[[param]]
name = "data"
type = "array of objects or null"
description = "The points of the series, oldest first. Only a series has it. A minute or hour with no sample has no point. `traffic` counts the bytes sent and received in each point's interval. For hourly points, the bytes inside the zone, `bytes_in_intra_az` and `bytes_out_intra_az`, are `null`."

[[param]]
name = "data[].dt"
type = "datetime"
description = "In ISO 8601 format, such as `2026-07-01T12:00:00Z`."

[[param]]
name = "data[].cpu"
type = "object"
description = "The cpu."

[[param]]
name = "data[].cpu.usage_percent"
type = "number"
description = "The usage percent."

[[param]]
name = "data[].cpu.vcpus"
type = "integer"
description = "The vcpus."

[[param]]
name = "data[].memory"
type = "object"
description = "The memory."

[[param]]
name = "data[].memory.used_bytes"
type = "integer"
description = "The used bytes."

[[param]]
name = "data[].memory.total_bytes"
type = "integer"
description = "The total bytes."

[[param]]
name = "data[].memory.usage_percent"
type = "number or null"
description = "The usage percent."

[[param]]
name = "data[].disk"
type = "object"
description = "The disk."

[[param]]
name = "data[].disk.space"
type = "object"
description = "The space."

[[param]]
name = "data[].disk.space.used_bytes"
type = "integer"
description = "The used bytes."

[[param]]
name = "data[].disk.space.total_bytes"
type = "integer"
description = "The total bytes."

[[param]]
name = "data[].disk.space.usage_percent"
type = "number or null"
description = "The usage percent."

[[param]]
name = "data[].disk.io"
type = "object"
description = "The io."

[[param]]
name = "data[].disk.io.read_bytes_per_second"
type = "integer"
description = "The read bytes per second."

[[param]]
name = "data[].disk.io.write_bytes_per_second"
type = "integer"
description = "The write bytes per second."

[[param]]
name = "data[].uptime_seconds"
type = "integer"
description = "The uptime seconds."

[[param]]
name = "data[].traffic"
type = "object"
description = "The traffic."

[[param]]
name = "data[].traffic.bytes_in"
type = "integer"
description = "The bytes in."

[[param]]
name = "data[].traffic.bytes_out"
type = "integer"
description = "The bytes out."

[[param]]
name = "data[].traffic.bytes_in_intra_az"
type = "integer or null"
description = "The bytes in intra az."

[[param]]
name = "data[].traffic.bytes_out_intra_az"
type = "integer or null"
description = "The bytes out intra az."
[/params]
