fluent-plugin-systemd 1.0.1 → 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: c6e9aac538e4ec4e1a65dae4873493e2439b8b59
4
- data.tar.gz: f6589478860a0b2864929339651005df1732d9b0
2
+ SHA256:
3
+ metadata.gz: 4cb4c7536e7d15ebea8d31cab4e9bd1902cfcdf3fcb9adba98b7c957d16a78f0
4
+ data.tar.gz: 1d18922ec4c903834251e2a325e911c9d4746c164b69d2947aadb0b3c768ab3e
5
5
  SHA512:
6
- metadata.gz: d0efddc0d59ca876d8b7cd356dd9f238b99eb5d6c55cd2fee5ae65e26bceeea9d6f61afbcc1f5b17e1eed891fc30f744a81bd01a7ef475b62db821a1415a6018
7
- data.tar.gz: 7613bdc750bab5a6738e27540aa30ce55affa625614c9b848302995ef642adc41250c091f16f1eecd80193940d281e118977416dcf4ada17fe4ca0eccb709340
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.1
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.1
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
 
@@ -248,14 +250,16 @@ We have adopted the [Contributor Covenant](CODE_OF_CONDUCT.md) and thus expect a
248
250
 
249
251
  Many thanks to our fantastic contributors
250
252
 
251
- * [Hiroshi Hatake](https://github.com/cosmo0920)
252
253
  * [Erik Maciejewski](https://github.com/emacski)
253
- * [Masahiro Nakagawa](https://github.com/repeatedly)
254
- * [Richard Megginson](https://github.com/richm)
255
- * [Mike Kaplinskiy](https://github.com/mikekap)
256
- * [neko-neko](https://github.com/neko-neko)
257
- * [Sadayuki Furuhashi](https://github.com/frsyuki)
254
+ * [Ernie Hershey](https://github.com/ehershey)
255
+ * [Hiroshi Hatake](https://github.com/cosmo0920)
258
256
  * [Jesus Rafael Carrillo](https://github.com/jescarri)
257
+ * [Joel Gerber](https://github.com/Jitsusama)
259
258
  * [John Thomas Wile II](https://github.com/jtwile2)
260
259
  * [Kazuhiro Suzuki](https://github.com/ksauzz)
261
- * [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,9 +57,19 @@ 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
@@ -92,6 +102,7 @@ module Fluent
92
102
  def seek_to(pos)
93
103
  @journal.seek(pos)
94
104
  return if pos == :head
105
+
95
106
  if pos == :tail
96
107
  @journal.move(-2)
97
108
  else
@@ -105,6 +116,7 @@ module Fluent
105
116
 
106
117
  def run
107
118
  return unless @journal || init_journal
119
+
108
120
  init_journal if @journal.wait(0) == :invalidate
109
121
  watch do |entry|
110
122
  emit(entry)
@@ -116,6 +128,7 @@ module Fluent
116
128
  rescue Fluent::Plugin::Buffer::BufferOverflowError => e
117
129
  retries ||= 0
118
130
  raise e if retries > 10
131
+
119
132
  retries += 1
120
133
  sleep 1.5**retries + rand(0..3)
121
134
  retry
@@ -128,7 +141,9 @@ module Fluent
128
141
  end
129
142
 
130
143
  def watch(&block)
131
- 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}")
132
147
  end
133
148
 
134
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.1
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-06-12 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.2
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.2
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: []