@@ -55,65 +55,82 @@ GLOBAL OPTIONS:
55
55
56
56
``` text
57
57
NAME:
58
- alpen clf - Parses apache common/combined log format
58
+ alpen s3 - Parses S3 access logs
59
59
60
60
USAGE:
61
- alpen clf
61
+ alpen s3
62
62
63
63
DESCRIPTION:
64
- Parses apache common/combined log format and converts them to structured formats
64
+ Parses S3 access logs and converts them to structured formats
65
65
66
66
OPTIONS:
67
- --input value, -i value input from string
68
- --file-path value, -f value input from file path
69
- --gzip-path value , -g value input from gzip file path
70
- --zip-path value, -z value input from zip file path
71
- --output value, -o value select output format: json|pretty-json|text|ltsv|tsv (default: "json")
72
- --skip value, -s value [ --skip value, -s value ] skip records by index
73
- --metadata , -m enable metadata output (default: false)
74
- --line-number , -l set line number at the beginning of the line (default: false)
75
- --header , -H set header: avairable for tsv output (default: false)
76
- --glob-pattern value , -G value filter glob pattern: available for parsing zip only (default: "*" )
77
- --help, -h show help
67
+ --input value, -i value select input type: default|gz|zip (default: "default")
68
+ --output value, -o value select output type: json|pretty-json|text|ltsv|tsv (default: "json")
69
+ --result , -r enable result output (default: false)
70
+ --glob value, -g value filter glob pattern: available for parsing zip only (default: "*")
71
+ --labels value, -l value [ --labels value, -l value ] select labels to output with labels
72
+ --filters value, -f value [ --filters value, -f value ] set filter expressions: allowed operator: >|>=|<|<=|==|!=|==*|!=*|=~|!~|=~*|!~*
73
+ --skip value , -s value [ --skip value, -s value ] skip lines by line number
74
+ --prefix , -p enable line prefix: PROCESSED|UNMATCHED (default: false)
75
+ --unmatch , -u enable output of unmatched lines (default: false)
76
+ --num , -n set line number at the beginning of the line (default: false )
77
+ --help, -h show help
78
78
```
79
79
80
80
Example
81
81
-------
82
82
83
83
``` sh
84
84
# Read and convert s3 logs from file and convert to default NDJSON format
85
- alpen s3 -f " sample_s3.log"
85
+ alpen s3 " sample_s3.log"
86
86
87
- # Set line number at the beginning of line, like "index": "n"
88
- alpen s3 -f " sample_s3.log" -l
87
+ # Set line number at the beginning of line
88
+ alpen s3 -n " sample_s3.log"
89
89
90
- # Read s3 logs from file and convert to pretty NDJSON, also output metadata
91
- alpen s3 -f " sample_s3.log" -o pretty-json -m
90
+ # Read s3 log from file, convert to pretty NDJSON and output parsed results
91
+ alpen s3 -r -o pretty-json " sample_s3.log"
92
+
93
+ # Can be combined with tail -f to process standard input
94
+ # Results are consistent, even if interrupted with CTRL+C
95
+ tail -f sample_s3.log | alpen s3 -r
92
96
93
97
# Convert LTSV format
94
- alpen s3 -f " sample_s3.log " -o ltsv -m
98
+ alpen s3 -r -o ltsv " sample_s3.log "
95
99
96
- # Convert TSV format and enable header
97
- alpen s3 -f " sample_s3.log " -o tsv -H
100
+ # In TSV format, the header is set from the parsing result of the first line
101
+ alpen s3 -r -o tsv " sample_s3.log "
98
102
99
103
# Read CloudFront logs from gzip file and skip header lines
100
- alpen cf -g " sample_cloudfront.log.gz" -s 1,2
104
+ alpen cf -r -s 1,2 -i gz " sample_cloudfront.log.gz"
101
105
102
106
# Read ALB logs from zip file and convert all entries with `.log` extension
103
- alpen alb -z " sample_alb.log.zip" -G " *.log"
107
+ alpen alb -r -g " *.log" -i zip " sample_alb.log.zip"
108
+
109
+ # Unmatched lines can also be output raw and made explicit by line prefix
110
+ alpen s3 -u -p " sample_s3.log"
111
+
112
+ # Columns can be narrowed by specifying labels
113
+ alpen s3 -l bucket,method,request_uri,protocol " sample_s3.log"
114
+
115
+ # Filter expressions to narrow down rows
116
+ # > >= == <= < (arithmetic (float64))
117
+ # == ==* != !=* (string comparison (string))
118
+ # =~ !~ =~* !~* (regular expression (string))
119
+ # inspired from <https://github.com/sonots/lltsv>
120
+ alpen s3 -f " method == GET,operation =~ .*BUCKETPOLICY"
104
121
105
122
# Read apache common/combined format logs
106
123
# Matches both common/combined by default
107
124
# Use space or tab as delimiter
108
- alpen clf -f " sample_clf.log"
125
+ alpen clf " sample_clf.log"
109
126
110
127
# Read apache common/combined log format with virtual host
111
128
# Matches if virtual host is at the beginning
112
- alpen clfv -f " sample_clf.log"
129
+ alpen clfv " sample_clf.log"
113
130
114
131
# LTSV uses labels as names, so it is not possible to decompose a request into
115
132
# methods, request_uri, or protocols.
116
- alpen ltsv -f " sample_ltsv.log"
133
+ alpen ltsv " sample_ltsv.log"
117
134
```
118
135
119
136
Installation
0 commit comments