Documentation
¶
Overview ¶
Package store holds an imported workspace in memory. Data becomes visible one complete chunk at a time, and every change bumps a revision so readers can describe a consistent view while an import is still running.
Index ¶
- Constants
- Variables
- type AccessEdge
- type AgwRequest
- type Bucket
- type Collection
- type Diagnostic
- type ErrorMinute
- type Event
- type FieldCounter
- type FieldValues
- type Flow
- type FlowFileResult
- type ImportState
- type LineLoc
- type LiveState
- type LogFilter
- type LogResult
- type LogStreamKey
- type Object
- type ObjectHit
- type ObjectResult
- type SQLResult
- type Suggestion
- type TimeBucket
- type TimeEvent
- type Timeline
- type TimelineFilter
- type Trust
- type Workspace
- func (w *Workspace) AccessEdges(cluster string) []AccessEdge
- func (w *Workspace) AddCRD(cluster string, crd map[string]any)
- func (w *Workspace) AddCollectionLog(lines []json.RawMessage)
- func (w *Workspace) AddDiagnostic(cluster, kind, ns, pod, file string, data []byte)
- func (w *Workspace) AddEvents(cluster string, items []map[string]any)
- func (w *Workspace) AddFlows(fs []Flow) error
- func (w *Workspace) AddLogLines(cluster, ns, pod, container, stream string, lines []string, chunk string)
- func (w *Workspace) AddObjects(cluster string, r bundle.APIResource, items []map[string]any, chunk string)
- func (w *Workspace) AddReviewerFlows(cluster, name string, r io.Reader, format string) (FlowFileResult, error)
- func (w *Workspace) AgentTimeline(f TimelineFilter) Timeline
- func (w *Workspace) AgentgatewayRequests(cluster string) []AgwRequest
- func (w *Workspace) AllLogStreams() []LogStreamKey
- func (w *Workspace) AllObjects(cluster string) []*Object
- func (w *Workspace) CRD(cluster, group, resource string) map[string]any
- func (w *Workspace) CRDs(cluster string) []map[string]any
- func (w *Workspace) Close() error
- func (w *Workspace) Clusters() []string
- func (w *Workspace) CollectionLog() []json.RawMessage
- func (w *Workspace) CollectionState(cluster, group, resource, kind string, namespaced bool) Collection
- func (w *Workspace) Coverage() []bundle.Coverage
- func (w *Workspace) CoverageRecord(id string) (bundle.Coverage, bool)
- func (w *Workspace) DBPath() string
- func (w *Workspace) DeleteEvent(cluster, ns, name string) bool
- func (w *Workspace) DeleteObject(cluster, group, resource, ns, name string) bool
- func (w *Workspace) Diagnostic(cluster, kind, ns, pod string) *Diagnostic
- func (w *Workspace) DiagnosticSummary(cluster string) json.RawMessage
- func (w *Workspace) Diagnostics(cluster string) []Diagnostic
- func (w *Workspace) ErrorMinutes(cluster string, min int) []ErrorMinute
- func (w *Workspace) Events(cluster string) []Event
- func (w *Workspace) FindLogs(query string, limit int) ([]*logs.Record, error)
- func (w *Workspace) FindResource(cluster, name string) (bundle.APIResource, bool)
- func (w *Workspace) Flows(cluster string) []Flow
- func (w *Workspace) FlowsFrom(cluster, source string) []Flow
- func (w *Workspace) Get(cluster, group, resource, ns, name string) *Object
- func (w *Workspace) HasChunk(name string) bool
- func (w *Workspace) HasStream(cluster, ns, pod, container, stream string) bool
- func (w *Workspace) Header() *bundle.Header
- func (w *Workspace) ImportFlowFile(cluster, name string, r io.Reader, format, origin string) (FlowFileResult, error)
- func (w *Workspace) IsLive() bool
- func (w *Workspace) LineLocation(id int64) (*LineLoc, error)
- func (w *Workspace) LineLocations(f LogFilter, max int) ([]LineLoc, int, error)
- func (w *Workspace) List(cluster, group, resource, ns string, labels map[string]string) []*Object
- func (w *Workspace) LogContext(id int64, n int) []*logs.Record
- func (w *Workspace) LogFields(query, cluster string, maxFields, maxValues int) ([]FieldValues, error)
- func (w *Workspace) LogStream(cluster, ns, pod, container, stream string) []*logs.Record
- func (w *Workspace) LogStreamFrom(cluster, ns, pod, container, stream string, from int) []*logs.Record
- func (w *Workspace) LogStreamLines() map[LogStreamKey]int
- func (w *Workspace) Manifest() *bundle.Manifest
- func (w *Workspace) MarkChunk(name string)
- func (w *Workspace) Policy() *policy.Policy
- func (w *Workspace) PutCoverage(c bundle.Coverage)
- func (w *Workspace) QueueLogLines(cluster, ns, pod, container, stream string, lines []string, chunk string, ...)
- func (w *Workspace) Redaction() json.RawMessage
- func (w *Workspace) RegisterResources(cluster string, rs []bundle.APIResource)
- func (w *Workspace) RegisteredResources(cluster string) []bundle.APIResource
- func (w *Workspace) RemoveDiagnostic(cluster, kind, ns, pod string)
- func (w *Workspace) Resources(cluster string) []bundle.APIResource
- func (w *Workspace) Revision() int64
- func (w *Workspace) SQL(query string, limit int) (*SQLResult, error)
- func (w *Workspace) SearchLogs(f LogFilter) (*LogResult, error)
- func (w *Workspace) SearchObjects(query, cluster string, limit int) (*ObjectResult, error)
- func (w *Workspace) SetCoverage(c bundle.Coverage)
- func (w *Workspace) SetDiagnosticSummary(cluster string, raw json.RawMessage)
- func (w *Workspace) SetHeader(h *bundle.Header)
- func (w *Workspace) SetLedger(raw json.RawMessage)
- func (w *Workspace) SetManifest(m *bundle.Manifest)
- func (w *Workspace) SetRedaction(raw json.RawMessage)
- func (w *Workspace) SetSignature(r sign.Result)
- func (w *Workspace) SetState(fn func(*ImportState))
- func (w *Workspace) SetVersion(cluster string, raw json.RawMessage)
- func (w *Workspace) State() ImportState
- func (w *Workspace) Streams(cluster, ns, pod string) []string
- func (w *Workspace) Subscribe() (<-chan struct{}, func())
- func (w *Workspace) SuggestLogs(field, prefix, query, cluster string, limit int) ([]Suggestion, error)
- func (w *Workspace) SuggestObjects(field, prefix, query, cluster string, limit int) ([]Suggestion, error)
- func (w *Workspace) TrimLogs(max int) int
- func (w *Workspace) Trust() Trust
- func (w *Workspace) UpsertEvent(cluster string, obj map[string]any)
- func (w *Workspace) UpsertObject(cluster string, r bundle.APIResource, obj map[string]any) bool
- func (w *Workspace) Version(cluster string) json.RawMessage
- func (w *Workspace) WaitLogs()
Constants ¶
const ( OriginLogs = "logs" OriginBundle = "bundle" OriginReviewer = "reviewer" )
Origins of a flow row.
const ( PhaseWaiting = "waiting" PhaseLoading = "loading" PhaseComplete = "complete" PhaseFailed = "failed" PhaseCancelled = "cancelled" )
Import phases.
const ( StateComplete = "complete" StateLoading = "loading" StateExcluded = "excluded" StateFailed = "failed" StateTruncated = "truncated" StateNotCollected = "not-collected" // StateRemoved: the customer took the whole type out in review. StateRemoved = "removed" // StateTrimmed: the customer removed some objects of the type in review; // the rest are here, but absence proves nothing. StateTrimmed = "trimmed" )
Collection states shown to users.
const PhaseLive = "live"
PhaseLive is a workspace that mirrors a running cluster: the initial list has completed and watches keep it up to date.
const SourceLive = "live"
SourceLive marks a header written by flightbay-desk live.
const SuggestLimit = 50
SuggestLimit caps how many suggestions a call returns.
const SynthesisedAnnotation = "flightbay.dev/synthesised"
SynthesisedAnnotation marks objects the workspace built rather than captured.
Variables ¶
var AgwRequestFields = []string{
"gateway", "listener", "route", "endpoint", "src.addr", "src.identity", "jwt.sub",
"http.method", "http.host", "http.status", "protocol", "reason",
"mcp.method.name", "mcp.method", "mcp.target", "mcp.resource.type", "gen_ai.tool.name", "mcp.tool.name", "mcp.tool", "gen_ai.prompt.name",
"a2a.method", "gen_ai.operation.name", "gen_ai.provider.name", "llm.provider", "gen_ai.request.model", "gen_ai.response.model",
}
AgwRequestFields are the request log fields AgentgatewayRequests groups on. Names come from agentgateway's request logger (crates/agentgateway/src/telemetry/log.rs); older builds used mcp.method and mcp.tool, and llm.provider before gen_ai.provider.name.
var ErrNotReadOnly = errors.New("only read-only queries are allowed: SELECT, WITH, FROM, DESCRIBE, SHOW, SUMMARIZE, EXPLAIN")
ErrNotReadOnly rejects statements that could change the workspace.
Functions ¶
This section is empty.
Types ¶
type AccessEdge ¶
type AccessEdge struct {
Cluster string `json:"cluster"`
SrcNamespace string `json:"srcNamespace"`
SrcPod string `json:"srcPod"`
SrcIdentity string `json:"srcIdentity"`
DstService string `json:"dstService"` // host, e.g. name.ns.svc.cluster.local, or an external host
DstNamespace string `json:"dstNamespace"`
DstWorkload string `json:"dstWorkload"`
Methods []string `json:"methods"`
Paths []string `json:"paths"` // up to five examples
Requests int `json:"requests"`
Denied int `json:"denied"` // 401/403 responses or policy rejections
DstIdentity string `json:"dstIdentity,omitempty"`
// HBONE counts connections carried over HBONE (mutual TLS between
// ztunnels, port 15008); Plaintext counts the rest. Both are per side, the
// larger taken, like Requests.
HBONE int `json:"hbone"`
Plaintext int `json:"plaintext"`
BytesSent int64 `json:"bytesSent,omitempty"` // by the source
BytesRecv int64 `json:"bytesRecv,omitempty"`
First time.Time `json:"first"`
Last time.Time `json:"last"`
// Connections counts connection lines (scope access) and HTTPRequests
// request lines (scope http_access in some ztunnel builds); Requests is both.
Connections int `json:"connections"`
HTTPRequests int `json:"httpRequests"`
}
AccessEdge is traffic seen in mesh access logs between a source pod and a destination Service, aggregated over the capture.
type AgwRequest ¶
type AgwRequest struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"` // of the gateway pod that logged it
Pod string `json:"pod"`
Fields map[string]string `json:"fields"`
Count int `json:"count"`
InputTokens int64 `json:"inputTokens,omitempty"`
OutputTokens int64 `json:"outputTokens,omitempty"`
CacheRead int64 `json:"cacheRead,omitempty"`
CacheWrite int64 `json:"cacheWrite,omitempty"`
Cost float64 `json:"cost,omitempty"`
First time.Time `json:"first"`
Last time.Time `json:"last"`
// Error is one example of the error field, when the group has one.
Error string `json:"error,omitempty"`
}
AgwRequest is a group of agentgateway request log lines that agree on every field the activity map keeps. Token counts and cost are summed over the group rather than grouped on.
type Collection ¶
type Collection struct {
State string `json:"state"`
Reason string `json:"reason,omitempty"`
Items int `json:"items"`
}
Collection is the state of one resource collection.
type Diagnostic ¶
type Diagnostic struct {
Cluster string `json:"cluster"`
Kind string `json:"kind"` // proxies or control-plane
Namespace string `json:"namespace"`
Pod string `json:"pod"`
Component string `json:"component"`
Container string `json:"container"`
Image string `json:"image"`
Version string `json:"version"`
Node string `json:"node"`
Files map[string][]byte `json:"-"`
}
Diagnostic is one component's captured admin output.
type ErrorMinute ¶
ErrorMinute counts error lines in one namespace in one minute.
type Event ¶
type Event struct {
Cluster string `json:"cluster"`
Obj map[string]any `json:"object"`
RV int64 `json:"-"` // revision the event was stored at; watches use it to spot updates
}
Event is a captured Kubernetes event.
type FieldCounter ¶
FieldCounter is one value and how many matching lines carry it.
type FieldValues ¶
type FieldValues struct {
Field string `json:"field"`
Count int `json:"count"`
Values []FieldCounter `json:"values"`
}
FieldValues is one parsed field with its most common values.
type Flow ¶
Flow is one observed connection or request, normalised from any source: ztunnel, agentgateway, Envoy (waypoints and sidecars), CoreDNS query logs, or flow logs imported alongside the bundle (Cilium Hubble, Calico, AWS, GCP and Azure VPC flow logs, or a generic CSV/JSON). Endpoints are named when the source names them and otherwise carried as IPs; internal/reach resolves IPs to workloads from the captured pod, Service and node addresses.
The type lives in internal/flows, where the parsers are; this alias keeps store.Flow as the name the rest of Flightbay codes against.
type FlowFileResult ¶
type FlowFileResult struct {
File string `json:"file"`
Format string `json:"format"`
Flows int `json:"flows"` // aggregated rows
Events int `json:"records"` // records they stand for
}
FlowFileResult is what ImportFlowFile loaded.
type ImportState ¶
type ImportState struct {
Phase string `json:"phase"`
Source string `json:"source"`
BytesReceived int64 `json:"bytesReceived"`
Members int `json:"members"`
Objects int `json:"objects"`
LogLines int `json:"logLines"`
LogsSkipped int `json:"logsSkipped,omitempty"` // lines not indexed because of the memory budget
Events int `json:"events"`
CoverageSeen int `json:"coverageSeen"`
Verified bool `json:"verified"`
Error string `json:"error,omitempty"`
Started time.Time `json:"started"`
Finished time.Time `json:"finished,omitempty"`
Revision int64 `json:"revision"`
Deferred []string `json:"deferred,omitempty"`
Live *LiveState `json:"live,omitempty"` // set by flightbay-desk live
}
ImportState is the progress of the running import.
type LineLoc ¶
type LineLoc struct {
ID int64 `json:"id"`
Chunk string `json:"chunk"`
Index int `json:"index"`
Raw string `json:"raw"`
}
LineLoc places a log line in the bundle: its chunk member and its position among the chunk's non-empty lines, which is how a review plan names it.
type LiveState ¶
type LiveState struct {
Live bool `json:"live"`
Context string `json:"context"`
Server string `json:"server"`
Connected bool `json:"connected"`
LastEvent time.Time `json:"lastEvent"`
Reconnects int64 `json:"reconnects"`
Watches int `json:"watches"`
ObjectsWatched int `json:"objectsWatched"`
LogStreams int `json:"logStreams"`
LogStreamsTotal int `json:"logStreamsTotal"`
LogLinesDropped int64 `json:"logLinesDropped"`
MaxLogStreams int `json:"maxLogStreams"`
MaxLogLines int `json:"maxLogLines"`
Diagnostics bool `json:"diagnostics"`
Requests map[string]int64 `json:"requests,omitempty"` // requests made to the cluster, by verb
Refused int64 `json:"refused"` // requests the read-only guard refused
}
LiveState describes the connection behind a live workspace.
type LogFilter ¶
type LogFilter struct {
Query string
Cluster string
Namespace string
Pod string
Container string
Level string
Stream string
Workload string // Kind/name or name
From, To time.Time
Limit int
Offset int
}
LogFilter selects log records.
type LogResult ¶
type LogResult struct {
Total int `json:"total"`
Records []*logs.Record `json:"records"`
Facets map[string]map[string]int `json:"facets"`
Histogram []Bucket `json:"histogram"`
Revision int64 `json:"revision"`
Scanned int `json:"scanned"`
Loading bool `json:"loading"`
Message string `json:"message,omitempty"`
From time.Time `json:"from"`
To time.Time `json:"to"`
}
LogResult is a consistent page of search results.
type LogStreamKey ¶
type LogStreamKey struct {
Cluster, Namespace, Pod, Container, Stream string
}
LogStreamKey names one container log stream.
type Object ¶
type Object struct {
Cluster string `json:"cluster"`
Group string `json:"group"`
Version string `json:"version"`
Resource string `json:"resource"`
Kind string `json:"kind"`
Namespaced bool `json:"namespaced"`
Namespace string `json:"namespace"`
Name string `json:"name"`
RV int64 `json:"rv"`
Obj map[string]any `json:"object"`
}
Object is one captured Kubernetes object.
type ObjectHit ¶
type ObjectHit struct {
Cluster string `json:"cluster"`
Group string `json:"group"`
Version string `json:"version"`
Resource string `json:"resource"`
Kind string `json:"kind"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Labels map[string]string `json:"labels,omitempty"`
Match string `json:"match"` // name, label or content
Snippet string `json:"snippet,omitempty"` // where the free text matched
}
ObjectHit is one object found by SearchObjects.
type ObjectResult ¶
type ObjectResult struct {
Total int `json:"total"`
ByKind map[string]int `json:"byKind"`
Results []ObjectHit `json:"results"`
Loading bool `json:"loading"`
Message string `json:"message,omitempty"`
}
ObjectResult is a page of object search results.
type SQLResult ¶
type SQLResult struct {
Columns []string `json:"columns"`
Rows [][]any `json:"rows"`
Truncated bool `json:"truncated"`
Millis int64 `json:"ms"`
}
SQLResult is the result of a read-only query.
type Suggestion ¶
type Suggestion struct {
Value string `json:"value"`
Count int `json:"count"`
Hint string `json:"hint,omitempty"`
Example string `json:"example,omitempty"`
// More means the value is a stem, e.g. a label key, and the UI should
// keep suggesting after inserting it rather than finish the term.
More bool `json:"more,omitempty"`
}
Suggestion is one typeahead entry: a field key (when no field is given) or a value for a field, with how many captured objects or lines carry it.
func LogFieldKeys ¶
func LogFieldKeys() []Suggestion
LogFieldKeys are the fixed keys the log query understands. Structured fields parsed from JSON or key=value lines come on top, see SuggestLogs.
func ObjectFieldKeys ¶
func ObjectFieldKeys() []Suggestion
ObjectFieldKeys are the keys the object search understands.
type TimeBucket ¶
type TimeBucket struct {
Start time.Time `json:"start"`
Connections int `json:"connections"` // ztunnel connections from the workload
Requests int `json:"requests"` // agentgateway requests it made
ToolCalls int `json:"toolCalls"`
LLMCalls int `json:"llmCalls"`
Refused int `json:"refused"` // refused by ztunnel or agentgateway policy
Errors int `json:"errors"`
Tokens int64 `json:"tokens"`
}
TimeBucket is one slice of the window.
type TimeEvent ¶
type TimeEvent struct {
At time.Time `json:"at"`
Kind string `json:"kind"` // connection, tool, model, refusal
What string `json:"what"`
Count int `json:"count"`
}
TimeEvent is the first time something was seen in the window.
type Timeline ¶
type Timeline struct {
From time.Time `json:"from"`
To time.Time `json:"to"`
Step int64 `json:"stepSeconds"`
Buckets []TimeBucket `json:"buckets"`
Events []TimeEvent `json:"events"`
}
Timeline is a workload's activity over the log window.
type TimelineFilter ¶
type TimelineFilter struct {
Cluster string
Pods []string
IdentitySuffix string // "/ns/kagent/sa/tom-demo"
IPs []string
Buckets int // default 60
}
TimelineFilter picks one workload's traffic out of the logs: its ztunnel access lines by pod name, and the agentgateway requests it made by mesh identity (a SPIFFE ID ending in /ns/<ns>/sa/<sa>) or pod address.
type Trust ¶
type Trust struct {
Signature *sign.Result `json:"signature,omitempty"`
Ledger json.RawMessage `json:"ledger,omitempty"`
}
Trust is what the desk knows about where a bundle came from: its signature, checked once the whole bundle has been read, and the ledger of what the customer removed in review.
type Workspace ¶
type Workspace struct {
// contains filtered or unexported fields
}
Workspace is one opened bundle.
func New ¶
func New() *Workspace
New returns an empty workspace with an in-memory database (tests, diffs).
func Open ¶
Open returns an empty workspace whose logs, objects and events are stored in the DuckDB file at path (replaced if it exists). "" keeps it in memory.
func (*Workspace) AccessEdges ¶
func (w *Workspace) AccessEdges(cluster string) []AccessEdge
AccessEdges aggregates ztunnel (and waypoint) access log lines. ztunnel writes one JSON line per connection (scope "access") or per HTTP request (scope "http_access" in some builds) with src.* and dst.* fields.
func (*Workspace) AddCollectionLog ¶
func (w *Workspace) AddCollectionLog(lines []json.RawMessage)
AddCollectionLog appends collection-log.jsonl lines.
func (*Workspace) AddDiagnostic ¶
AddDiagnostic records a diagnostic file (or meta.json) for a component pod.
func (*Workspace) AddLogLines ¶
func (w *Workspace) AddLogLines(cluster, ns, pod, container, stream string, lines []string, chunk string)
AddLogLines parses and commits one log chunk before returning.
func (*Workspace) AddObjects ¶
func (w *Workspace) AddObjects(cluster string, r bundle.APIResource, items []map[string]any, chunk string)
AddObjects commits one resource chunk.
func (*Workspace) AddReviewerFlows ¶
func (w *Workspace) AddReviewerFlows(cluster, name string, r io.Reader, format string) (FlowFileResult, error)
AddReviewerFlows imports a flow file chosen by the reviewer when opening the bundle and lists it on the Coverage page, marked as not part of the signed bundle.
func (*Workspace) AgentTimeline ¶
func (w *Workspace) AgentTimeline(f TimelineFilter) Timeline
AgentTimeline returns one workload's connections, calls and refusals over the log window, and the first time each destination, tool, model and refusal was seen.
func (*Workspace) AgentgatewayRequests ¶
func (w *Workspace) AgentgatewayRequests(cluster string) []AgwRequest
AgentgatewayRequests groups the agentgateway request logs (scope "request", text or JSON) of a cluster ("" for all). Ephemeral source ports are dropped so a caller's connections fall into one group.
func (*Workspace) AllLogStreams ¶
func (w *Workspace) AllLogStreams() []LogStreamKey
AllLogStreams lists every stream with lines loaded.
func (*Workspace) AllObjects ¶
AllObjects returns every object in a cluster ("" for all clusters).
func (*Workspace) CollectionLog ¶
func (w *Workspace) CollectionLog() []json.RawMessage
CollectionLog returns the collection log.
func (*Workspace) CollectionState ¶
func (w *Workspace) CollectionState(cluster, group, resource, kind string, namespaced bool) Collection
CollectionState tells loading, excluded, failed, truncated and complete apart.
func (*Workspace) CoverageRecord ¶
CoverageRecord returns one coverage record by id.
func (*Workspace) DeleteEvent ¶
DeleteEvent removes an event, reporting whether it was present.
func (*Workspace) DeleteObject ¶
DeleteObject removes one object, as a watch DELETED event does, and reports whether it was present.
func (*Workspace) Diagnostic ¶
func (w *Workspace) Diagnostic(cluster, kind, ns, pod string) *Diagnostic
Diagnostic returns one component pod's capture, or nil.
func (*Workspace) DiagnosticSummary ¶
func (w *Workspace) DiagnosticSummary(cluster string) json.RawMessage
DiagnosticSummary returns the diagnostic component summary for a cluster.
func (*Workspace) Diagnostics ¶
func (w *Workspace) Diagnostics(cluster string) []Diagnostic
Diagnostics lists captured components, optionally for one cluster.
func (*Workspace) ErrorMinutes ¶
func (w *Workspace) ErrorMinutes(cluster string, min int) []ErrorMinute
ErrorMinutes returns minutes with at least min error lines per namespace.
func (*Workspace) FindResource ¶
func (w *Workspace) FindResource(cluster, name string) (bundle.APIResource, bool)
FindResource resolves "pods", "po", "deployments.apps" or a kind for a cluster.
func (*Workspace) Flows ¶
Flows returns every observed flow for a cluster ("" for all), from logs in the capture and any flow logs imported with it.
func (*Workspace) ImportFlowFile ¶
func (w *Workspace) ImportFlowFile(cluster, name string, r io.Reader, format, origin string) (FlowFileResult, error)
ImportFlowFile parses a flow log file (format "" to detect it) and adds its flows under cluster, marked with the file name and origin (OriginBundle for a file inside the signed bundle, OriginReviewer for one added at open).
func (*Workspace) IsLive ¶
IsLive reports whether the workspace mirrors a running cluster, as opposed to a bundle (including a bundle saved from a live workspace).
func (*Workspace) LineLocation ¶
LineLocation returns one line by id.
func (*Workspace) LineLocations ¶
LineLocations returns where the lines matching a log filter live, at most max of them, and how many match in total.
func (*Workspace) List ¶
List returns objects of one type, optionally in one namespace and matching labels.
func (*Workspace) LogContext ¶
LogContext returns up to n lines either side of a line in its stream.
func (*Workspace) LogFields ¶
func (w *Workspace) LogFields(query, cluster string, maxFields, maxValues int) ([]FieldValues, error)
LogFields lists the parsed fields present in lines matching the query, most common first, each with its top values.
func (*Workspace) LogStreamFrom ¶
func (w *Workspace) LogStreamFrom(cluster, ns, pod, container, stream string, from int) []*logs.Record
LogStreamFrom returns a stream's lines from sequence number from onwards.
func (*Workspace) LogStreamLines ¶
func (w *Workspace) LogStreamLines() map[LogStreamKey]int
LogStreamLines returns every stream with lines loaded and how many, for workspaces (a live mirror) whose coverage does not list streams one by one.
func (*Workspace) MarkChunk ¶
MarkChunk records that a bundle member has been committed, so a retried or repeated import does not add it twice.
func (*Workspace) PutCoverage ¶
PutCoverage records or replaces a coverage record without counting it as a newly received member (live workspaces rewrite their records).
func (*Workspace) QueueLogLines ¶
func (w *Workspace) QueueLogLines(cluster, ns, pod, container, stream string, lines []string, chunk string, done func())
QueueLogLines reserves ids for a chunk in order and commits it in the background; searches see it once committed. Call WaitLogs before treating the import as complete.
func (*Workspace) Redaction ¶
func (w *Workspace) Redaction() json.RawMessage
Redaction returns the redaction report.
func (*Workspace) RegisterResources ¶
func (w *Workspace) RegisterResources(cluster string, rs []bundle.APIResource)
RegisterResources records discovery for a cluster.
func (*Workspace) RegisteredResources ¶
func (w *Workspace) RegisteredResources(cluster string) []bundle.APIResource
RegisteredResources returns the resource types recorded by discovery or by objects, without the virtual types the workspace synthesises.
func (*Workspace) RemoveDiagnostic ¶
RemoveDiagnostic drops a component pod's captured diagnostics so a fresh capture replaces them rather than mixing with them.
func (*Workspace) Resources ¶
func (w *Workspace) Resources(cluster string) []bundle.APIResource
Resources returns the resource types known for a cluster.
func (*Workspace) SQL ¶
SQL runs one read-only statement against the workspace database: tables log_lines, objects, events and flows, and the view logs. It runs inside a transaction that is always rolled back, and the database has no access to the local file system.
func (*Workspace) SearchLogs ¶
SearchLogs evaluates a query over every committed line. The matches go into a temporary table once; facets, the histogram, the count and the page are all computed from it, so the text search runs once per request.
func (*Workspace) SearchObjects ¶
func (w *Workspace) SearchObjects(query, cluster string, limit int) (*ObjectResult, error)
SearchObjects finds captured objects of any type. Terms:
kind:pod (also po, pods, deployment.apps, httproute) ns:payments cluster:mesh1 name:checkout* label:app=checkout label:app "free text" (name, labels, spec, status...) -term negates. Space is AND.
func (*Workspace) SetCoverage ¶
SetCoverage records a coverage record.
func (*Workspace) SetDiagnosticSummary ¶
func (w *Workspace) SetDiagnosticSummary(cluster string, raw json.RawMessage)
SetDiagnosticSummary records the summary of detected diagnostic components.
func (*Workspace) SetLedger ¶
func (w *Workspace) SetLedger(raw json.RawMessage)
SetLedger records review-ledger.json.
func (*Workspace) SetManifest ¶
SetManifest records manifest.json.
func (*Workspace) SetRedaction ¶
func (w *Workspace) SetRedaction(raw json.RawMessage)
SetRedaction records the redaction report.
func (*Workspace) SetSignature ¶
SetSignature records the result of checking manifest.sig.
func (*Workspace) SetState ¶
func (w *Workspace) SetState(fn func(*ImportState))
SetState updates import progress.
func (*Workspace) SetVersion ¶
func (w *Workspace) SetVersion(cluster string, raw json.RawMessage)
SetVersion records a cluster's /version.
func (*Workspace) Subscribe ¶
func (w *Workspace) Subscribe() (<-chan struct{}, func())
Subscribe returns a channel signalled after every commit.
func (*Workspace) SuggestLogs ¶
func (w *Workspace) SuggestLogs(field, prefix, query, cluster string, limit int) ([]Suggestion, error)
SuggestLogs lists values for one log query field that start with prefix, with line counts, narrowed by the field terms of query. An empty field returns the fixed keys and the most common structured fields.
func (*Workspace) SuggestObjects ¶
func (w *Workspace) SuggestObjects(field, prefix, query, cluster string, limit int) ([]Suggestion, error)
SuggestObjects lists values for one object search field that start with prefix, narrowed by the structured terms (kind, ns, label...) of query. An empty field returns the keys. Values come from the captured objects.
func (*Workspace) TrimLogs ¶
TrimLogs deletes the oldest log lines so at most max remain, and returns how many were dropped. Live workspaces call it to keep the database bounded.
func (*Workspace) UpsertEvent ¶
UpsertEvent adds an event or replaces the one with the same name (a repeated event is the same object with a higher count).
func (*Workspace) UpsertObject ¶
UpsertObject adds or replaces one object, as a watch ADDED or MODIFIED event does. The object gets a new resource version, the revision moves on and the SQL copy is replaced. It reports whether the object is new.