fluent-plugin-systemd 1.0.2 → 1.1.0

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: 51791abc856b31177f2053533b7d8d3cf31e9d7d
4
- data.tar.gz: 5e306cc82ca65d76d69bf71f50208b5d3aaed005
2
+ SHA256:
3
+ metadata.gz: 9e95e3feb43d74663b14476d96c92a536ecefdc7c32dc9be68d778640c2fe3e1
4
+ data.tar.gz: e45bd0896dd0f6e0df61006a9bfc13426f78c1aa0da2eb0b7d60f129d7040793
5
5
  SHA512:
6
- metadata.gz: 413d7ff33b0224b0af859e58b58045781fda8dd35139a9b11db5cc37f3a33f9a6f26527de8aa380e78a963049588fb01940d2b4414ac8f3b638b49bb24c3d71f
7
- data.tar.gz: 6fcab5af997ce17913cd44e7cd81531fcc399e1a998f39dfebb2c7b7721eda29b32f1b6e9ef7c0cf744809aee1915cea25ec224c8e4b9e04bcdf119b4cfe6bd1
6
+ metadata.gz: 94ee7b4de1a4fec10b4951861b28b27a39d554f3788378549e8c5bac3632544f7201b03f26c619fa0135535c88c2a1a483a671e6b739c254fe96b67fb280cb63
7
+ data.tar.gz: 27a1148fca72b0b61f4f90c977aebbe3a9e358e78fa81538c6c04e9cdcf04a0894b99e288ed18f4e5779feb97063ebee72e39c58b958ff3e287923f4b4cc2d71
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|
@@ -21,6 +18,10 @@ Join the #plugin-systemd channel on the [Fluentd Slack](http://slack.fluentd.org
21
18
  | > 0.1.0 | >= 0.14.11, < 2 | 3 | >= 2.1 |
22
19
  | 0.0.x | ~> 0.12.0 | 2 | >= 1.9 |
23
20
 
21
+ |fluent-plugin-systemd|fluentd|fluent-package|ruby|
22
+ |----|----|----|----|
23
+ | >= 1.1.0 | >= 0.14.11, < 2 | 5 | >= 3.0 |
24
+
24
25
  * The 1.x.x series is developed from this branch (master)
25
26
  * The 0.0.x series (compatible with fluentd v0.12, and td-agent 2) is maintained on the [0.0.x branch](https://github.com/reevoo/fluent-plugin-systemd/tree/0.0.x)
26
27
 
@@ -28,11 +29,11 @@ Join the #plugin-systemd channel on the [Fluentd Slack](http://slack.fluentd.org
28
29
 
29
30
  Simply use RubyGems:
30
31
 
31
- gem install fluent-plugin-systemd -v 1.0.1
32
+ gem install fluent-plugin-systemd -v 1.0.3
32
33
 
33
34
  or
34
35
 
35
- td-agent-gem install fluent-plugin-systemd -v 1.0.1
36
+ td-agent-gem install fluent-plugin-systemd -v 1.0.3
36
37
 
37
38
  ## Upgrading
38
39
 
@@ -47,8 +48,9 @@ If you are upgrading to version 1.0 from a previous version of this plugin take
47
48
  matches [{ "_SYSTEMD_UNIT": "kubelet.service" }]
48
49
  read_from_head true
49
50
 
50
- <storage kubelet-pos>
51
+ <storage>
51
52
  @type local
53
+ path /var/log/fluentd-journald-kubelet-cursor.json
52
54
  </storage>
53
55
 
54
56
  <entry>
@@ -84,7 +86,7 @@ description of this property and how to use it.
84
86
 
85
87
  **`storage`**
86
88
 
87
- Configuration for a [storage plugin](http://docs.fluentd.org/v0.14/articles/storage-plugin-overview) used to store the journald cursor.
89
+ Configuration for a [storage plugin](https://docs.fluentd.org/storage) used to store the journald cursor.
88
90
 
89
91
  **`read_from_head`**
90
92
 
@@ -214,13 +216,13 @@ On Debian or Ubuntu you might need to install the libsystemd0 package:
214
216
  apt-get install libsystemd0
215
217
  ```
216
218
 
217
- On CentOS or RHEL you might need to install the systemd package:
219
+ On AlmaLinux or RHEL you might need to install the systemd package:
218
220
 
219
221
  ```
220
222
  yum install -y systemd
221
223
  ```
222
224
 
223
- If you want to do this in a CentOS docker image you might first need to remove the `fakesystemd` package.
225
+ If you want to do this in a AlmaLinux docker image you might first need to remove the `fakesystemd` package.
224
226
 
225
227
  ```
226
228
  yum remove -y fakesystemd
@@ -252,14 +254,17 @@ We have adopted the [Contributor Covenant](CODE_OF_CONDUCT.md) and thus expect a
252
254
 
253
255
  Many thanks to our fantastic contributors
254
256
 
255
- * [Hiroshi Hatake](https://github.com/cosmo0920)
256
257
  * [Erik Maciejewski](https://github.com/emacski)
257
- * [Masahiro Nakagawa](https://github.com/repeatedly)
258
- * [Richard Megginson](https://github.com/richm)
259
- * [Mike Kaplinskiy](https://github.com/mikekap)
260
- * [neko-neko](https://github.com/neko-neko)
261
- * [Sadayuki Furuhashi](https://github.com/frsyuki)
258
+ * [Ernie Hershey](https://github.com/ehershey)
259
+ * [Hiroshi Hatake](https://github.com/cosmo0920)
262
260
  * [Jesus Rafael Carrillo](https://github.com/jescarri)
261
+ * [Joel Gerber](https://github.com/Jitsusama)
263
262
  * [John Thomas Wile II](https://github.com/jtwile2)
264
263
  * [Kazuhiro Suzuki](https://github.com/ksauzz)
265
- * [Joel Gerber](https://github.com/Jitsusama)
264
+ * [Marius Grigoriu](https://github.com/mariusgrigoriu)
265
+ * [Masahiro Nakagawa](https://github.com/repeatedly)
266
+ * [Mike Kaplinskiy](https://github.com/mikekap)
267
+ * [Richard Megginson](https://github.com/richm)
268
+ * [Sadayuki Furuhashi](https://github.com/frsyuki)
269
+ * [Seiichi Nishikata](https://github.com/neko-neko)
270
+ * [Kentaro Hayashi](https://github.com/kenhys)
@@ -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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-systemd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
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: 2019-02-07 00:00:00.000000000 Z
11
+ date: 2024-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -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: 2.0.0
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: 2.0.0
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.5.11
135
+ signing_key:
137
136
  specification_version: 4
138
137
  summary: Input plugin to read from systemd journal.
139
138
  test_files: []