fluent-plugin-kafka 0.19.6 → 0.19.7
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/.github/dependabot.yml +1 -1
- data/.github/workflows/add-to-project.yml +9 -2
- data/.github/workflows/linux.yml +14 -6
- data/.github/workflows/stale-actions.yml +4 -1
- data/ChangeLog +3 -0
- data/README.md +4 -0
- data/ci/prepare-kafka-server.sh +13 -1
- data/fluent-plugin-kafka.gemspec +1 -1
- data/lib/fluent/plugin/in_rdkafka_group.rb +20 -3
- data/test/plugin/test_in_rdkafka_group.rb +128 -0
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2a709cad3615bca0c45f0606644142278acbb75b8e43f766dd4a1821a624aa75
|
|
4
|
+
data.tar.gz: 269bfdaa2ef8fb7b6cbb254971cc728769aba7215a472a73b34af2c04d735f6f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b15df023bd526fb22752da54b460ed12ce9a2d3c35e3ad9959c86d1ba8ac06fb9915799da95135fec3c6911ae776375ee8bc13f4803cad6663e2b60351b302c1
|
|
7
|
+
data.tar.gz: f9bfe163282d53f4f583ac905bffd50cab6eeaaaf5da2b9bf7511c7dad064c3aff458252af784ff8a52a3b6b5b63c80d47fccc80677692f58dc8a9fed814e6f4
|
data/.github/dependabot.yml
CHANGED
|
@@ -10,8 +10,15 @@ jobs:
|
|
|
10
10
|
name: Add issue to project
|
|
11
11
|
runs-on: ubuntu-latest
|
|
12
12
|
steps:
|
|
13
|
-
-
|
|
13
|
+
- name: Generate token
|
|
14
|
+
id: generate_token
|
|
15
|
+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
16
|
+
with:
|
|
17
|
+
app-id: ${{ secrets.PROJECT_APP_ID }}
|
|
18
|
+
private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
|
|
19
|
+
owner: fluent
|
|
20
|
+
- uses: actions/add-to-project@5afcf98fcd03f1c2f92c3c83f58ae24323cc57fd # v2.0.0
|
|
14
21
|
with:
|
|
15
22
|
project-url: https://github.com/orgs/fluent/projects/4
|
|
16
|
-
github-token: ${{
|
|
23
|
+
github-token: ${{ steps.generate_token.outputs.token }}
|
|
17
24
|
labeled: waiting-for-triage
|
data/.github/workflows/linux.yml
CHANGED
|
@@ -4,15 +4,23 @@ on:
|
|
|
4
4
|
branches: [master]
|
|
5
5
|
pull_request:
|
|
6
6
|
branches: [master]
|
|
7
|
+
schedule:
|
|
8
|
+
- cron: '0 0 1 * *'
|
|
7
9
|
jobs:
|
|
10
|
+
ruby-versions:
|
|
11
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
|
12
|
+
with:
|
|
13
|
+
engine: cruby
|
|
14
|
+
min_version: 3.0
|
|
8
15
|
build:
|
|
16
|
+
needs: ruby-versions
|
|
9
17
|
runs-on: ${{ matrix.os }}
|
|
10
18
|
env:
|
|
11
19
|
USE_RDKAFKA: 1
|
|
12
20
|
strategy:
|
|
13
21
|
fail-fast: false
|
|
14
22
|
matrix:
|
|
15
|
-
ruby:
|
|
23
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
|
16
24
|
os:
|
|
17
25
|
- ubuntu-latest
|
|
18
26
|
rdkafka_versions:
|
|
@@ -23,6 +31,7 @@ jobs:
|
|
|
23
31
|
- { min: '>= 0.25.0', max: '>= 0.25.0' }
|
|
24
32
|
# rdkafka 0.25.0 supports Ruby 3.2+, so we exclude it for Ruby 3.0 and 3.1
|
|
25
33
|
exclude:
|
|
34
|
+
- ruby: head
|
|
26
35
|
- ruby: '3.1'
|
|
27
36
|
rdkafka_versions: { min: '>= 0.25.0', max: '>= 0.25.0' }
|
|
28
37
|
- ruby: '3.0'
|
|
@@ -37,17 +46,17 @@ jobs:
|
|
|
37
46
|
rdkafka_versions: { min: '>= 0.12.0', max: '= 0.15.2' }
|
|
38
47
|
name: Ruby ${{ matrix.ruby }} unit testing on ${{ matrix.os }} with rdkafka gem version (min ${{ matrix.rdkafka_versions.min }} max ${{ matrix.rdkafka_versions.max }})
|
|
39
48
|
steps:
|
|
40
|
-
- uses: actions/checkout@v6
|
|
41
|
-
- uses: ruby/setup-ruby@v1
|
|
49
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
50
|
+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1.310.0
|
|
42
51
|
with:
|
|
43
52
|
ruby-version: ${{ matrix.ruby }}
|
|
44
53
|
- name: Install confluent-kafka
|
|
45
54
|
run: |
|
|
46
55
|
sudo apt install -V -y gnupg2 wget
|
|
47
|
-
wget https://packages.confluent.io/deb/
|
|
56
|
+
wget https://packages.confluent.io/deb/7.9/archive.key
|
|
48
57
|
sudo gpg2 --homedir /tmp --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/confluent-archive-keyring.gpg --import archive.key
|
|
49
58
|
sudo chmod 644 /usr/share/keyrings/confluent-archive-keyring.gpg
|
|
50
|
-
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/confluent-archive-keyring.gpg] https://packages.confluent.io/deb/
|
|
59
|
+
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/confluent-archive-keyring.gpg] https://packages.confluent.io/deb/7.9 stable main" > /etc/apt/sources.list.d/confluent.list'
|
|
51
60
|
sudo apt update
|
|
52
61
|
sudo apt install -y confluent-community-2.13 openjdk-11-jre netcat-openbsd
|
|
53
62
|
- name: unit testing
|
|
@@ -57,6 +66,5 @@ jobs:
|
|
|
57
66
|
RDKAFKA_VERSION_MAX_RANGE: ${{ matrix.rdkafka_versions.max }}
|
|
58
67
|
run: |
|
|
59
68
|
sudo ./ci/prepare-kafka-server.sh
|
|
60
|
-
gem install rake
|
|
61
69
|
bundle install --jobs 4 --retry 3
|
|
62
70
|
bundle exec rake test
|
|
@@ -6,8 +6,11 @@ on:
|
|
|
6
6
|
jobs:
|
|
7
7
|
stale:
|
|
8
8
|
runs-on: ubuntu-latest
|
|
9
|
+
permissions:
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
9
12
|
steps:
|
|
10
|
-
- uses: actions/stale@v10
|
|
13
|
+
- uses: actions/stale@eb5cf3af3ac0a1aa4c9c45633dd1ae542a27a899 # v10.3.0
|
|
11
14
|
with:
|
|
12
15
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
|
13
16
|
days-before-stale: 90
|
data/ChangeLog
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
Release 0.19.7 - 2026/06/02
|
|
2
|
+
* in_rdkafka_group: support regexp pattern in topics (#541)
|
|
3
|
+
|
|
1
4
|
Release 0.19.6 - 2026/03/04
|
|
2
5
|
* out_rdkafka2: Auto-configure SASL PLAIN when username and password are set (#547)
|
|
3
6
|
* out_rdkafka2: Fix NoMethodError during graceful reload (#546)
|
data/README.md
CHANGED
|
@@ -177,6 +177,10 @@ With the introduction of the rdkafka-ruby based input plugin we hope to support
|
|
|
177
177
|
|
|
178
178
|
See also [rdkafka-ruby](https://github.com/appsignal/rdkafka-ruby) and [librdkafka](https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md) for more detailed documentation about Kafka consumer options.
|
|
179
179
|
|
|
180
|
+
`topics` supports POSIX Extended Regular Expression pattern (not Ruby regex syntax) since v0.19.6. If you want to use regex pattern, use `/pattern/` like `/foo.*/`.
|
|
181
|
+
|
|
182
|
+
**Note**: A caret (`^`) is automatically added to the beginning of the pattern.
|
|
183
|
+
|
|
180
184
|
Consuming topic name is used for event tag. So when the target topic name is `app_event`, the tag is `app_event`. If you want to modify tag, use `add_prefix` or `add_suffix` parameter. With `add_prefix kafka`, the tag is `kafka.app_event`.
|
|
181
185
|
|
|
182
186
|
### Output plugin
|
data/ci/prepare-kafka-server.sh
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
|
|
3
|
+
set -x
|
|
4
|
+
|
|
3
5
|
export KAFKA_OPTS=-Dzookeeper.4lw.commands.whitelist=ruok
|
|
4
6
|
/usr/bin/zookeeper-server-start /etc/kafka/zookeeper.properties &
|
|
5
7
|
N_POLLING=30
|
|
@@ -30,4 +32,14 @@ while true ; do
|
|
|
30
32
|
exit 1
|
|
31
33
|
fi
|
|
32
34
|
done
|
|
33
|
-
|
|
35
|
+
# kafka-topics --version fails to connect zookeeper here.
|
|
36
|
+
case "$(java -cp "/usr/share/java/kafka/*" kafka.Kafka --version 2>/dev/null)" in
|
|
37
|
+
7.*)
|
|
38
|
+
/usr/bin/kafka-topics --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic test
|
|
39
|
+
;;
|
|
40
|
+
*)
|
|
41
|
+
# Deprecated zookeeper
|
|
42
|
+
/usr/bin/kafka-topics --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
|
|
43
|
+
;;
|
|
44
|
+
esac
|
|
45
|
+
|
data/fluent-plugin-kafka.gemspec
CHANGED
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
|
13
13
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
14
14
|
gem.name = "fluent-plugin-kafka"
|
|
15
15
|
gem.require_paths = ["lib"]
|
|
16
|
-
gem.version = '0.19.
|
|
16
|
+
gem.version = '0.19.7'
|
|
17
17
|
gem.required_ruby_version = ">= 2.1.0"
|
|
18
18
|
|
|
19
19
|
gem.add_dependency "fluentd", [">= 0.10.58", "< 2"]
|
|
@@ -76,13 +76,25 @@ class Fluent::Plugin::RdKafkaGroupInput < Fluent::Plugin::Input
|
|
|
76
76
|
end
|
|
77
77
|
config_array
|
|
78
78
|
end
|
|
79
|
+
private :_config_to_array
|
|
80
|
+
|
|
81
|
+
def regex_pattern?(topic)
|
|
82
|
+
topic.start_with?('/') && topic.end_with?('/') ? true : false
|
|
83
|
+
end
|
|
84
|
+
private :regex_pattern?
|
|
85
|
+
|
|
86
|
+
def _config_regex_pattern(topic)
|
|
87
|
+
# librdkafka recognizes string as regex pattern if the topic name starts with '^'.
|
|
88
|
+
# https://github.com/confluentinc/librdkafka/blob/570c785e9e35812db8f50254bd2f7e0cf47def39/src/rdkafka.h#L4148
|
|
89
|
+
# https://github.com/confluentinc/librdkafka/blob/e1db7eaa517f0a6438bc846a9c49ede73b9ea211/src/rdkafka_topic.c#L2064
|
|
90
|
+
[topic[1..-2].prepend('^')]
|
|
91
|
+
end
|
|
92
|
+
private :_config_regex_pattern
|
|
79
93
|
|
|
80
94
|
def multi_workers_ready?
|
|
81
95
|
true
|
|
82
96
|
end
|
|
83
97
|
|
|
84
|
-
private :_config_to_array
|
|
85
|
-
|
|
86
98
|
def configure(conf)
|
|
87
99
|
compat_parameters_convert(conf, :parser)
|
|
88
100
|
|
|
@@ -93,7 +105,12 @@ class Fluent::Plugin::RdKafkaGroupInput < Fluent::Plugin::Input
|
|
|
93
105
|
log.info "Will watch for topics #{@topics} at brokers " \
|
|
94
106
|
"#{@kafka_configs["bootstrap.servers"]} and '#{@kafka_configs["group.id"]}' group"
|
|
95
107
|
|
|
96
|
-
|
|
108
|
+
topics = @topics.strip
|
|
109
|
+
if regex_pattern?(topics)
|
|
110
|
+
@topics = _config_regex_pattern(topics)
|
|
111
|
+
else
|
|
112
|
+
@topics = _config_to_array(topics)
|
|
113
|
+
end
|
|
97
114
|
|
|
98
115
|
parser_conf = conf.elements('parse').first
|
|
99
116
|
unless parser_conf
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require 'helper'
|
|
2
|
+
require 'fluent/test/driver/input'
|
|
3
|
+
require 'securerandom'
|
|
4
|
+
|
|
5
|
+
class RdkafkaGroupInputTest < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def have_rdkafka
|
|
8
|
+
begin
|
|
9
|
+
require 'fluent/plugin/in_rdkafka_group'
|
|
10
|
+
true
|
|
11
|
+
rescue LoadError
|
|
12
|
+
false
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def setup
|
|
17
|
+
omit_unless(have_rdkafka, "rdkafka isn't installed")
|
|
18
|
+
Fluent::Test.setup
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
TOPIC_NAME = "kafka-input-#{SecureRandom.uuid}"
|
|
22
|
+
|
|
23
|
+
CONFIG = %[
|
|
24
|
+
topics #{TOPIC_NAME}
|
|
25
|
+
kafka_configs {"bootstrap.servers": "localhost:9092", "group.id": "test_group"}
|
|
26
|
+
<parse>
|
|
27
|
+
@type none
|
|
28
|
+
</parse>
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
def create_driver(conf = CONFIG)
|
|
32
|
+
Fluent::Test::Driver::Input.new(Fluent::Plugin::RdKafkaGroupInput).configure(conf)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def test_configure
|
|
37
|
+
d = create_driver
|
|
38
|
+
assert_equal [TOPIC_NAME], d.instance.topics
|
|
39
|
+
assert_equal 'localhost:9092', d.instance.kafka_configs['bootstrap.servers']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def test_multi_worker_support
|
|
43
|
+
d = create_driver
|
|
44
|
+
assert_true d.instance.multi_workers_ready?
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
class ConsumeTest < self
|
|
48
|
+
TOPIC_NAME = "kafka-input-#{SecureRandom.uuid}"
|
|
49
|
+
|
|
50
|
+
def setup
|
|
51
|
+
@kafka = Kafka.new(["localhost:9092"], client_id: 'kafka')
|
|
52
|
+
@producer = @kafka.producer
|
|
53
|
+
@kafka.create_topic(TOPIC_NAME)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def teardown
|
|
57
|
+
@kafka.delete_topic(TOPIC_NAME)
|
|
58
|
+
@kafka.close
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def test_consume
|
|
62
|
+
conf = %[
|
|
63
|
+
topics #{TOPIC_NAME}
|
|
64
|
+
kafka_configs {"bootstrap.servers": "localhost:9092", "group.id": "test_group"}
|
|
65
|
+
<parse>
|
|
66
|
+
@type none
|
|
67
|
+
</parse>
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
d = create_driver(conf)
|
|
71
|
+
|
|
72
|
+
d.run(expect_records: 1, timeout: 10) do
|
|
73
|
+
sleep 0.1
|
|
74
|
+
@producer.produce("Hello, fluent-plugin-kafka!", topic: TOPIC_NAME)
|
|
75
|
+
@producer.deliver_messages
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
expected = {'message' => 'Hello, fluent-plugin-kafka!'}
|
|
79
|
+
assert_equal expected, d.events[0][2]
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
class ConsumeTopicWithRegexpTest < self
|
|
84
|
+
TOPIC_NAME1 = "kafka-input-1-#{SecureRandom.uuid}"
|
|
85
|
+
TOPIC_NAME2 = "kafka-input-22-#{SecureRandom.uuid}"
|
|
86
|
+
UNMATCHED_TOPIC = "kafka-input-333-#{SecureRandom.uuid}"
|
|
87
|
+
|
|
88
|
+
TOPIC_NAME_REGEXP = "/kafka-input-[0-9]{1,2}-.*/"
|
|
89
|
+
|
|
90
|
+
def setup
|
|
91
|
+
@kafka = Kafka.new(["localhost:9092"], client_id: 'kafka')
|
|
92
|
+
@producer = @kafka.producer
|
|
93
|
+
@kafka.create_topic(TOPIC_NAME1)
|
|
94
|
+
@kafka.create_topic(TOPIC_NAME2)
|
|
95
|
+
@kafka.create_topic(UNMATCHED_TOPIC)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def teardown
|
|
99
|
+
@kafka.delete_topic(TOPIC_NAME1)
|
|
100
|
+
@kafka.delete_topic(TOPIC_NAME2)
|
|
101
|
+
@kafka.delete_topic(UNMATCHED_TOPIC)
|
|
102
|
+
@kafka.close
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def test_consume_with_regexp
|
|
106
|
+
conf = %[
|
|
107
|
+
topics #{TOPIC_NAME_REGEXP}
|
|
108
|
+
kafka_configs {"bootstrap.servers": "localhost:9092", "group.id": "test_group"}
|
|
109
|
+
<parse>
|
|
110
|
+
@type none
|
|
111
|
+
</parse>
|
|
112
|
+
]
|
|
113
|
+
d = create_driver(conf)
|
|
114
|
+
|
|
115
|
+
d.run(expect_records: 2, timeout: 10) do
|
|
116
|
+
sleep 0.1
|
|
117
|
+
@producer.produce("Hello, fluent-plugin-kafka! in topic 1", topic: TOPIC_NAME1)
|
|
118
|
+
@producer.produce("Hello, fluent-plugin-kafka! in topic 2", topic: TOPIC_NAME2)
|
|
119
|
+
@producer.produce("Should be ignored", topic: UNMATCHED_TOPIC)
|
|
120
|
+
@producer.deliver_messages
|
|
121
|
+
end
|
|
122
|
+
expected_message_pattern = /Hello, fluent-plugin-kafka! in topic [12]/
|
|
123
|
+
assert_equal 2, d.events.size
|
|
124
|
+
assert_match(expected_message_pattern, d.events[0][2]['message'])
|
|
125
|
+
assert_match(expected_message_pattern, d.events[1][2]['message'])
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-kafka
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.19.
|
|
4
|
+
version: 0.19.7
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hidemasa Togashi
|
|
@@ -192,6 +192,7 @@ files:
|
|
|
192
192
|
- test/helper.rb
|
|
193
193
|
- test/plugin/test_in_kafka.rb
|
|
194
194
|
- test/plugin/test_in_kafka_group.rb
|
|
195
|
+
- test/plugin/test_in_rdkafka_group.rb
|
|
195
196
|
- test/plugin/test_kafka_plugin_util.rb
|
|
196
197
|
- test/plugin/test_out_kafka.rb
|
|
197
198
|
- test/plugin/test_out_kafka2.rb
|
|
@@ -215,13 +216,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
215
216
|
- !ruby/object:Gem::Version
|
|
216
217
|
version: '0'
|
|
217
218
|
requirements: []
|
|
218
|
-
rubygems_version: 4.0.
|
|
219
|
+
rubygems_version: 4.0.10
|
|
219
220
|
specification_version: 4
|
|
220
221
|
summary: Fluentd plugin for Apache Kafka > 0.8
|
|
221
222
|
test_files:
|
|
222
223
|
- test/helper.rb
|
|
223
224
|
- test/plugin/test_in_kafka.rb
|
|
224
225
|
- test/plugin/test_in_kafka_group.rb
|
|
226
|
+
- test/plugin/test_in_rdkafka_group.rb
|
|
225
227
|
- test/plugin/test_kafka_plugin_util.rb
|
|
226
228
|
- test/plugin/test_out_kafka.rb
|
|
227
229
|
- test/plugin/test_out_kafka2.rb
|