Skip to content

Commit

Permalink
docs(vrl): add an example of parsing upstreaminfo with parse_nginx_log (
Browse files Browse the repository at this point in the history
vectordotdev#18815)

* docs(vrl): add an example of parsing upstreaminfo with parse_nginx_log

* Copy the example message from the "all valid" test

* Mention which fields might not be present when parsing a ingress_upstreaminfo log

* Replace whitespaces breaking CUE validation
  • Loading branch information
ex5 authored Oct 11, 2023
1 parent b107ff7 commit 774094e
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions website/cue/reference/remap/functions/parse_nginx_log.cue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ remap: functions: parse_nginx_log: {
"""
Missing information in the log message may be indicated by `-`. These fields are omitted in the result.
""",
"""
In case of `ingress_upstreaminfo` format the following fields may be safely omitted in the log message: `remote_addr`, `remote_user`, `http_referer`, `http_user_agent`, `proxy_alternative_upstream_name`, `upstream_addr`, `upstream_response_length`, `upstream_response_time`, `upstream_status`.
""",
]

arguments: [
Expand Down Expand Up @@ -93,5 +96,33 @@ remap: functions: parse_nginx_log: {
host: "localhost:8081"
}
},
{
title: "Parse via Nginx log format (ingress_upstreaminfo)"
source: #"""
parse_nginx_log!(
s'0.0.0.0 - bob [18/Mar/2023:15:00:00 +0000] "GET /some/path HTTP/2.0" 200 12312 "https://10.0.0.1/some/referer" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36" 462 0.050 [some-upstream-service-9000] [some-other-upstream-5000] 10.0.50.80:9000 19437 0.049 200 752178adb17130b291aefd8c386279e7',
"ingress_upstreaminfo"
)
"""#
return: {
body_bytes_size: 12312
http_referer: "https://10.0.0.1/some/referer"
http_user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
proxy_alternative_upstream_name: "some-other-upstream-5000"
proxy_upstream_name: "some-upstream-service-9000"
remote_addr: "0.0.0.0"
remote_user: "bob"
req_id: "752178adb17130b291aefd8c386279e7"
request: "GET /some/path HTTP/2.0"
request_length: 462
request_time: 0.050
status: 200
timestamp: "2023-03-18T15:00:00Z"
upstream_addr: "10.0.50.80:9000"
upstream_response_length: 19437
upstream_response_time: 0.049
upstream_status: 200
}
},
]
}

0 comments on commit 774094e

Please sign in to comment.