fluent-plugin-systemd 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 05b2387f068e7c0ec23f74f61bb5d1b031fbd670
4
- data.tar.gz: 438b9f07ea3b23d6af05077ec460f51e413002e4
2
+ SHA256:
3
+ metadata.gz: 4cb4c7536e7d15ebea8d31cab4e9bd1902cfcdf3fcb9adba98b7c957d16a78f0
4
+ data.tar.gz: 1d18922ec4c903834251e2a325e911c9d4746c164b69d2947aadb0b3c768ab3e
5
5
  SHA512:
6
- metadata.gz: 23d0e490a9befa2d01ea8fd6092dbed234ea8a31e3433cb458a584195d0ba6a08376881641df75db4fb139887e869b66c935a58ce7daf796d24bea8b533020fa
7
- data.tar.gz: 7ac5767e188b7ef944c62415a7e13eb100effa83f05784377b7fa071b9a6cbc52eaf72f7f45a5d593d0302474e4ca858d746a616ae1ec2a8522c62f20cc09dc8
6
+ metadata.gz: 601f2f07b040378c78a53f8cdce16a53a3d691a9634b4a8e7d85c4c6bf1ec5c2d84f52271ff0a6040d70437f97f975825ff228809e7524921b02bdcd0715c154
7
+ data.tar.gz: 0f42d023c28dbd644391693c7973ccb34542fc71fcf5e0b2ac97178522549fc7e2dd43b6472622d313a9008073c9712d8b15eb809bc676ca1121e5ec5cd669a9
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # systemd plugin for [Fluentd](http://github.com/fluent/fluentd)
2
2
 
