Documentation
¶
Index ¶
- func CreateIncident(c *fiber.Ctx) error
- func HandleAck(c *fiber.Ctx) error
- func HealthCheck(c *fiber.Ctx) error
- func MountStaticUI(app *fiber.App)
- func SNS(c *fiber.Ctx) error
- type AgentController
- func (a *AgentController) Register(router fiber.Router)
- func (a *AgentController) SetCatalogConfig(cat config.AgentCatalogConfig, poll time.Duration) *AgentController
- func (a *AgentController) SetCursorStore(cs *agent.CursorStore) *AgentController
- func (a *AgentController) SetSources(sources []core.SignalSource) *AgentController
- type ConfigAdminController
- type IncidentAdminController
- type ReportsAdminController
- type RunbookAdminController
- type SNSMessage
- type TeamsAdminController
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateIncident ¶
func HealthCheck ¶
func MountStaticUI ¶ added in v1.3.9
MountStaticUI registers the embedded UI at "/" with SPA fallback so client-side routes like /dashboard, /incidents/:id, /shadow/:id all resolve to index.html when the asset doesn't exist.
Call this AFTER all API/admin routes are registered; otherwise the catch-all would shadow them.
Types ¶
type AgentController ¶ added in v1.3.9
type AgentController struct {
// contains filtered or unexported fields
}
AgentController exposes admin endpoints for inspecting and curating the pattern catalog. All endpoints require the gateway secret configured under `agent.gateway_secret` (or env AGENT_GATEWAY_SECRET), sent in the `X-Gateway-Secret` header. When no secret is configured, every request is rejected — this is by design: an empty secret must not silently grant access.
func NewAgentController ¶ added in v1.3.9
func NewAgentController(cat *agent.Catalog, mn *agent.Miner, sl *agent.ShadowLog, dl *agent.DetectLog, ov *agent.ServiceOverrideStore, runbooksEnabled bool) *AgentController
NewAgentController wires the catalog, miner, shadow log, and detect log into a controller. Pass `cat=nil` if the agent is disabled — in that case every endpoint will return 503. `mn` is the shared drain miner; it may be nil (the patterns clear then wipes only the persisted patterns, not in-memory miner state). `sl` may be nil to disable the shadow endpoints, and `dl` may be nil to disable the detect-log endpoints. `ov` is the manual-attribution override store backing the service-override endpoints; it may be nil to disable them. `runbooksEnabled` tells the status endpoint whether the runbooks subsystem is available.
func (*AgentController) Register ¶ added in v1.3.9
func (a *AgentController) Register(router fiber.Router)
Register attaches the agent admin endpoints to the given fiber group.
Routes (under /api/agent):
GET /patterns list all patterns (sorted by Count desc)
GET /patterns/:id get one pattern
POST /patterns/:id update verdict / tags
DELETE /patterns/:id remove a pattern
DELETE /patterns wipe ALL learned log patterns (relearn fresh)
GET /status lightweight status (catalog size, dirty flag)
GET /shadow list shadow-mode "would have alerted" events
GET /shadow/stats aggregate counts for the shadow log
DELETE /shadow clear the shadow log
POST /shadow/flush force-flush the shadow log to disk
GET /services list known services with grace status
GET /services/:name aggregate detail for one service (meta + grace +
patterns + bounded incident summary)
POST /services create a manual service (selectable override target)
PUT /services/:name rename a manual service
DELETE /services/:name delete a manual service (blocked when overrides target it)
DELETE /services wipe ALL discovered/manual services (re-discover fresh)
POST /services/:name/grace control grace period (end / restart)
GET /service-overrides list manual-attribution override rules
POST /service-overrides create/replace one override rule
DELETE /service-overrides/:id delete one override rule
GET /detect list detect-mode AI calls (newest first)
GET /detect/stats aggregate counts for the detect log
GET /detect/:id get one detect-mode AI call (full prompt + response)
DELETE /detect clear the detect log
POST /detect/flush force-flush the detect log to disk
GET /ai/system-prompt the assembled system prompt sent on every AI call
func (*AgentController) SetCatalogConfig ¶ added in v1.4.7
func (a *AgentController) SetCatalogConfig(cat config.AgentCatalogConfig, poll time.Duration) *AgentController
SetCatalogConfig wires the catalog threshold + worker poll interval into the controller so listPatterns can attach a computed core.Readiness to each pattern row WITHOUT reaching into package globals. `cat.AutoPromoteAfter` supplies the readiness `Needed` gate (≤0 → indeterminate/manual-only) and `poll` converts each pattern's per-tick sighting EWMA into a per-minute arrival rate for the ETA. Optional and safe to omit: left unset the readiness degrades to Needed=0/RatePerMin=0 (renders as "Learning", no ETA), so a process that runs no worker still serves well-formed rows. Returns the receiver for fluent wiring.
func (*AgentController) SetCursorStore ¶ added in v1.4.7
func (a *AgentController) SetCursorStore(cs *agent.CursorStore) *AgentController
SetCursorStore wires the worker's poll-cursor store into the controller so that clearing the pattern catalog also rewinds every source cursor. This makes the SAME running worker re-read its lookback window and relearn immediately after a clear — the in-place equivalent of a fresh process start. It MUST be the exact CursorStore the worker mines through (shared pointer), or the rewind won't reach the worker's learn loop. Optional: when left unset (e.g. the agent runs no worker in this process), clearPatterns leaves cursors untouched. Returns the receiver for fluent wiring.
func (*AgentController) SetSources ¶ added in v1.4.7
func (a *AgentController) SetSources(sources []core.SignalSource) *AgentController
SetSources wires the worker's live signal sources into the controller so that clearing the pattern catalog can also rewind the read position of any source that keeps its OWN (a core.SourceRewinder — e.g. the file source's byte offset). Rewinding the poll cursor (SetCursorStore) only re-reads cursor-driven backends (Elasticsearch, Loki, …); a file source ignores the poll cursor, so without this it stays pinned at EOF after a clear and the SAME running worker never re-emits its backlog — the "clear stops learning until the container is recreated" halt. MUST be the exact source slice the worker polls (shared pointers). Optional and nil-safe: sources without their own position simply never implement SourceRewinder. Returns the receiver for fluent wiring.
type ConfigAdminController ¶ added in v1.3.9
type ConfigAdminController struct{}
ConfigAdminController exposes a read-only, secret-redacted view of the running config so the admin dashboard can render it without ever exposing tokens, passwords, or webhook URLs. Same gateway-secret guard as the rest of the admin surface.
func NewConfigAdminController ¶ added in v1.3.9
func NewConfigAdminController() *ConfigAdminController
func (*ConfigAdminController) Register ¶ added in v1.3.9
func (c *ConfigAdminController) Register(router fiber.Router)
Register attaches:
GET /api/admin/config/incidents alert channels + queue + on-call GET /api/admin/config/agent agent runtime config
type IncidentAdminController ¶ added in v1.3.9
type IncidentAdminController struct{}
IncidentAdminController exposes read endpoints for the persisted incident history. Same X-Gateway-Secret guard as the agent admin surface — see AgentController.authMiddleware.
func NewIncidentAdminController ¶ added in v1.3.9
func NewIncidentAdminController() *IncidentAdminController
NewIncidentAdminController returns a controller. No state of its own; the storage provider is read lazily via services.Storage().
func (*IncidentAdminController) Register ¶ added in v1.3.9
func (i *IncidentAdminController) Register(router fiber.Router)
Register attaches the admin endpoints under /api/admin/incidents.
GET /api/admin/incidents list (newest first; ?limit=NN) GET /api/admin/incidents/search full-text search (?q=&limit=NN) GET /api/admin/incidents/:id single record POST /api/admin/incidents/:id/resolve mark resolved (idempotent)
type ReportsAdminController ¶ added in v1.4.8
type ReportsAdminController struct{}
ReportsAdminController exposes the incidents-analytics report: render an aggregate dashboard PNG over a time window and deliver it to a channel, preview it, and read/update the runtime report settings. Window-scoped, not per-incident. Same X-Gateway-Secret guard as the rest of the admin surface.
func NewReportsAdminController ¶ added in v1.4.8
func NewReportsAdminController() *ReportsAdminController
NewReportsAdminController returns a controller. No state of its own; storage + renderer are read via the services seams.
func (*ReportsAdminController) Register ¶ added in v1.4.8
func (rc *ReportsAdminController) Register(router fiber.Router)
Register attaches the endpoints under /api/admin/reports.
POST /api/admin/reports/incidents render aggregate + send to a channel (?window=) GET /api/admin/reports/incidents/report.png render + return the PNG (?window=) GET /api/admin/reports/settings current runtime report settings PUT /api/admin/reports/settings update runtime report settings
type RunbookAdminController ¶ added in v1.4.4
type RunbookAdminController struct {
// contains filtered or unexported fields
}
RunbookAdminController exposes upload/list/get/delete for the runbook corpus that backs the find_runbook tool. Same X-Gateway-Secret guard as the other /api/agent/* admin controllers. Runbooks are managed by uploading `.md` files (multipart) — there is no free-text editor; to change a runbook, re-upload a file with the same name.
func NewRunbookAdminController ¶ added in v1.4.4
func NewRunbookAdminController(mgr *runbook.Manager) *RunbookAdminController
NewRunbookAdminController returns a controller backed by the runbook manager. Pass nil to disable the endpoints entirely (every request returns 503) — e.g. when storage is unavailable.
func (*RunbookAdminController) Register ¶ added in v1.4.4
func (c *RunbookAdminController) Register(router fiber.Router)
Register mounts the runbook admin routes:
GET /api/agent/runbooks list (metadata only) POST /api/agent/runbooks upload one or more `.md` files (field "files") GET /api/agent/runbooks/* get one (full body) DELETE /api/agent/runbooks/* delete one
The wildcard `*` carries the runbook ID, which may itself contain `/` (corpus-relative paths), so a `:id` param would not match nested IDs.
type SNSMessage ¶
type SNSMessage struct {
Type string `json:"Type"`
MessageId string `json:"MessageId"`
Token string `json:"Token,omitempty"` // Omit empty for Notification type
TopicArn string `json:"TopicArn"`
Message string `json:"Message"`
SubscribeURL string `json:"SubscribeURL,omitempty"` // Omit empty for Notification type
Timestamp string `json:"Timestamp"`
SignatureVersion string `json:"SignatureVersion"`
Signature string `json:"Signature"`
SigningCertURL string `json:"SigningCertURL"`
}
type TeamsAdminController ¶ added in v1.4.1
type TeamsAdminController struct {
// contains filtered or unexported fields
}
TeamsAdminController exposes CRUD for members and teams plus an incident-assignment endpoint. Same X-Gateway-Secret guard as the other /api/admin/* controllers.
func NewTeamsAdminController ¶ added in v1.4.1
func NewTeamsAdminController(s *teams.Store) *TeamsAdminController
NewTeamsAdminController returns a controller backed by the given teams store. Pass nil to disable the endpoints entirely (every request returns 503).
func (*TeamsAdminController) Register ¶ added in v1.4.1
func (c *TeamsAdminController) Register(router fiber.Router)
Register mounts the admin routes:
GET /api/admin/members list POST /api/admin/members create GET /api/admin/members/:id get one PATCH /api/admin/members/:id partial update DELETE /api/admin/members/:id delete (+ scrub team refs) GET /api/admin/teams list POST /api/admin/teams create GET /api/admin/teams/:id get one PATCH /api/admin/teams/:id partial update DELETE /api/admin/teams/:id delete POST /api/admin/incidents/:id/assign assign team + members