docs(runtime-logs): implement runtime log management features
Добавлены новые возможности для работы с файловыми логами Docker-сервисов: - Эндпоинты для получения списка логов и хвоста лог-файла. - Очистка лог-файлов с возможностью выбора режима (truncate или delete) и запись в аудит очистки. - Обновлена документация и конфигурация для поддержки новых функций. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -101,6 +101,17 @@ EVOBGP_BUNDLE_SEED_HEX=<32 bytes hex, стабильный>
|
||||
|
||||
После `deploy_apply` CP шлёт `POST https://AGENT_DOMAIN/v1/agent/sync` с `Authorization: Bearer <agent_secret>`. На реплике — `EVOBGP_AGENT_SECRET`, Traefik `PANEL_IP_WHITELIST`. Подробнее: [remote-speakers.md](remote-speakers.md).
|
||||
|
||||
## Runtime log-файлы (`EVOBGP_RUNTIME_LOGS_DIR`)
|
||||
|
||||
Файловые логи Docker-сервисов (sidecar `stack-runtime-logs` в compose) читаются API **только** в процессе **`evobgp-all`**, когда заданы обе переменные:
|
||||
|
||||
```text
|
||||
EVOBGP_SERVICE=evobgp-all
|
||||
EVOBGP_RUNTIME_LOGS_DIR=/opt/evobgp/runtime-logs
|
||||
```
|
||||
|
||||
В dev-профиле compose каталог на хосте обычно `./runtime-logs`, в контейнере — mount на `/opt/evobgp/runtime-logs`. Если каталог не задан или роль процесса не `evobgp-all`, эндпоинты `/v1/runtime-logs/*` отвечают **503** (`runtime_logs_unavailable`). Очистка файлов — роль **operator+**; операции пишутся в таблицу `runtime_log_cleanup_audit`.
|
||||
|
||||
## CORS для веб-интерфейса
|
||||
|
||||
Браузерные запросы с другого origin требуют заголовков CORS на API. Задайте список разрешённых origin через **`EVOBGP_CORS_ORIGINS`** (через запятую), например:
|
||||
|
||||
@@ -53,6 +53,11 @@ tags:
|
||||
description: Наблюдаемость PostgreSQL и корреляция (instance-level, viewer+). Maintenance — operator.
|
||||
- name: Maintenance
|
||||
description: Политики обслуживания PostgreSQL (instance-scoped). CRUD и запуск — operator.
|
||||
- name: RuntimeLogs
|
||||
description: |
|
||||
Файловые runtime-логи Docker-сервисов (каталог EVOBGP_RUNTIME_LOGS_DIR).
|
||||
Доступно только в процессе evobgp-all с примонтированным volume; иначе 503.
|
||||
Просмотр — viewer+; очистка — operator+ (синхронно, с audit).
|
||||
|
||||
security:
|
||||
- bearerAuth: []
|
||||
@@ -1060,6 +1065,109 @@ components:
|
||||
has_more:
|
||||
type: boolean
|
||||
|
||||
RuntimeLogCleanupMode:
|
||||
type: string
|
||||
enum: [truncate, delete]
|
||||
description: |
|
||||
truncate — обнулить файл (по умолчанию); delete — удалить файл с диска.
|
||||
|
||||
RuntimeLogFile:
|
||||
type: object
|
||||
required: [name, size_bytes, modified_at]
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: Basename файла (*.log) в каталоге runtime-логов.
|
||||
pattern: '^[a-z0-9][a-z0-9_.-]*\.log$'
|
||||
size_bytes:
|
||||
type: integer
|
||||
format: int64
|
||||
minimum: 0
|
||||
modified_at:
|
||||
type: string
|
||||
format: date-time
|
||||
|
||||
RuntimeLogFileList:
|
||||
type: object
|
||||
required: [items]
|
||||
properties:
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/RuntimeLogFile"
|
||||
|
||||
RuntimeLogTail:
|
||||
type: object
|
||||
required: [filename, content, truncated, lines_returned]
|
||||
properties:
|
||||
filename:
|
||||
type: string
|
||||
content:
|
||||
type: string
|
||||
description: UTF-8 текст хвоста файла.
|
||||
truncated:
|
||||
type: boolean
|
||||
description: true если применён лимит bytes/lines.
|
||||
lines_returned:
|
||||
type: integer
|
||||
minimum: 0
|
||||
|
||||
RuntimeLogCleanupResult:
|
||||
type: object
|
||||
required: [audit_id, filename, action, size_before]
|
||||
properties:
|
||||
audit_id:
|
||||
$ref: "#/components/schemas/ResourceId"
|
||||
filename:
|
||||
type: string
|
||||
action:
|
||||
$ref: "#/components/schemas/RuntimeLogCleanupMode"
|
||||
size_before:
|
||||
type: integer
|
||||
format: int64
|
||||
size_after:
|
||||
type: ["integer", "null"]
|
||||
format: int64
|
||||
|
||||
RuntimeLogCleanupAudit:
|
||||
type: object
|
||||
required: [id, tenant_id, actor_prefix, filename, action, size_before, created_at]
|
||||
properties:
|
||||
id:
|
||||
$ref: "#/components/schemas/ResourceId"
|
||||
tenant_id:
|
||||
$ref: "#/components/schemas/ResourceId"
|
||||
actor_prefix:
|
||||
type: string
|
||||
filename:
|
||||
type: string
|
||||
action:
|
||||
$ref: "#/components/schemas/RuntimeLogCleanupMode"
|
||||
size_before:
|
||||
type: integer
|
||||
format: int64
|
||||
size_after:
|
||||
type: ["integer", "null"]
|
||||
format: int64
|
||||
detail:
|
||||
type: object
|
||||
additionalProperties: true
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
|
||||
RuntimeLogCleanupAuditList:
|
||||
type: object
|
||||
properties:
|
||||
items:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/RuntimeLogCleanupAudit"
|
||||
next_cursor:
|
||||
type: string
|
||||
has_more:
|
||||
type: boolean
|
||||
|
||||
BirdLocalStatus:
|
||||
type: object
|
||||
description: Статус локального BIRD на хосте API (GET /v1/bird/status).
|
||||
@@ -3761,6 +3869,148 @@ paths:
|
||||
default:
|
||||
$ref: "#/components/responses/DefaultProblem"
|
||||
|
||||
/v1/runtime-logs/files:
|
||||
get:
|
||||
tags: [RuntimeLogs]
|
||||
summary: Список runtime log-файлов
|
||||
description: |
|
||||
Список *.log в EVOBGP_RUNTIME_LOGS_DIR (размер и mtime).
|
||||
Требуется evobgp-all с примонтированным volume.
|
||||
operationId: listRuntimeLogFiles
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/TenantId"
|
||||
responses:
|
||||
"200":
|
||||
description: Успешно.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuntimeLogFileList"
|
||||
"503":
|
||||
description: Runtime logs недоступны (не evobgp-all или каталог не настроен).
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
default:
|
||||
$ref: "#/components/responses/DefaultProblem"
|
||||
|
||||
/v1/runtime-logs/files/{filename}:
|
||||
get:
|
||||
tags: [RuntimeLogs]
|
||||
summary: Хвост runtime log-файла
|
||||
operationId: getRuntimeLogTail
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/TenantId"
|
||||
- name: filename
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
pattern: '^[a-z0-9][a-z0-9_.-]*\.log$'
|
||||
description: Basename файла (без пути).
|
||||
- name: lines
|
||||
in: query
|
||||
schema:
|
||||
type: integer
|
||||
minimum: 1
|
||||
maximum: 2000
|
||||
default: 200
|
||||
- name: bytes
|
||||
in: query
|
||||
schema:
|
||||
type: integer
|
||||
minimum: 1
|
||||
maximum: 262144
|
||||
description: Альтернатива lines; при указании обоих — более строгий лимит.
|
||||
- name: grep
|
||||
in: query
|
||||
schema:
|
||||
type: string
|
||||
maxLength: 128
|
||||
description: Опциональный подстрочный фильтр (после чтения хвоста).
|
||||
responses:
|
||||
"200":
|
||||
description: Успешно.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuntimeLogTail"
|
||||
"404":
|
||||
$ref: "#/components/responses/NotFound"
|
||||
"503":
|
||||
description: Runtime logs недоступны.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
default:
|
||||
$ref: "#/components/responses/DefaultProblem"
|
||||
delete:
|
||||
tags: [RuntimeLogs]
|
||||
summary: Очистить runtime log-файл
|
||||
description: |
|
||||
Синхронная очистка (truncate по умолчанию или delete). Запись в cleanup audit.
|
||||
Максимальный размер файла для очистки — 512 MiB. Только operator+.
|
||||
operationId: deleteRuntimeLogFile
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/TenantId"
|
||||
- name: filename
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
pattern: '^[a-z0-9][a-z0-9_.-]*\.log$'
|
||||
- name: mode
|
||||
in: query
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuntimeLogCleanupMode"
|
||||
description: По умолчанию truncate.
|
||||
responses:
|
||||
"200":
|
||||
description: Файл очищен.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuntimeLogCleanupResult"
|
||||
"403":
|
||||
$ref: "#/components/responses/Forbidden"
|
||||
"404":
|
||||
$ref: "#/components/responses/NotFound"
|
||||
"413":
|
||||
description: Файл превышает лимит 512 MiB.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
"503":
|
||||
description: Runtime logs недоступны.
|
||||
content:
|
||||
application/problem+json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/Problem"
|
||||
default:
|
||||
$ref: "#/components/responses/DefaultProblem"
|
||||
|
||||
/v1/runtime-logs/cleanup-audit:
|
||||
get:
|
||||
tags: [RuntimeLogs]
|
||||
summary: Audit очистки runtime log-файлов
|
||||
operationId: listRuntimeLogCleanupAudit
|
||||
parameters:
|
||||
- $ref: "#/components/parameters/TenantId"
|
||||
- $ref: "#/components/parameters/Cursor"
|
||||
- $ref: "#/components/parameters/Limit"
|
||||
responses:
|
||||
"200":
|
||||
description: Успешно.
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: "#/components/schemas/RuntimeLogCleanupAuditList"
|
||||
default:
|
||||
$ref: "#/components/responses/DefaultProblem"
|
||||
|
||||
/v1/settings:
|
||||
get:
|
||||
tags: [Settings]
|
||||
|
||||
Reference in New Issue
Block a user