3
- [![Build Status](https://travis-ci.org/reevoo/fluent-plugin-systemd.svg?branch=master)](https://travis-ci.org/reevoo/fluent-plugin-systemd) [![Code Climate GPA](https://codeclimate.com/github/reevoo/fluent-plugin-systemd/badges/gpa.svg)](https://codeclimate.com/github/reevoo/fluent-plugin-systemd) [![Gem Version](https://badge.fury.io/rb/fluent-plugin-systemd.svg)](https://rubygems.org/gems/fluent-plugin-systemd)
3
+ [![Build Status](https://github.com/fluent-plugin-systemd/fluent-plugin-systemd/actions/workflows/ci.yml/badge.svg)](https://github.com/fluent-plugin-systemd/fluent-plugin-systemd/actions/workflows/ci.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/5c773a4c1c6a6964fa4b/maintainability)](https://codeclimate.com/github/fluent-plugin-systemd/fluent-plugin-systemd/maintainability) [![Gem Version](https://badge.fury.io/rb/fluent-plugin-systemd.svg)](https://rubygems.org/gems/fluent-plugin-systemd)
4
4
 
5
5
  ## Overview
6
6
 
@@ -9,11 +9,8 @@
9
9
 
10
10
  ## Support
11
11
 
12
- [![Fluentd Slack](http://slack.fluentd.org/badge.svg)](http://slack.fluentd.org/)
13
-
14
12
  Join the #plugin-systemd channel on the [Fluentd Slack](http://slack.fluentd.org/)
15
13
 
16
-
17
14
  ## Requirements
18
15
 
19
16
  |fluent-plugin-systemd|fluentd|td-agent|ruby|
@@ -28,11 +25,11 @@ Join the #plugin-systemd channel on the [Fluentd Slack](http://slack.fluentd.org
28
25
 
29
26
  Simply use RubyGems:
30
27
 
31
- gem install fluent-plugin-systemd -v 1.0.0
28
+ gem install fluent-plugin-systemd -v 1.0.3
32
29
 
33
30
  or
34
31
 
35
- td-agent-gem install fluent-plugin-systemd -v 1.0.0
32
+ td-agent-gem install fluent-plugin-systemd -v 1.0.3
36
33
 
37
34
  ## Upgrading
38
35
 
@@ -42,25 +39,30 @@ If you are upgrading to version 1.0 from a previous version of this plugin take
42
39
 
43
40
  <source>
44
41
  @type systemd
45
- tag kube-proxy
42
+ tag kubelet
46
43
  path /var/log/journal
47
- matches [{ "_SYSTEMD_UNIT": "kube-proxy.service" }]
44
+ matches [{ "_SYSTEMD_UNIT": "kubelet.service" }]
48
45
  read_from_head true
46
+
49
47
  <storage>
50
48
  @type local
51
- persistent false
52
- path kube-proxy.pos
49
+ path /var/log/fluentd-journald-kubelet-cursor.json
53
50
  </storage>
51
+
54
52
  <entry>
55
53
  fields_strip_underscores true
56
54
  fields_lowercase true
57
55
  </entry>
58
56
  </source>
59
57
 
60
- <match kube-proxy>
58
+ <match kubelet>
61
59
  @type stdout
62
60
  </match>
63
61
 
62
+ <system>
63
+ root_dir /var/log/fluentd
64
+ </system>
65
+
64
66
  **`path`**
65
67
 
66
68
  Path to the systemd journal, defaults to `/var/log/journal`
@@ -80,7 +82,7 @@ description of this property and how to use it.
80
82
 
81
83
  **`storage`**
82
84
 
83
- Configuration for a [storage plugin](http://docs.fluentd.org/v0.14/articles/storage-plugin-overview) used to store the journald cursor.
85
+ Configuration for a [storage plugin](https://docs.fluentd.org/storage) used to store the journald cursor.
84
86
 
85
87
  **`read_from_head`**
86
88
 
@@ -186,6 +188,16 @@ Another strategy would be to use a plugin like [fluent-plugin-concat](https://gi
186
188
  * You can use an [offical fluentd docker](https://github.com/fluent/fluentd-docker-image) image as a base, (choose the debian based version, as alpine linux doesn't support systemd).
187
189
  * Bind mount `/var/log/journal` into your container.
188
190
 
191
+ > ### I am seeing lots of logs being generated very rapidly!
192
+
193
+ This commonly occurs when a loop is created when fluentd is logging to STDOUT, and the collected logs are then written to the systemd journal. This could happen if you run fluentd as a systemd serivce, or as a docker container with the systemd log driver.
194
+
195
+ Workarounds include:
196
+
197
+ * Use another fluentd output
198
+ * Don't read every message from the journal, set some `matches` so you only read the messages you are interested in.
199
+ * Disable the systemd log driver when you launch your fluentd docker container, e.g. by passing `--log-driver json-file`
200
+
189
201
  ### Example
190
202
 
191
203
  For an example of a full working setup including the plugin, take a look at [the fluentd kubernetes daemonset](https://github.com/fluent/fluentd-kubernetes-daemonset)
@@ -238,14 +250,16 @@ We have adopted the [Contributor Covenant](CODE_OF_CONDUCT.md) and thus expect a
238
250
 
239
251
  Many thanks to our fantastic contributors
240
252
 
241
- * [Hiroshi Hatake](https://github.com/cosmo0920)
242
253
  * [Erik Maciejewski](https://github.com/emacski)
243
- * [Masahiro Nakagawa](https://github.com/repeatedly)
244
- * [Richard Megginson](https://github.com/richm)
245
- * [Mike Kaplinskiy](https://github.com/mikekap)
246
- * [neko-neko](https://github.com/neko-neko)
247
- * [Sadayuki Furuhashi](https://github.com/frsyuki)
254
+ * [Ernie Hershey](https://github.com/ehershey)
255
+ * [Hiroshi Hatake](https://github.com/cosmo0920)
248
256
  * [Jesus Rafael Carrillo](https://github.com/jescarri)
257
+ * [Joel Gerber](https://github.com/Jitsusama)
249
258
  * [John Thomas Wile II](https://github.com/jtwile2)
250
259
  * [Kazuhiro Suzuki](https://github.com/ksauzz)
251
- * [Joel Gerber](https://github.com/Jitsusama)
260
+ * [Marius Grigoriu](https://github.com/mariusgrigoriu)
261
+ * [Masahiro Nakagawa](https://github.com/repeatedly)
262
+ * [Mike Kaplinskiy](https://github.com/mikekap)
263
+ * [Richard Megginson](https://github.com/richm)
264
+ * [Sadayuki Furuhashi](https://github.com/frsyuki)
265
+ * [Seiichi Nishikata](https://github.com/neko-neko)
@@ -21,7 +21,7 @@ require 'fluent/plugin/systemd/entry_mutator'
21
21
  module Fluent
22
22
  module Plugin
23
23
  # Fluentd plugin for reading from the systemd journal
24
- class SystemdInput < Input
24
+ class SystemdInput < Input # rubocop:disable Metrics/ClassLength
25
25
  Fluent::Plugin.register_input('systemd', self)
26
26
 
27
27
  helpers :timer, :storage
@@ -57,18 +57,25 @@ module Fluent
57
57
 
58
58
  def start
59
59
  super
60
+ @running = true
60
61
  timer_execute(:in_systemd_emit_worker, 1, &method(:run))
61
62
  end
62
63
 
64
+ def shutdown
65
+ @running = false
66
+ @journal&.close
67
+ @journal = nil
68
+ @pos_storage = nil
69
+ @mutator = nil
70
+ super
71
+ end
72
+
63
73
  private
64
74
 
65
75
  def init_journal
66
76
  # TODO: ruby 2.3
67
77
  @journal.close if @journal # rubocop:disable Style/SafeNavigation
68
78
  @journal = Systemd::Journal.new(path: @path)
69
- # make sure initial call to wait doesn't return :invalidate
70
- # see https://github.com/ledbettj/systemd-journal/issues/70
71
- @journal.wait(0)
72
79
  @journal.filter(*(@matches || @filters))
73
80
  seek
74
81
  true
@@ -95,6 +102,7 @@ module Fluent
95
102
  def seek_to(pos)
96
103
  @journal.seek(pos)
97
104
  return if pos == :head
105
+
98
106
  if pos == :tail
99
107
  @journal.move(-2)
100
108
  else
@@ -108,6 +116,7 @@ module Fluent
108
116
 
109
117
  def run
110
118
  return unless @journal || init_journal
119
+
111
120
  init_journal if @journal.wait(0) == :invalidate
112
121
  watch do |entry|
113
122
  emit(entry)
@@ -119,6 +128,7 @@ module Fluent
119
128
  rescue Fluent::Plugin::Buffer::BufferOverflowError => e
120
129
  retries ||= 0
121
130
  raise e if retries > 10
131
+
122
132
  retries += 1
123
133
  sleep 1.5**retries + rand(0..3)
124
134
  retry
@@ -131,7 +141,9 @@ module Fluent
131
141
  end
132
142
 
133
143
  def watch(&block)
134
- yield_current_entry(&block) while @journal.move_next
144
+ yield_current_entry(&block) while @running && @journal.move_next
145
+ rescue Systemd::JournalError => e
146
+ log.warn("Error moving to next Journal entry: #{e.class}: #{e.message}")
135
147
  end
136
148
 
137
149
  def yield_current_entry
@@ -67,6 +67,7 @@ module Fluent
67
67
  # Expose config state as read-only instance properties of the mutator.
68
68
  def method_missing(sym, *args)
69
69
  return @opts[sym] if @opts.members.include?(sym)
70
+
70
71
  super
71
72
  end
72
73
 
@@ -80,6 +81,7 @@ module Fluent
80
81
  def run(entry)
81
82
  return entry.to_h if @no_transform
82
83
  return map_fields(entry) if @opts.field_map_strict
84
+
83
85
  format_fields(entry, map_fields(entry))
84
86
  end
85
87
 
@@ -90,6 +92,7 @@ module Fluent
90
92
  @map.each_with_object({}) do |(cstm, sysds), mapped|
91
93
  vals = sysds.collect { |fld| entry[fld] }.compact
92
94
  next if vals.empty? # systemd field does not exist in source entry
95
+
93
96
  mapped[cstm] = join_if_needed(vals)
94
97
  end
95
98
  end
@@ -103,6 +106,7 @@ module Fluent
103
106
  entry.each_with_object(mapped || {}) do |(fld, val), formatted_entry|
104
107
  # don't mess with explicitly mapped fields
105
108
  next if @map_src_fields.include?(fld)
109
+
106
110
  fld = format_field_name(fld)
107
111
  # account for mapping (appending) to an existing systemd field
108
112
  formatted_entry[fld] = join_if_needed([val, mapped[fld]])
@@ -111,6 +115,7 @@ module Fluent
111
115
 
112
116
  def warnings
113
117
  return [] unless field_map_strict && field_map.empty?
118
+
114
119
  '`field_map_strict` set to true with empty `field_map`, expect no fields'
115
120
  end
116
121
 
@@ -119,6 +124,7 @@ module Fluent
119
124
  def join_if_needed(values)
120
125
  values.compact!
121
126
  return values.first if values.length == 1
127
+
122
128
  values.join(' ')
123
129
  end
124
130
 
@@ -146,7 +152,7 @@ module Fluent
146
152
  end
147
153
  end
148
154
 
149
- def validate_all_strings(arr, message, allow_nesting = false)
155
+ def validate_all_strings(arr, message, allow_nesting = false) # rubocop:disable Style/OptionalBooleanParameter
150
156
  valid = arr.all? do |value|
151
157
  value.is_a?(String) || allow_nesting && value.is_a?(Array) && value.all? { |key| key.is_a?(String) }
152
158
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-systemd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Robinson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-10 00:00:00.000000000 Z
11
+ date: 2021-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.5'
47
+ version: '3.4'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.5'
54
+ version: '3.4'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rubocop
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 0.53.0
61
+ version: 1.13.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 0.53.0
68
+ version: 1.13.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fluentd
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -92,14 +92,14 @@ dependencies:
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '1.3'
95
+ version: 1.4.2
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '1.3'
102
+ version: 1.4.2
103
103
  description: This is a fluentd input plugin. It reads logs from the systemd journal.
104
104
  email:
105
105
  - edward-robinson@cookpad.com
@@ -116,7 +116,7 @@ homepage: https://github.com/reevoo/fluent-plugin-systemd
116
116
  licenses:
117
117
  - Apache-2.0
118
118
  metadata: {}
119
- post_install_message:
119
+ post_install_message:
120
120
  rdoc_options: []
121
121
  require_paths:
122
122
  - lib
@@ -131,9 +131,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubyforge_project:
135
- rubygems_version: 2.6.13
136
- signing_key:
134
+ rubygems_version: 3.2.15
135
+ signing_key:
137
136
  specification_version: 4
138
137
  summary: Input plugin to read from systemd journal.
139
138
  test_files: []