# Read a service's logs

Source: https://openpanel.sh/docs/api/services/read-a-service-s-logs

The newest lines its running containers wrote, read live from each server through its agent and merged by time. Logs stay on the servers, so a server whose agent is away is listed in unreachable instead.

`GET https://openpanel.sh/api/v1/services/{serviceId}/logs`

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `serviceId` | path | yes | The service's id. |
| `tail` | query | no | How many lines, 1 to 1000. Default 100. |

## Responses

| Status | Meaning | Body |
|---|---|---|
| 200 | Read a service's logs | `application/json`, `ServiceLogs` |
| 401 | No valid credential was sent. | `application/problem+json`, `Problem` |
| 403 | The credential may not do this. | `application/problem+json`, `Problem` |
| 404 | Not found, or not visible to this credential. | `application/problem+json`, `Problem` |
| 422 | The input was refused; detail says why. | `application/problem+json`, `Problem` |
| 429 | Too many requests; wait for Retry-After seconds. | `application/problem+json`, `Problem` |

## Schemas

### LogLine

```json
{
  "type": "object",
  "properties": {
    "at": {
      "anyOf": [
        {
          "type": "string",
          "format": "date-time"
        },
        {
          "type": "null"
        }
      ],
      "description": "When the container wrote the line."
    },
    "serverId": {
      "type": "string",
      "format": "uuid"
    },
    "container": {
      "type": "string"
    },
    "replica": {
      "type": "integer"
    },
    "line": {
      "type": "string"
    }
  },
  "required": [
    "at",
    "serverId",
    "container",
    "replica",
    "line"
  ]
}
```

### Problem

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": "string",
      "description": "A link to the error's explanation in the docs."
    },
    "title": {
      "type": "string"
    },
    "status": {
      "type": "integer"
    },
    "code": {
      "type": "string",
      "description": "Stable machine-readable code: not_found, forbidden, invalid, conflict, rate_limited, not_implemented, …"
    },
    "detail": {
      "type": "string",
      "description": "What went wrong, in a sentence written for a person."
    }
  },
  "required": [
    "type",
    "title",
    "status",
    "code",
    "detail"
  ]
}
```

### ServiceLogs

```json
{
  "type": "object",
  "properties": {
    "data": {
      "type": "array",
      "items": {
        "$ref": "#/components/schemas/LogLine"
      },
      "description": "The newest lines of every replica, merged by time, oldest first."
    },
    "unreachable": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "serverId": {
            "type": "string",
            "format": "uuid"
          },
          "container": {
            "type": "string"
          },
          "reason": {
            "type": "string"
          }
        },
        "required": [
          "serverId",
          "container",
          "reason"
        ]
      },
      "description": "Containers whose server's agent could not be asked; their lines are missing."
    }
  },
  "required": [
    "data",
    "unreachable"
  ]
}
```