Documentation
¶
Overview ¶
Package logs parses captured container log lines into structured records and evaluates the Flightbay log query language.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContainsFold ¶
ContainsFold reports whether s contains the lower-case needle, ignoring ASCII case, without allocating. Searches run over every captured line, so lower-casing each line per query (the obvious way) costs gigabytes of garbage on a large bundle.
func NormalizeLevel ¶
NormalizeLevel maps the many level spellings onto trace, debug, info, warn, error.
func SortNewestFirst ¶
func SortNewestFirst(rs []*Record)
SortNewestFirst orders records by time, newest first, keeping line order stable.
func SplitTimestamp ¶
SplitTimestamp removes the RFC 3339 timestamp the kubelet adds with timestamps=true.
Types ¶
type Fields ¶
type Fields []string
Fields are parsed key/value pairs, stored as a sorted flat slice (k0, v0, k1, v1...). A map per line costs several hundred bytes; most lines have a handful of fields.
func (Fields) MarshalJSON ¶
MarshalJSON writes the fields as a JSON object.
func (*Fields) UnmarshalJSON ¶
UnmarshalJSON reads a JSON object.
type Query ¶
type Query struct {
Text string
Since time.Duration
Reference time.Time // "now" for since:, normally the end of the capture
// contains filtered or unexported fields
}
Query is a parsed log query. Terms are ANDed; OR joins neighbours.
func ParseQuery ¶
ParseQuery parses level:error ns:payments pod:checkout* trace_id:x "phrase" -term since:15m.
type Record ¶
type Record struct {
ID int64 `json:"id"`
Seq int `json:"seq"`
TS time.Time `json:"ts"`
*Source
Level string `json:"level"`
Scope string `json:"scope,omitempty"`
Msg string `json:"msg"`
Fields Fields `json:"fields,omitempty"`
Raw string `json:"raw"`
}
Record is one parsed log line. Source is embedded, so r.Pod and the JSON shape are unchanged.
type Source ¶
type Source struct {
Cluster string `json:"cluster"`
Namespace string `json:"namespace"`
Pod string `json:"pod"`
Container string `json:"container"`
Stream string `json:"stream"`
Node string `json:"node,omitempty"`
// Workload is the Deployment, DaemonSet, StatefulSet, Job (or bare pod)
// the pod belongs to, so a controller's logs can be read across pods.
Workload string `json:"workload,omitempty"`
WorkloadKind string `json:"workloadKind,omitempty"`
Chunk string `json:"-"`
}
Source is where a line came from. Every line of a log chunk shares one, so the identity strings are stored once per chunk rather than once per line.