Documentation
¶
Overview ¶
Package lognorm turns raw container log lines into clusterable records: it picks the useful JSON fields, joins stack traces and masks variable parts. All functions are pure; nothing here touches the store or the API.
Index ¶
- Constants
- func Join(lines []string) []string
- func MaskPatterns(s string) string
- func Placeholders(s string) string
- func Sample(line string, reg *secretmask.Registry) string
- func Scrub(s string) string
- func Template(line string, reg *secretmask.Registry) string
- type Entry
- type MinedTemplate
- type Miner
- type MinerConfig
- type Record
Constants ¶
const ( PhTimestamp = "<TS>" PhUUID = "<UUID>" PhIP = "<IP>" PhHex = "<HEX>" PhNum = "<NUM>" )
Placeholders left in a template so equal failures with different values cluster.
const ( MaxStackLines = 64 MaxRecordBytes = 8192 )
Caps for one joined record. Package constants until the wiring slice makes them runtime settings.
const DefaultMaxClusters = 200
DefaultMaxClusters is the per-stream cap until the logs.miner_max_clusters runtime setting is wired (needs design: the miner has no caller yet).
const DefaultSimilarity = 0.5
DefaultSimilarity is the share of equal tokens a line needs to join a cluster.
const Wildcard = "<*>"
Wildcard marks a token position that differed across lines of one cluster.
Variables ¶
This section is empty.
Functions ¶
func Join ¶
Join folds Go, Java, Python and Node stack traces into single multi-line records and passes every other line through untouched.
func MaskPatterns ¶
MaskPatterns replaces credential-shaped text with the secretmask marker.
func Placeholders ¶
Placeholders swaps timestamps, uuids, ips, hex ids and numbers for tokens.
func Sample ¶
func Sample(line string, reg *secretmask.Registry) string
Sample returns the line with known secrets and credential shapes masked. This is the only form that may be stored; reg nil uses the process-wide registry.
Types ¶
type MinedTemplate ¶
MinedTemplate is one mined cluster: a stable id, how many lines it absorbed and a masked sample line.
type Miner ¶
type Miner struct {
// contains filtered or unexported fields
}
Miner is a small Drain-style clusterer: lines group by token count and first token, then merge with the closest cluster above the similarity bar. It is not safe for concurrent use; one miner per stream.
func (*Miner) Add ¶
Add feeds one normalized entry. The entry sample is already secret-masked, and the template carries placeholders only, so nothing raw is retained.
func (*Miner) Templates ¶
func (m *Miner) Templates() []MinedTemplate
Templates returns clusters by descending count, then template text.
type MinerConfig ¶
MinerConfig bounds one stream's miner. Zero values fall back to the defaults.