A Common and Combined Log Format analyzer for MoonBit
moon add pei0331/moon-accesslogimport {
"pei0331/moon-accesslog" @accesslog,
}moon run cmd/main -- examples/access.log
moon run cmd/main -- --top 5 examples/access.log
moon run cmd/main -- --json examples/access.log
moon run cmd/main -- --csv examples/access.log
moon run cmd/main -- --method GET --path-prefix /api examples/access.log
moon run cmd/main -- --status-min 400 --status-max 599 --json examples/access.log
moon run cmd/main -- --max-error-rate 5 examples/access.log
moon run cmd/main -- --hour-prefix 23/Sep/2026:09 examples/access.log
moon run cmd/main -- --prometheus examples/access.log
moon run cmd/main -- --markdown --top 5 examples/access.log
moon run cmd/main -- --ndjson examples/access.loglet report = @accesslog.analyze(source)
println(report.to_text(top=10))///|
let options = @accesslog.AnalyzeOptions::new().with_hour_prefix(
Some("23/Sep/2026:09"),
)
///|
let report = @accesslog.analyze_with_options(source, options)moon fmt --check
moon info
moon check
moon test
moon run cmd/main -- examples/access.log
moon run cmd/main -- --json examples/access.log
moon run cmd/main -- --status-min 400 examples/access.log
moon run cmd/main -- --prometheus examples/access.log
moon build --target nativepub struct AccessRecord {
address : String
timestamp : String
http_method : String
path : String
route : String
query : String
protocol : String
status : Int
bytes : Int
referrer : String
user_agent : String
}pub struct AnalyzeOptions {
http_method : String?
path_prefix : String?
address : String?
status_min : Int?
status_max : Int?
hour_prefix : String?
}fn AnalyzeOptions::from(http_method : String?, path_prefix : String?, address : String?, status_min : Int?, status_max : Int?) -> AnalyzeOptionspub struct EndpointSummary {
route : String
requests : Int
errors : Int
total_bytes : Int
error_rate_percent : Int
average_bytes : Int
depth : Int
}pub struct MetricFinding {
code : String
severity : String
message : String
value : Int
}pub struct Report {
total_lines : Int
invalid_lines : Int
filtered_lines : Int
requests : Int
total_bytes : Int
query_requests : Int
status_counts : Map[Int, Int]
method_counts : Map[String, Int]
path_counts : Map[String, Int]
address_counts : Map[String, Int]
hourly_counts : Map[String, Int]
route_counts : Map[String, Int]
user_agent_counts : Map[String, Int]
referrer_counts : Map[String, Int]
query_key_counts : Map[String, Int]
protocol_counts : Map[String, Int]
route_error_counts : Map[String, Int]
route_bytes_counts : Map[String, Int]
}pub struct SloSnapshot {
availability_percent : Int
error_budget_percent : Int
invalid_input_percent : Int
query_request_percent : Int
total_requests : Int
server_errors : Int
}Install
Download zipA Common and Combined Log Format analyzer for MoonBit