Dispra Docs

Cloud › Services

Get service metrics

GET https://devapi.dispralabs.com/v1/cloud/services/:svc/metrics

Returns CPU, memory and network out for the service and each replica over a range, from one-minute windows, with the limits in force.

Needs a key with read access or more.

  • Authentication: Secret key (send it as Authorization: Bearer <key>)

Parameters

  • svc string, required: The service's id. Example: svc_01jdk3n2f4g6h8j0k2l4z6x8ca
  • range string, optional: 1h, 3h, 24h, 7d or 30d (default 24h). Example: 24h

Returns

Errors

StatusCodeWhen
400invalid_rangerange is 1h, 3h, 24h, 7d or 30d.
404not_foundNo such object in the key's project (or environment).

Request samples

Dispra Cloud CLI

dcloud api GET /v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h

cURL

curl "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h" \
  -H "Authorization: Bearer dsp_live_YOUR_KEY"

Node

const res = await fetch("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h", {
  method: "GET",
  headers: { Authorization: "Bearer dsp_live_YOUR_KEY" },
});
console.log(await res.json());

Python

import requests
res = requests.request("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics", headers={"Authorization": "Bearer dsp_live_YOUR_KEY"}, params={"range": "24h"})
print(res.json())

Go

req, _ := http.NewRequest("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/metrics?range=24h", nil)
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
res, _ := http.DefaultClient.Do(req)

Responses

200

{
  "data": {
    "range": "24h",
    "step_s": 300,
    "series": {"cpu_millis":[[1764324900,412]],"memory_mb":[[1764324900,618]]},
    "replicas": [{"replica":"r1","cpu_millis":[[1764324900,205]]}],
    "limits": {"cpu_millis":1000,"memory_mb":1024}
  }
}

400 invalid_range

{
  "error": {
    "code": "invalid_range",
    "message": "range is 1h, 3h, 24h, 7d or 30d.",
    "request_id": "req_7f3a9c21d84be056"
  }
}

404 not_found

{
  "error": {
    "code": "not_found",
    "message": "No such object in the key's project (or environment).",
    "request_id": "req_7f3a9c21d84be056"
  }
}