Skip to content

ereichert/elp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ELP - AWS ELB Access Log Parser

ELP is a simple AWS ELB Access Log parser.

See the access log docs for more information about them.

Be kind and learn from others.

This project supports the Rust Code of Conduct.

How To

There is a full example of ELP's use in a production environment here.

Add ELP as a dependency. Add the following to your Cargo.toml:

[dependencies]
elp = "2.0.0"

Then reference it as an external crate in your code.

extern crate elp;

Here's a short (incomplete, probably buggy) program that uses ELP to parse all of the records in a file.

extern crate elp;

fn main() {
  match File::open(some_path) {
    Ok(file) => {
        for possible_record in BufReader::new(file).lines() {
            // See http://ereichert.github.io/elp/elp/type.ParsingResult.html
            if let Ok(record) = elp::parse_record(possible_record) {
                // handle ELBRecord
            } else {
                // handle ParsingErrors
            }
        };
    }
    Err(err) => {} //handle io::Error
  }
}

Most of this is pretty standard Rust code. The only ELP specific code of note is the elp::parse_record call.

An attempt is made to parse each field independently. The ParsingErrors struct includes a list of the fields that could not be parsed and, if possible, the reason they could not be parsed.

About

Utility for parsing and analyzing the AWS ELB logs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published