Crates.io | mysql-slowlog-parser |
lib.rs | mysql-slowlog-parser |
version | |
source | src |
created_at | 2024-11-20 00:45:44.257662 |
updated_at | 2024-11-24 21:20:55.877179 |
description | Streaming parser for MySQL slowlogs |
homepage | |
repository | https://github.com/soulstompp/mysql-slowlog-parser |
max_upload_size | |
id | 1454052 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
This library parsers MySQL slow query logs. While
certainly not the first slowlog parser written, this one attempts to extract a great deal more information than its
predecessors. The parsers extract nearly all the information about each line in an Entry
with plans to extract any
remaining values in the near future.
The query found within an entry is also parsed to extract query meta-information about the query (such as which tables and databases are accessed), what type of query and masking of parameters, primarily to normalize repeated calls of the same query.
Since it is a fairly common practice to include important information in the comment of a query. So, each of these comments are parsed to find key-value pairs and include values you can map to specific context about the software that ran the query.
This library is able to read streaming data from the slow logs from a variety of sources and can handle large logs without memory issues.
Vec<Bytes>
to ensure the values are accessible.The parser is built as a tokio codec and so can accept anything that FramedRead supports.
let fr = FramedRead::with_capacity(
File::open("mysql-slow-lobsters.log")
.await
.unwrap(),
EntryCodec::default(),
400000,
);
let future = fr.for_each(|re: Result<Entry, CodecError>| async move {
let _ = re.unwrap();
// do something here with each entry
});
future.await;
The parsers or codec will return an Entry struct for each object found which contains the following information. Most of the following information below can be accessed via functions on this struct.
Information about the start and end time of the query run including the time period it held locks EntryCall
Information about the user connection, contained in EntrySession
Details on how long and how often the query ran, contained in EntryStats.
EntrySqlAttributes Contains information on the query the entry is about. You can find out the following information about a query:
EntrySqlAttributes
are lost. This problem will be fixed in an upcoming release.In order to understand the data streaming back to you, see docs for the Entry
struct, which holds information returned from individual
in the docs
MIT Licensed. See LICENSE