Skip to content

Implementation of the drain log categorization algorithm in Rust

License

Notifications You must be signed in to change notification settings

benwtrent/drain-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

drain-rs

Drain provides a mechanism for online log categorization.

This version provides:

  • serialization/deserialization of drain state via serde json
  • support for GROK patterns for more accurate categories and variable filtering

The goal of this particular project is to provide a nice, fast, rust upgrade to the original drain implementation. Original paper here:

This is a WIP, 0.3.x

Installing

[dependencies]
drain-rs = "0.3.0"

Using drain for clustering

To use drain for clustering:

//Create new drain tree object
let mut drain = DrainTree::new()
// Add log lines and see their group:
let log_group = drain.add_log_line(s.as_str());

To use drain with grok:

let mut g = grok::Grok::with_patterns();
let filter_patterns = vec![
    "blk_(|-)[0-9]+",     //blockid
    "%{IPV4:ip_address}", //IP
    "%{NUMBER:number}",   //Num
];
// Build new drain tree
let mut drain = DrainTree::new()
    .filter_patterns(filter_patterns)
    .max_depth(4)
    .max_children(100)
    .min_similarity(0.5)
    // HDFS log pattern, variable format printout in the content section
    .log_pattern("%{NUMBER:date} %{NUMBER:time} %{NUMBER:proc} %{LOGLEVEL:level} %{DATA:component}: %{GREEDYDATA:content}", "content")
    // Compile all the grok patterns so that they can be used
    .build_patterns(&mut g);

About

Implementation of the drain log categorization algorithm in Rust

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages