Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement(remap transform): add parse_aws_alb_log function #5489

Merged
merged 11 commits into from Dec 18, 2020
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -75,6 +75,7 @@
/docs/reference/remap/log.cue @FungusHumungus
/docs/reference/remap/merge.cue @FungusHumungus
/docs/reference/remap/parse_grok.cue @FungusHumungus
/docs/reference/remap/parse_aws_alb_log.cue @fanatid

/distribution/ @hoverbear @jamtur01
/distribution/docker/ @vector-kubernetes
Expand All @@ -101,6 +102,7 @@
/lib/remap-functions/src/ipv6_to_ipv4.rs @FungusHumungus
/lib/remap-functions/src/log.rs @FungusHumungus
/lib/remap-functions/src/merge.rs @FungusHumungus
/src/remap/function/parse_aws_alb_log.rs @fanatid
/lib/remap-functions/src/parse_grok.rs @FungusHumungus

/proto/ @lukesteensen
Expand Down
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

76 changes: 76 additions & 0 deletions docs/reference/remap/parse_aws_alb_log.cue
@@ -0,0 +1,76 @@
package metadata

remap: functions: parse_aws_alb_log: {
arguments: [
{
name: "value"
description: "Access log of the Application Load Balancer."
required: true
type: ["string"]
},
]
return: ["map"]
category: "parse"
description: #"""
Parses a Elastic Load Balancer Access log into it's constituent components.
"""#
examples: [
{
title: "Success"
input: {
log: #"http 2018-11-30T22:23:00.186641Z app/my-loadbalancer/50dc6c495c0c9188 192.168.131.39:2817 - 0.000 0.001 0.000 200 200 34 366 "GET http://www.example.com:80/ HTTP/1.1" "curl/7.46.0" - - arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067 "Root=1-58337364-23a8c76965a2ef7629b185e3" "-" "-" 0 2018-11-30T22:22:48.364000Z "forward" "-" "-" "-" "-" "-" "-""#
}
source: #"""
.parsed = parse_aws_alb_log(.log)
"""#
output: {
log: #"http 2018-11-30T22:23:00.186641Z app/my-loadbalancer/50dc6c495c0c9188 192.168.131.39:2817 - 0.000 0.001 0.000 200 200 34 366 "GET http://www.example.com:80/ HTTP/1.1" "curl/7.46.0" - - arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067 "Root=1-58337364-23a8c76965a2ef7629b185e3" "-" "-" 0 2018-11-30T22:22:48.364000Z "forward" "-" "-" "-" "-" "-" "-""#
parsed: {
"type": "http"
"timestamp": "2018-11-30T22:23:00.186641Z"
"elb": "app/my-loadbalancer/50dc6c495c0c9188"
"client_host": "192.168.131.39:2817"
"target_host": null
"request_processing_time": 0.0
"target_processing_time": 0.001
"response_processing_time": 0.0
"elb_status_code": "200"
"target_status_code": "200"
"received_bytes": 34
"sent_bytes": 366
"request_method": "GET"
"request_url": "http://www.example.com:80/"
"request_protocol": "HTTP/1.1"
"user_agent": "curl/7.46.0"
"ssl_cipher": null
"ssl_protocol": null
"target_group_arn": "arn:aws:elasticloadbalancing:us-east-2:123456789012:targetgroup/my-targets/73e2d6bc24d8a067"
"trace_id": "Root=1-58337364-23a8c76965a2ef7629b185e3"
"domain_name": null
"chosen_cert_arn": null
"matched_rule_priority": "0"
"request_creation_time": "2018-11-30T22:22:48.364000Z"
"actions_executed": "forward"
"redirect_url": null
"error_reason": null
"target_port_list": []
"target_status_code_list": []
"classification": null
"classification_reason": null
}
}
},
{
title: "Error"
input: {
log: "I am not a log"
}
source: #"""
.parsed = parse_aws_alb_log(.log)
"""#
output: {
error: remap.errors.ParseError
}
},
]
}
3 changes: 3 additions & 0 deletions lib/remap-functions/Cargo.toml
Expand Up @@ -15,6 +15,7 @@ grok = { version = "1", optional = true }
hex = { version = "0.4", optional = true }
lazy_static = { version = "1", optional = true }
md-5 = { version = "0.9", optional = true }
nom = { version = "6.0.1", optional = true }
regex = { version = "1", optional = true }
rust_decimal = { version = "1", optional = true }
serde_json = { version = "1", optional = true }
Expand Down Expand Up @@ -56,6 +57,7 @@ default = [
"merge",
"now",
"only_fields",
"parse_aws_alb_log",
"parse_duration",
"parse_grok",
"parse_json",
Expand Down Expand Up @@ -106,6 +108,7 @@ md5 = ["md-5", "hex"]
merge = []
now = []
only_fields = []
parse_aws_alb_log = ["nom"]
parse_duration = []
parse_grok = ["grok"]
parse_json = ["serde_json"]
Expand Down
6 changes: 6 additions & 0 deletions lib/remap-functions/src/lib.rs
Expand Up @@ -44,6 +44,8 @@ mod merge;
mod now;
#[cfg(feature = "only_fields")]
mod only_fields;
#[cfg(feature = "parse_aws_alb_log")]
mod parse_aws_alb_log;
#[cfg(feature = "parse_duration")]
mod parse_duration;
#[cfg(feature = "parse_grok")]
Expand Down Expand Up @@ -143,6 +145,8 @@ pub use merge::Merge;
pub use now::Now;
#[cfg(feature = "only_fields")]
pub use only_fields::OnlyFields;
#[cfg(feature = "parse_aws_alb_log")]
pub use parse_aws_alb_log::ParseAwsAlbLog;
#[cfg(feature = "parse_duration")]
pub use parse_duration::ParseDuration;
#[cfg(feature = "parse_grok")]
Expand Down Expand Up @@ -242,6 +246,8 @@ pub fn all() -> Vec<Box<dyn remap::Function>> {
Box::new(Now),
#[cfg(feature = "only_fields")]
Box::new(OnlyFields),
#[cfg(feature = "parse_aws_alb_log")]
Box::new(ParseAwsAlbLog),
#[cfg(feature = "parse_duration")]
Box::new(ParseDuration),
#[cfg(feature = "parse_grok")]
Expand Down