API Reference
Complete REST API documentation
Glintlog exposes a RESTful API for all operations. All endpoints (except setup and auth) require authentication.
Base URL
http://localhost:8080/api/v1Authentication
Include one of the following headers:
# JWT Token
Authorization: Bearer <access_token>
# API Key
X-Glintlog-Key: <api_key>Health Check
GET /healthReturns server health status. No authentication required.
Response:
{
"status": "ok",
"version": "0.0.1_alpha"
}Setup
Initialize Admin
POST /api/v1/setup/initCreate the initial admin account. Only works on first run.
Request:
{
"email": "admin@example.com",
"password": "secure-password"
}Authentication
Login
POST /api/v1/auth/loginRequest:
{
"email": "user@example.com",
"password": "password"
}Response:
{
"access_token": "eyJhbG...",
"refresh_token": "eyJhbG...",
"expires_in": 3600
}Refresh Token
POST /api/v1/auth/refreshRequest:
{
"refresh_token": "eyJhbG..."
}Get Current User
GET /api/v1/auth/meResponse:
{
"id": "user_abc123",
"email": "user@example.com",
"role": "admin",
"created_at": "2024-01-15T10:30:00Z"
}Logout
POST /api/v1/auth/logoutInvalidates the current session.
Request Password Reset
POST /api/v1/auth/password-reset/requestRequest:
{
"email": "user@example.com"
}Complete Password Reset
POST /api/v1/auth/password-reset/completeRequest:
{
"token": "reset-token",
"new_password": "new-password"
}Logs
Query Logs
GET /api/v1/logsQuery Parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
start | RFC3339 | - | Start timestamp |
end | RFC3339 | - | End timestamp |
service | string | - | Filter by service name |
severity | string | - | Filter by level (DEBUG, INFO, WARN, ERROR, FATAL) |
search | string | - | Full-text search on body |
api_key_name | string | - | Filter by ingestion API key |
limit | int | 100 | Max results (max: 10000) |
offset | int | 0 | Pagination offset |
Response:
{
"logs": [
{
"timestamp": "2024-01-15T10:30:00.123Z",
"service_name": "api-server",
"severity": "INFO",
"body": "Request processed",
"trace_id": "abc123...",
"span_id": "def456...",
"attributes": {"key": "value"}
}
],
"total": 1523,
"has_more": true
}Live Tail
GET /api/v1/logs/tailReturns Server-Sent Events stream.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
service | string | Filter by service name |
severity | string | Filter by severity |
Response (SSE):
data: {"timestamp":"2024-01-15T10:30:00Z","service_name":"api-server","severity":"INFO","body":"New entry"}
data: {"timestamp":"2024-01-15T10:30:01Z","service_name":"api-server","severity":"DEBUG","body":"Another entry"}Histogram
GET /api/v1/logs/histogramGet log distribution over time.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
start | RFC3339 | Start timestamp |
end | RFC3339 | End timestamp |
service | string | Filter by service |
interval | string | Bucket interval (1m, 5m, 1h, 1d) |
Response:
{
"buckets": [
{"timestamp": "2024-01-15T10:00:00Z", "count": 1523},
{"timestamp": "2024-01-15T11:00:00Z", "count": 892}
]
}Traces
List Traces
GET /api/v1/tracesQuery Parameters:
| Parameter | Type | Description |
|---|---|---|
service | string | Filter by service |
start | RFC3339 | Start timestamp |
end | RFC3339 | End timestamp |
min_duration | int | Minimum duration (ms) |
max_duration | int | Maximum duration (ms) |
status | string | Filter by status (OK, ERROR) |
limit | int | Max results (default: 50) |
offset | int | Pagination offset |
Response:
{
"traces": [
{
"trace_id": "abc123...",
"root_span_name": "HTTP POST /orders",
"services": ["api-gateway", "order-service"],
"duration_ms": 250,
"span_count": 5,
"status": "OK",
"started_at": "2024-01-15T10:30:00Z"
}
],
"total": 156,
"has_more": true
}Get Trace
GET /api/v1/traces/{traceId}Response:
{
"trace_id": "abc123...",
"spans": [
{
"span_id": "def456...",
"parent_span_id": null,
"name": "HTTP POST /orders",
"service_name": "api-gateway",
"start_time": "2024-01-15T10:30:00.000Z",
"end_time": "2024-01-15T10:30:00.250Z",
"duration_ms": 250,
"status": "OK",
"attributes": {}
}
],
"services": ["api-gateway", "order-service"],
"total_duration_ms": 250
}Services
List Services
GET /api/v1/servicesResponse:
{
"services": [
{"name": "api-server", "log_count": 15234},
{"name": "worker", "log_count": 8921}
]
}Statistics
Get Stats
GET /api/v1/statsResponse:
{
"total_logs": 26496,
"total_traces": 1523,
"services": 3,
"storage_bytes": 52428800,
"oldest_log": "2024-01-01T00:00:00Z",
"newest_log": "2024-01-15T10:30:00Z"
}Admin Endpoints
All admin endpoints require admin role.
System Metrics
GET /api/v1/admin/metricsResponse:
{
"cpu_percent": 12.5,
"memory_percent": 45.2,
"memory_used_bytes": 1073741824,
"goroutines": 42,
"uptime_seconds": 86400
}Storage Info
GET /api/v1/admin/storageResponse:
{
"database_size_bytes": 52428800,
"partitions": [
{"name": "logs_2024_01_15", "row_count": 15234, "size_bytes": 5242880},
{"name": "logs_2024_01_14", "row_count": 12000, "size_bytes": 4194304}
]
}Delete Logs
DELETE /api/v1/admin/logsDelete logs within a time range.
Query Parameters:
| Parameter | Type | Description |
|---|---|---|
start | RFC3339 | Start timestamp |
end | RFC3339 | End timestamp |
Compact Database
POST /api/v1/admin/compactTrigger database compaction.
Users
GET /api/v1/admin/users
POST /api/v1/admin/users
DELETE /api/v1/admin/users/{userId}API Keys
GET /api/v1/admin/api-keys
POST /api/v1/admin/api-keys
DELETE /api/v1/admin/api-keys/{keyId}Settings
GET /api/v1/admin/settings
PUT /api/v1/admin/settingsRequest (PUT):
{
"retention_days": 30,
"batch_size": 1000,
"flush_interval": "5s"
}Error Responses
All errors follow this format:
{
"error": "unauthorized",
"message": "Invalid or expired token"
}Common Status Codes:
| Code | Description |
|---|---|
| 400 | Bad request - invalid parameters |
| 401 | Unauthorized - missing or invalid auth |
| 403 | Forbidden - insufficient permissions |
| 404 | Not found |
| 500 | Internal server error |
Rate Limiting
Glintlog does not enforce rate limits by default. Consider using a reverse proxy like nginx for production deployments.