fluent-plugin-cloudfront-log-optimized 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.devcontainer/Dockerfile +42 -0
- data/.devcontainer/devcontainer.json +21 -0
- data/CHANGELOG.md +6 -0
- data/benchmark-gsub-vs-replace.rb +23 -0
- data/fluent-plugin-cloudfront-log-optimized.gemspec +2 -2
- data/lib/fluent/plugin/in_cloudfront_log.rb +10 -5
- data/test/plugin/test_in_cloudfrontlog.rb +34 -0
- metadata +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29422143da7c36ffd474f6f9345ca3419fc9eec9315e015edf99a8de4aa763ca
|
|
4
|
+
data.tar.gz: 22be1e3ad171f1a684b4eb11ed3fa4584345b1af8ceabddb721dc08edba22135
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2c5a78c69cda9394786b3e5bb7ce81e30d2f61a8b975e9c0b9d7d00564d42589842d59cd3ddc616921a0c280e0bea213b4fc7a953f55094897491f1eda878004
|
|
7
|
+
data.tar.gz: 6861b08d29b8144e9763f5ee235f9c0e493bd52061c8dff003e9e24e565cdfeea56b2236f691ec6bf1f6d40b5f11baa17abdaec8aff51809d929f4cb1a8173ff
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
ARG RUBY_VERSION=2.7.6
|
|
2
|
+
ARG RUBYGEMS_UPDATE_VERSION=1.8.30
|
|
3
|
+
ARG BUNDLER_VERSION=1.7.15
|
|
4
|
+
|
|
5
|
+
FROM ruby:$RUBY_VERSION-slim
|
|
6
|
+
LABEL maintainer="k.j.wierenga@kerkdienstgemist.nl"
|
|
7
|
+
|
|
8
|
+
# Common dependencies
|
|
9
|
+
# Install apt based dependencies required to run Rails as
|
|
10
|
+
# well as RubyGems. As the Ruby image itself is based on a
|
|
11
|
+
# Debian image, we use apt-get to install those.
|
|
12
|
+
RUN apt-get update -qq \
|
|
13
|
+
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
|
14
|
+
build-essential \
|
|
15
|
+
git \
|
|
16
|
+
&& apt-get clean \
|
|
17
|
+
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
|
|
18
|
+
&& truncate -s 0 /var/log/*log
|
|
19
|
+
|
|
20
|
+
# Configure bundler
|
|
21
|
+
ENV LANG=C.UTF-8 \
|
|
22
|
+
BUNDLE_JOBS=4 \
|
|
23
|
+
BUNDLE_RETRY=3
|
|
24
|
+
|
|
25
|
+
# Uncomment this line if you store Bundler settings in the project's root
|
|
26
|
+
# ENV BUNDLE_APP_CONFIG=.bundle
|
|
27
|
+
|
|
28
|
+
# Uncomment this line if you want to run binstubs without prefixing with `bin/` or `bundle exec`
|
|
29
|
+
# ENV PATH /app/bin:$PATH
|
|
30
|
+
|
|
31
|
+
# Upgrade RubyGems and install required Bundler version
|
|
32
|
+
# ARG BUNDLER_VERSION
|
|
33
|
+
# ARG RUBYGEMS_UPDATE_VERSION
|
|
34
|
+
# RUN gem uninstall bundler && \
|
|
35
|
+
# gem update --system $RUBYGEMS_UPDATE_VERSION && \
|
|
36
|
+
# gem install bundler:$BUNDLER_VERSION
|
|
37
|
+
|
|
38
|
+
# Configure the main working directory. This is the base
|
|
39
|
+
# directory used in any further RUN, COPY, and ENTRYPOINT commands.
|
|
40
|
+
ENV WORKDIR=/app
|
|
41
|
+
RUN mkdir -p $WORKDIR
|
|
42
|
+
WORKDIR $WORKDIR
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
|
2
|
+
// README at: https://github.com/devcontainers/templates/tree/main/src/ruby
|
|
3
|
+
{
|
|
4
|
+
"name": "Ruby",
|
|
5
|
+
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
|
6
|
+
// "image": "ruby:2.7.6-slim"
|
|
7
|
+
"build": {
|
|
8
|
+
// Path is relative to the devcontainer.json file.
|
|
9
|
+
"dockerfile": "Dockerfile"
|
|
10
|
+
}
|
|
11
|
+
// Features to add to the dev container. More info: https://containers.dev/features.
|
|
12
|
+
// "features": {},
|
|
13
|
+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
|
14
|
+
// "forwardPorts": [],
|
|
15
|
+
// Use 'postCreateCommand' to run commands after the container is created.
|
|
16
|
+
// "postCreateCommand": "ruby --version",
|
|
17
|
+
// Configure tool-specific properties.
|
|
18
|
+
// "customizations": {},
|
|
19
|
+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
|
20
|
+
// "remoteUser": "root"
|
|
21
|
+
}
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## Release 0.2.2
|
|
2
|
+
- [end] replace slow gsub with more efficient string replace
|
|
3
|
+
|
|
4
|
+
## Release 0.2.1
|
|
5
|
+
Merge pull request #1 from kdgm/feature/fix/escaped-tab-handling
|
|
6
|
+
|
|
1
7
|
## Release 0.2.0 (kjwierenga)
|
|
2
8
|
Merge branch 'feature/enh/rename-to-optimized' into develop
|
|
3
9
|
Merge branch 'feature/fix/process-log-files-in-last-modified-order' into develop
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require "benchmark"
|
|
2
|
+
require "cgi"
|
|
3
|
+
|
|
4
|
+
n = 5000000
|
|
5
|
+
log_line = '2025-10-12 09:52:59 MRS53-P3 1400 150.107.232.112 POST d2p1j3y3mcauy0.cloudfront.net /plugin/add 403 - Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/17.3.1%20Safari/605.1.1%0920.51 - - Error WcPCNG0WyL4BbXhEXq4AQulhrqte2TPUHt1Uz-iqcSwtx1L6ORdTOA== livecdn.kerkdienstgemist.nl https 9760 0.124 - TLSv1.3 TLS_AES_128_GCM_SHA256 Error HTTP/1.1 - - 50294 0.000 InvalidRequestMethod text/html 1053 - -'
|
|
6
|
+
Benchmark.bm do |x|
|
|
7
|
+
x.report do
|
|
8
|
+
n.times do
|
|
9
|
+
log_line = '2025-10-12 09:52:59 MRS53-P3 1400 150.107.232.112 POST d2p1j3y3mcauy0.cloudfront.net /plugin/add 403 - Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/17.3.1%20Safari/605.1.1%0920.51 - - Error WcPCNG0WyL4BbXhEXq4AQulhrqte2TPUHt1Uz-iqcSwtx1L6ORdTOA== livecdn.kerkdienstgemist.nl https 9760 0.124 - TLSv1.3 TLS_AES_128_GCM_SHA256 Error HTTP/1.1 - - 50294 0.000 InvalidRequestMethod text/html 1053 - -'
|
|
10
|
+
CGI.unescape(log_line.gsub('%09', " "))
|
|
11
|
+
log_line
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
x.report do
|
|
16
|
+
n.times do
|
|
17
|
+
log_line = '2025-10-12 09:52:59 MRS53-P3 1400 150.107.232.112 POST d2p1j3y3mcauy0.cloudfront.net /plugin/add 403 - Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/17.3.1%20Safari/605.1.1%0920.51 - - Error WcPCNG0WyL4BbXhEXq4AQulhrqte2TPUHt1Uz-iqcSwtx1L6ORdTOA== livecdn.kerkdienstgemist.nl https 9760 0.124 - TLSv1.3 TLS_AES_128_GCM_SHA256 Error HTTP/1.1 - - 50294 0.000 InvalidRequestMethod text/html 1053 - -'
|
|
18
|
+
log_line["%09"] = " " if log_line.include?("%09")
|
|
19
|
+
CGI.unescape(log_line)
|
|
20
|
+
log_line
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "fluent-plugin-cloudfront-log-optimized"
|
|
7
|
-
spec.version = "0.2.
|
|
7
|
+
spec.version = "0.2.2"
|
|
8
8
|
spec.authors = ["kubihee", "lenfree", "kjwierenga"]
|
|
9
9
|
spec.email = ["kubihie@gmail.com", "lenfree.yeung@gmail.com", "k.j.wierenga@gmail.com"]
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
spec.add_dependency "fluentd", ">= 0.14.0", "< 2"
|
|
21
21
|
spec.add_dependency "aws-sdk-s3", "~> 1"
|
|
22
22
|
spec.add_dependency "aws-sdk-sqs", "~> 1"
|
|
23
|
-
spec.add_development_dependency "bundler", "~>
|
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
|
24
24
|
spec.add_development_dependency "rake", "~> 12"
|
|
25
25
|
spec.add_development_dependency 'test-unit', "~> 2"
|
|
26
26
|
end
|
|
@@ -132,18 +132,23 @@ class Fluent::Cloudfront_LogInput < Fluent::Input
|
|
|
132
132
|
return
|
|
133
133
|
end
|
|
134
134
|
|
|
135
|
+
# replace %09 (tab) with space to avoid incorrect introduction of tab character by CGI.unescape
|
|
136
|
+
line["%09"] = " " if line.include?("%09")
|
|
137
|
+
|
|
135
138
|
record = [
|
|
136
139
|
@fields,
|
|
137
|
-
CGI.unescape(line).
|
|
140
|
+
CGI.unescape(line).split("\t")
|
|
138
141
|
].transpose.to_h
|
|
139
142
|
|
|
140
143
|
timestamp = if @parse_date_time
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
144
|
+
Time.iso8601("#{record['date']}T#{record['time']}+00:00").to_i
|
|
145
|
+
else
|
|
146
|
+
Time.now.to_i
|
|
147
|
+
end
|
|
145
148
|
|
|
146
149
|
router.emit(@tag, timestamp, record)
|
|
150
|
+
|
|
151
|
+
record # for testing purposes
|
|
147
152
|
end
|
|
148
153
|
|
|
149
154
|
def process_content(content)
|
|
@@ -105,4 +105,38 @@ class Cloudfront_LogInputTest < Test::Unit::TestCase
|
|
|
105
105
|
end
|
|
106
106
|
end
|
|
107
107
|
|
|
108
|
+
sub_test_case "regression test for %09 (tab) in log lines" do
|
|
109
|
+
test "log line with %09 in user-agent is parsed correctly" do
|
|
110
|
+
driver = create_driver(MINIMAL_CONFIG)
|
|
111
|
+
instance = driver.instance
|
|
112
|
+
|
|
113
|
+
version_line = "#Version: 1.0"
|
|
114
|
+
fields_line = "#Fields: date time x-edge-location sc-bytes c-ip cs-method cs(Host) cs-uri-stem sc-status cs(Referer) cs(User-Agent) cs-uri-query cs(Cookie) x-edge-result-type x-edge-request-id x-host-header cs-protocol cs-bytes time-taken x-forwarded-for ssl-protocol ssl-cipher x-edge-response-result-type cs-protocol-version fle-status fle-encrypted-fields c-port time-to-first-byte x-edge-detailed-result-type sc-content-type sc-content-len sc-range-start sc-range-end"
|
|
115
|
+
regression_line_with_excaped_tab = "2025-10-12 09:52:59 MRS53-P3 1400 150.107.232.112 POST d2p1j3y3mcauy0.cloudfront.net /plugin/add 403 - Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/17.3.1%20Safari/605.1.1%0920.51 - - Error WcPCNG0WyL4BbXhEXq4AQulhrqte2TPUHt1Uz-iqcSwtx1L6ORdTOA== livecdn.kerkdienstgemist.nl https 9760 0.124 - TLSv1.3 TLS_AES_128_GCM_SHA256 Error HTTP/1.1 - - 50294 0.000 InvalidRequestMethod text/html 1053 - -"
|
|
116
|
+
|
|
117
|
+
# Prime the processor with version and fields lines
|
|
118
|
+
instance.process_line(version_line)
|
|
119
|
+
instance.process_line(fields_line)
|
|
120
|
+
emitted_event = instance.process_line(regression_line_with_excaped_tab)
|
|
121
|
+
|
|
122
|
+
assert_equal(emitted_event['cs(User-Agent)'], "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.1 20.51")
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
test "log line without %09 in user-agent is parsed correctly" do
|
|
126
|
+
driver = create_driver(MINIMAL_CONFIG)
|
|
127
|
+
instance = driver.instance
|
|
128
|
+
|
|
129
|
+
version_line = "#Version: 1.0"
|
|
130
|
+
fields_line = "#Fields: date time x-edge-location sc-bytes c-ip cs-method cs(Host) cs-uri-stem sc-status cs(Referer) cs(User-Agent) cs-uri-query cs(Cookie) x-edge-result-type x-edge-request-id x-host-header cs-protocol cs-bytes time-taken x-forwarded-for ssl-protocol ssl-cipher x-edge-response-result-type cs-protocol-version fle-status fle-encrypted-fields c-port time-to-first-byte x-edge-detailed-result-type sc-content-type sc-content-len sc-range-start sc-range-end"
|
|
131
|
+
regression_line_with_excaped_tab = "2025-10-12 09:52:59 MRS53-P3 1400 150.107.232.112 POST d2p1j3y3mcauy0.cloudfront.net /plugin/add 403 - Mozilla/5.0%20(Macintosh;%20Intel%20Mac%20OS%20X%2010_15_7)%20AppleWebKit/605.1.15%20(KHTML,%20like%20Gecko)%20Version/17.3.1%20Safari/605.1.1-20.51 - - Error WcPCNG0WyL4BbXhEXq4AQulhrqte2TPUHt1Uz-iqcSwtx1L6ORdTOA== livecdn.kerkdienstgemist.nl https 9760 0.124 - TLSv1.3 TLS_AES_128_GCM_SHA256 Error HTTP/1.1 - - 50294 0.000 InvalidRequestMethod text/html 1053 - -"
|
|
132
|
+
|
|
133
|
+
# Prime the processor with version and fields lines
|
|
134
|
+
instance.process_line(version_line)
|
|
135
|
+
instance.process_line(fields_line)
|
|
136
|
+
emitted_event = instance.process_line(regression_line_with_excaped_tab)
|
|
137
|
+
|
|
138
|
+
assert_equal(emitted_event['cs(User-Agent)'], "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.3.1 Safari/605.1.1-20.51")
|
|
139
|
+
end
|
|
140
|
+
end
|
|
141
|
+
|
|
108
142
|
end
|
metadata
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-cloudfront-log-optimized
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- kubihee
|
|
8
8
|
- lenfree
|
|
9
9
|
- kjwierenga
|
|
10
|
-
autorequire:
|
|
10
|
+
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date:
|
|
13
|
+
date: 2025-11-10 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: fluentd
|
|
@@ -66,14 +66,14 @@ dependencies:
|
|
|
66
66
|
requirements:
|
|
67
67
|
- - "~>"
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '
|
|
69
|
+
version: '2.0'
|
|
70
70
|
type: :development
|
|
71
71
|
prerelease: false
|
|
72
72
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
73
|
requirements:
|
|
74
74
|
- - "~>"
|
|
75
75
|
- !ruby/object:Gem::Version
|
|
76
|
-
version: '
|
|
76
|
+
version: '2.0'
|
|
77
77
|
- !ruby/object:Gem::Dependency
|
|
78
78
|
name: rake
|
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -111,11 +111,14 @@ executables: []
|
|
|
111
111
|
extensions: []
|
|
112
112
|
extra_rdoc_files: []
|
|
113
113
|
files:
|
|
114
|
+
- ".devcontainer/Dockerfile"
|
|
115
|
+
- ".devcontainer/devcontainer.json"
|
|
114
116
|
- ".gitignore"
|
|
115
117
|
- CHANGELOG.md
|
|
116
118
|
- Gemfile
|
|
117
119
|
- README.md
|
|
118
120
|
- Rakefile
|
|
121
|
+
- benchmark-gsub-vs-replace.rb
|
|
119
122
|
- fluent-plugin-cloudfront-log-optimized.gemspec
|
|
120
123
|
- lib/fluent/plugin/enumerable_inflater.rb
|
|
121
124
|
- lib/fluent/plugin/in_cloudfront_log.rb
|
|
@@ -124,7 +127,7 @@ files:
|
|
|
124
127
|
homepage: https://github.com/kjwierenga/fluent-plugin-cloudfront-log-optimized
|
|
125
128
|
licenses: []
|
|
126
129
|
metadata: {}
|
|
127
|
-
post_install_message:
|
|
130
|
+
post_install_message:
|
|
128
131
|
rdoc_options: []
|
|
129
132
|
require_paths:
|
|
130
133
|
- lib
|
|
@@ -139,8 +142,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
139
142
|
- !ruby/object:Gem::Version
|
|
140
143
|
version: '0'
|
|
141
144
|
requirements: []
|
|
142
|
-
rubygems_version: 3.
|
|
143
|
-
signing_key:
|
|
145
|
+
rubygems_version: 3.2.3
|
|
146
|
+
signing_key:
|
|
144
147
|
specification_version: 4
|
|
145
148
|
summary: AWS CloudFront log input plugin optimized for large log files. Credit to
|
|
146
149
|
kubihie and lenfree.
|