Documentation
¶
Overview ¶
Package api provides HTTP handlers for the eBPF monitoring system.
@title eBPF Network Monitor API @description HTTP API for eBPF-based network connection and packet drop monitoring @version 1.0.0 @host localhost:8080 @BasePath / @contact.name API Support @contact.url https://github.com/srodi/ebpf-server/issues @contact.email support@example.com @license.name MIT @license.url https://github.com/srodi/ebpf-server/blob/main/LICENSE
Index ¶
- func HandleConnectionSummary(w http.ResponseWriter, r *http.Request)
- func HandleEvents(w http.ResponseWriter, r *http.Request)
- func HandleHealth(w http.ResponseWriter, r *http.Request)
- func HandleListConnections(w http.ResponseWriter, r *http.Request)
- func HandleListPacketDrops(w http.ResponseWriter, r *http.Request)
- func HandlePacketDropSummary(w http.ResponseWriter, r *http.Request)
- func HandlePrograms(w http.ResponseWriter, r *http.Request)
- func Initialize(sys *system.System)
- type ConnectionListResponse
- type ConnectionSummaryRequest
- type ConnectionSummaryResponse
- type PacketDropListResponse
- type PacketDropSummaryRequest
- type PacketDropSummaryResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HandleConnectionSummary ¶
func HandleConnectionSummary(w http.ResponseWriter, r *http.Request)
HandleConnectionSummary provides connection event summaries.
@Summary Get connection statistics
@Description Get count of connection events filtered by PID, command, and time window
@Tags connections
@Accept json
@Produce json
@Param pid query int false "Process ID (GET only)"
@Param command query string false "Command name (GET only)"
@Param duration_seconds query int false "Duration in seconds (GET only, default: 60)"
@Param request body ConnectionSummaryRequest false "Connection summary request (POST only)"
@Success 200 {object} ConnectionSummaryResponse "Connection statistics"
@Failure 400 {object} map[string]string "Bad request"
@Failure 500 {object} map[string]string "Internal server error"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /api/connection-summary [get]
@Router /api/connection-summary [post]
func HandleEvents ¶ added in v0.0.2
func HandleEvents(w http.ResponseWriter, r *http.Request)
HandleEvents returns events matching query parameters.
@Summary Query events
@Description Get events filtered by type, PID, command, time range, and limit
@Tags events
@Accept json
@Produce json
@Param type query string false "Event type (connection, packet_drop)"
@Param pid query int false "Process ID"
@Param command query string false "Command name"
@Param since query string false "Start time (RFC3339 format)"
@Param until query string false "End time (RFC3339 format)"
@Param limit query int false "Maximum number of events to return (default: 100)"
@Success 200 {object} map[string]interface{} "Filtered events"
@Failure 500 {object} map[string]string "Internal server error"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /api/events [get]
func HandleHealth ¶
func HandleHealth(w http.ResponseWriter, r *http.Request)
HandleHealth responds with system health information.
@Summary Health check
@Description Get the health status of the eBPF monitoring system
@Tags health
@Accept json
@Produce json
@Success 200 {object} map[string]interface{} "Health status"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /health [get]
func HandleListConnections ¶
func HandleListConnections(w http.ResponseWriter, r *http.Request)
HandleListConnections returns recent connection events.
@Summary List connection events
@Description Get recent connection events grouped by PID
@Tags connections
@Accept json
@Produce json
@Success 200 {object} ConnectionListResponse "Connection events"
@Failure 500 {object} map[string]string "Internal server error"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /api/list-connections [get]
func HandleListPacketDrops ¶ added in v0.0.2
func HandleListPacketDrops(w http.ResponseWriter, r *http.Request)
HandleListPacketDrops returns recent packet drop events.
@Summary List packet drop events
@Description Get recent packet drop events grouped by PID
@Tags packet_drops
@Accept json
@Produce json
@Success 200 {object} PacketDropListResponse "Packet drop events"
@Failure 500 {object} map[string]string "Internal server error"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /api/list-packet-drops [get]
func HandlePacketDropSummary ¶ added in v0.0.2
func HandlePacketDropSummary(w http.ResponseWriter, r *http.Request)
HandlePacketDropSummary provides packet drop event summaries.
@Summary Get packet drop statistics
@Description Get count of packet drop events filtered by PID, command, and time window
@Tags packet_drops
@Accept json
@Produce json
@Param pid query int false "Process ID (GET only)"
@Param command query string false "Command name (GET only)"
@Param duration_seconds query int false "Duration in seconds (GET only, default: 60)"
@Param request body PacketDropSummaryRequest false "Packet drop summary request (POST only)"
@Success 200 {object} PacketDropSummaryResponse "Packet drop statistics"
@Failure 400 {object} map[string]string "Bad request"
@Failure 500 {object} map[string]string "Internal server error"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /api/packet-drop-summary [get]
@Router /api/packet-drop-summary [post]
func HandlePrograms ¶ added in v0.0.2
func HandlePrograms(w http.ResponseWriter, r *http.Request)
HandlePrograms returns the status of all eBPF programs.
@Summary List eBPF programs
@Description Get the status and information of all loaded eBPF programs
@Tags programs
@Accept json
@Produce json
@Success 200 {object} map[string]interface{} "List of eBPF programs"
@Failure 500 {object} map[string]string "Internal server error"
@Failure 503 {object} map[string]string "Service unavailable"
@Router /api/programs [get]
func Initialize ¶ added in v0.0.2
Initialize sets up the API with the system instance.
Types ¶
type ConnectionListResponse ¶ added in v0.0.2
type ConnectionListResponse struct {
TotalPIDs int `json:"total_pids" example:"3"` // Number of unique PIDs
TotalEvents int `json:"total_events" example:"10"` // Total number of events
EventsByPID map[uint32][]core.Event `json:"events_by_pid"` // Events grouped by PID
QueryTime string `json:"query_time" example:"2023-01-01T12:00:00Z"` // Query timestamp
}
ConnectionListResponse represents the response for listing connections
type ConnectionSummaryRequest ¶
type ConnectionSummaryRequest struct {
PID uint32 `json:"pid" example:"1234"` // Process ID
Command string `json:"command" example:"curl"` // Command name
Duration int `json:"duration_seconds" example:"60"` // Duration in seconds
}
ConnectionSummaryRequest represents the request body for connection summary
type ConnectionSummaryResponse ¶
type ConnectionSummaryResponse struct {
Count int `json:"count" example:"5"` // Number of connection events
PID uint32 `json:"pid" example:"1234"` // Process ID
Command string `json:"command" example:"curl"` // Command name
DurationSeconds int `json:"duration_seconds" example:"60"` // Duration in seconds
QueryTime string `json:"query_time" example:"2023-01-01T12:00:00Z"` // Query timestamp
}
ConnectionSummaryResponse represents the response for connection summary
type PacketDropListResponse ¶ added in v0.0.2
type PacketDropListResponse struct {
TotalPIDs int `json:"total_pids" example:"2"` // Number of unique PIDs
TotalEvents int `json:"total_events" example:"7"` // Total number of events
EventsByPID map[uint32][]core.Event `json:"events_by_pid"` // Events grouped by PID
QueryTime string `json:"query_time" example:"2023-01-01T12:00:00Z"` // Query timestamp
}
PacketDropListResponse represents the response for listing packet drops
type PacketDropSummaryRequest ¶ added in v0.0.2
type PacketDropSummaryRequest struct {
PID uint32 `json:"pid" example:"1234"` // Process ID
Command string `json:"command" example:"nginx"` // Command name
Duration int `json:"duration_seconds" example:"60"` // Duration in seconds
}
PacketDropSummaryRequest represents the request body for packet drop summary
type PacketDropSummaryResponse ¶ added in v0.0.2
type PacketDropSummaryResponse struct {
Count int `json:"count" example:"3"` // Number of packet drop events
PID uint32 `json:"pid" example:"1234"` // Process ID
Command string `json:"command" example:"nginx"` // Command name
DurationSeconds int `json:"duration_seconds" example:"60"` // Duration in seconds
QueryTime string `json:"query_time" example:"2023-01-01T12:00:00Z"` // Query timestamp
}
PacketDropSummaryResponse represents the response for packet drop summary