New creates a new Drain instance.
(tenant string, config *Config)
| 27 | |
| 28 | // New creates a new Drain instance. |
| 29 | func New(tenant string, config *Config) *Drain { |
| 30 | if config.LogClusterDepth < 3 { |
| 31 | config.LogClusterDepth = 3 |
| 32 | } |
| 33 | |
| 34 | metrics := metricsForTenant(tenant) |
| 35 | d := &Drain{ |
| 36 | config: config, |
| 37 | maxNodeDepth: config.LogClusterDepth - 2, |
| 38 | metrics: metrics, |
| 39 | tokenizer: &defaultTokenizer{}, |
| 40 | tokenIsLikelyData: defaultIsDataHeuristic, |
| 41 | |
| 42 | rootNode: newNode(), |
| 43 | idToCluster: newLogClusterCache(config.StaleClusterAge, config.MaxClusters, metrics.PatternsEvictedTotal, metrics.PatternsExpiredTotal), |
| 44 | } |
| 45 | |
| 46 | return d |
| 47 | } |
| 48 | |
| 49 | // Node is a node in the prefix tree. |
| 50 | type Node struct { |