GlintlogGlintlog

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/v1

Authentication

Include one of the following headers:

# JWT Token
Authorization: Bearer <access_token>

# API Key
X-Glintlog-Key: <api_key>

Health Check

GET /health

Returns server health status. No authentication required.

Response:

{
  "status": "ok",
  "version": "0.0.1_alpha"
}

Setup

Initialize Admin

POST /api/v1/setup/init

Create the initial admin account. Only works on first run.

Request:

{
  "email": "admin@example.com",
  "password": "secure-password"
}

Authentication

Login

POST /api/v1/auth/login

Request:

{
  "email": "user@example.com",
  "password": "password"
}

Response:

{
  "access_token": "eyJhbG...",
  "refresh_token": "eyJhbG...",
  "expires_in": 3600
}

Refresh Token

POST /api/v1/auth/refresh

Request:

{
  "refresh_token": "eyJhbG..."
}

Get Current User

GET /api/v1/auth/me

Response:

{
  "id": "user_abc123",
  "email": "user@example.com",
  "role": "admin",
  "created_at": "2024-01-15T10:30:00Z"
}

Logout

POST /api/v1/auth/logout

Invalidates the current session.

Request Password Reset

POST /api/v1/auth/password-reset/request

Request:

{
  "email": "user@example.com"
}

Complete Password Reset

POST /api/v1/auth/password-reset/complete

Request:

{
  "token": "reset-token",
  "new_password": "new-password"
}

Logs

Query Logs

GET /api/v1/logs

Query Parameters:

ParameterTypeDefaultDescription
startRFC3339-Start timestamp
endRFC3339-End timestamp
servicestring-Filter by service name
severitystring-Filter by level (DEBUG, INFO, WARN, ERROR, FATAL)
searchstring-Full-text search on body
api_key_namestring-Filter by ingestion API key
limitint100Max results (max: 10000)
offsetint0Pagination 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/tail

Returns Server-Sent Events stream.

Query Parameters:

ParameterTypeDescription
servicestringFilter by service name
severitystringFilter 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/histogram

Get log distribution over time.

Query Parameters:

ParameterTypeDescription
startRFC3339Start timestamp
endRFC3339End timestamp
servicestringFilter by service
intervalstringBucket 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/traces

Query Parameters:

ParameterTypeDescription
servicestringFilter by service
startRFC3339Start timestamp
endRFC3339End timestamp
min_durationintMinimum duration (ms)
max_durationintMaximum duration (ms)
statusstringFilter by status (OK, ERROR)
limitintMax results (default: 50)
offsetintPagination 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/services

Response:

{
  "services": [
    {"name": "api-server", "log_count": 15234},
    {"name": "worker", "log_count": 8921}
  ]
}

Statistics

Get Stats

GET /api/v1/stats

Response:

{
  "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/metrics

Response:

{
  "cpu_percent": 12.5,
  "memory_percent": 45.2,
  "memory_used_bytes": 1073741824,
  "goroutines": 42,
  "uptime_seconds": 86400
}

Storage Info

GET /api/v1/admin/storage

Response:

{
  "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/logs

Delete logs within a time range.

Query Parameters:

ParameterTypeDescription
startRFC3339Start timestamp
endRFC3339End timestamp

Compact Database

POST /api/v1/admin/compact

Trigger 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/settings

Request (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:

CodeDescription
400Bad request - invalid parameters
401Unauthorized - missing or invalid auth
403Forbidden - insufficient permissions
404Not found
500Internal server error

Rate Limiting

Glintlog does not enforce rate limits by default. Consider using a reverse proxy like nginx for production deployments.

On this page