Dispra Docs

Cloud › Logs and shell

Stream a service's logs

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

Streams what the service's live deployment writes, as Server-Sent Events. It starts with the newest 100 lines (tail to choose 0 to 750), then follows.

Each line is event: line with {at, level, message, replica}; a comment is sent every 15 seconds. If more than 750 lines arrive at once, the newest 750 are sent after event: gap with how many were skipped. Reconnect with since or Last-Event-ID to continue where you left off.

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
  • tail number, optional: Start with the newest N lines, 0 to 750 (default 100). Example: 200
  • since timestamp, optional: Continue after this line's time.

Returns

  • 200: A text/event-stream.

Errors

StatusCodeWhen
400invalid_tailtail is 0 to 750.
404not_foundNo such object in the key's project (or environment).

Request samples

Dispra Cloud CLI

dcloud logs api -n 200

cURL

curl "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200" \
  -H "Authorization: Bearer dsp_live_YOUR_KEY"

Node

const res = await fetch("https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200", {
  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/logs/stream", headers={"Authorization": "Bearer dsp_live_YOUR_KEY"}, params={"tail": "200"})
print(res.json())

Go

req, _ := http.NewRequest("GET", "https://devapi.dispralabs.com/v1/cloud/services/svc_01jdk3n2f4g6h8j0k2l4z6x8ca/logs/stream?tail=200", nil)
req.Header.Set("Authorization", "Bearer dsp_live_YOUR_KEY")
res, _ := http.DefaultClient.Do(req)

Responses

200

{}

400 invalid_tail

{
  "error": {
    "code": "invalid_tail",
    "message": "tail is 0 to 750.",
    "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"
  }
}

Related