Skip to content

Feat: Embedded HTTP API Server #7

@antweiss

Description

@antweiss

Feature Requirements

FR1: Embedded HTTP API Server

Objective: Embed an HTTP server within the khook controller to expose event data via REST API

Technical Requirements:

  • Serve HTTP API on configurable port (default: 8082)
  • Support graceful startup/shutdown with controller lifecycle
  • Implement request routing, middleware, and error handling
  • Add authentication and authorization mechanisms
  • Include request logging and metrics collection

FR2: Event Query Endpoints

Objective: Provide REST endpoints for querying collected events with filtering capabilities

API Specification:

GET /api/v1/events
GET /api/v1/events/{namespace}
GET /api/v1/hooks/{namespace}/{name}/events
GET /api/v1/events/types/{eventType}

Query Parameters:

  • startTime & endTime: Time-based filtering (RFC3339 format)
  • eventType: Filter by event type (pod-restart, oom-kill, etc.)
  • resourceName: Filter by Kubernetes resource name
  • status: Filter by event status (firing, resolved, duplicate)
  • limit & offset: Pagination support
  • sort: Sort by timestamp, eventType, resourceName

FR3: Event Statistics and Aggregation

Objective: Provide aggregated event statistics and metrics via API

Endpoints:

GET /api/v1/stats/events/summary
GET /api/v1/stats/events/by-type
GET /api/v1/stats/hooks/{namespace}/{name}/metrics
GET /api/v1/stats/trends

Response Format:

{
  "summary": {
    "totalEvents": 1247,
    "activeEvents": 23,
    "duplicateEvents": 156,
    "timeRange": "24h"
  },
  "byType": {
    "pod-restart": {"count": 856, "percentage": 68.7},
    "oom-kill": {"count": 234, "percentage": 18.8},
    "pod-pending": {"count": 157, "percentage": 12.5}
  }
}

FR4: Real-time Event Streaming

Objective: Support real-time event streaming via WebSockets or Server-Sent Events

Technical Features:

  • WebSocket endpoint: ws://khook:8082/api/v1/events/stream
  • Server-Sent Events: GET /api/v1/events/stream with Accept: text/event-stream
  • Configurable event filtering for streams
  • Connection management and automatic reconnection
  • Rate limiting and backpressure handling

FR5: Hook Configuration Management

Objective: Provide API endpoints for managing Hook configurations

Endpoints:

GET /api/v1/hooks
GET /api/v1/hooks/{namespace}/{name}
POST /api/v1/hooks/validate

Features:

  • List all Hook configurations with status
  • Validate Hook configurations before deployment
  • Export Hook configurations in YAML format
  • Display Hook processing statistics

FR6: Health and Diagnostics

Objective: Provide comprehensive health monitoring and diagnostic information

Endpoints:

GET /api/v1/health
GET /api/v1/diagnostics
GET /api/v1/metrics

Health Information:

  • API server status and uptime
  • Event processing pipeline health
  • Kagent API connectivity status
  • Plugin status (for pluggable event sources)
  • Memory usage and performance metrics

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions