fluent-plugin-systemd 0.0.2 → 0.0.3
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/Gemfile +2 -1
- data/README.md +12 -8
- data/Rakefile +21 -17
- data/fluent-plugin-systemd.gemspec +17 -18
- data/lib/fluent/plugin/in_systemd.rb +20 -9
- data/lib/fluent/plugin/systemd/pos_writer.rb +3 -3
- metadata +6 -8
- data/.gitignore +0 -1
- data/.travis.yml +0 -4
- data/Dockerfile +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be742762901719c8b1ded7200a0daca9243088db
|
4
|
+
data.tar.gz: 03634c021da0ce9585eb111a52d0b126e86c7a86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a38856bcc70d5fa68e56f8e6514b8de79bc69719e7b265a8f570c629be5a9196bf9e8f459191b6234ba025ca3bcb47c0921c2ad148647683b1376055a5e415
|
7
|
+
data.tar.gz: 6500153a1b384a79522172abe10977a40a743aa3cd80157928638f4f076fdee2ba0c2c81b84f2e47ab9538b6ed95ee49fc99e28ecc8ba6594e4309bdd8914917
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -10,15 +10,15 @@
|
|
10
10
|
|
11
11
|
Simply use RubyGems:
|
12
12
|
|
13
|
-
gem install fluent-plugin-systemd
|
13
|
+
gem install fluent-plugin-systemd -v 0.0.3
|
14
14
|
|
15
15
|
or
|
16
16
|
|
17
|
-
fluent-gem install fluent-plugin-systemd
|
17
|
+
fluent-gem install fluent-plugin-systemd -v 0.0.3
|
18
18
|
|
19
19
|
or
|
20
20
|
|
21
|
-
td-agent-gem install fluent-plugin-systemd
|
21
|
+
td-agent-gem install fluent-plugin-systemd -v 0.0.3
|
22
22
|
|
23
23
|
## Configuration
|
24
24
|
|
@@ -47,16 +47,20 @@ Path to pos file, stores the journald cursor. File is created if does not exist.
|
|
47
47
|
**read_from_head**
|
48
48
|
|
49
49
|
If true reads all available journal from head, otherwise starts reading from tail,
|
50
|
-
ignored if pos file exists. Defaults to false.
|
50
|
+
ignored if pos file exists (and is valid). Defaults to false.
|
51
51
|
|
52
52
|
**strip_underscores**
|
53
53
|
|
54
|
-
If true strips underscores from the beginning of
|
54
|
+
If true strips underscores from the beginning of systemd field names.
|
55
55
|
May be useful if outputting to kibana, as underscore prefixed fields are unindexed there.
|
56
56
|
|
57
57
|
**tag**
|
58
58
|
|
59
|
-
|
59
|
+
_Required_ A tag that will be added to events generated by this input.
|
60
|
+
|
61
|
+
## Example
|
62
|
+
|
63
|
+
For an example of a full working setup including the plugin, [take a look at](https://github.com/assemblyline/fluentd)
|
60
64
|
|
61
65
|
## Dependencies
|
62
66
|
|
@@ -64,9 +68,9 @@ This plugin depends on libsystemd
|
|
64
68
|
|
65
69
|
## Running the tests
|
66
70
|
|
67
|
-
To run the tests simply run `rake
|
71
|
+
To run the tests with docker on several distros simply run `rake`
|
68
72
|
|
69
|
-
For systems
|
73
|
+
For systems with systemd installed you can run the tests against your installed libsystemd with `rake test`
|
70
74
|
|
71
75
|
## Licence etc
|
72
76
|
|
data/Rakefile
CHANGED
@@ -1,27 +1,31 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rake/testtask"
|
3
|
+
require "reevoocop/rake_task"
|
4
|
+
require "fileutils"
|
4
5
|
|
5
6
|
ReevooCop::RakeTask.new(:reevoocop)
|
6
7
|
|
7
|
-
Rake::TestTask.new(:
|
8
|
-
t.test_files = Dir[
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
9
|
+
t.test_files = Dir["test/**/test_*.rb"]
|
9
10
|
end
|
10
11
|
|
11
|
-
task default: :test
|
12
|
-
task build: :test
|
13
|
-
task
|
12
|
+
task default: "docker:test"
|
13
|
+
task build: "docker:test"
|
14
|
+
task test: :reevoocop
|
14
15
|
|
15
16
|
namespace :docker do
|
16
|
-
|
17
|
-
|
18
|
-
end
|
19
|
-
end
|
17
|
+
distros = [:ubuntu, :"tdagent-ubuntu", :centos, :"tdagent-centos"]
|
18
|
+
task test: distros
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
distros.each do |distro|
|
21
|
+
task distro do
|
22
|
+
puts "testing on #{distro}"
|
23
|
+
begin
|
24
|
+
FileUtils.cp("test/docker/Dockerfile.#{distro}", "Dockerfile")
|
25
|
+
sh "docker build ."
|
26
|
+
ensure
|
27
|
+
FileUtils.rm("Dockerfile")
|
28
|
+
end
|
29
|
+
end
|
26
30
|
end
|
27
31
|
end
|
@@ -1,29 +1,28 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
-
spec.version =
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
7
|
+
spec.name = "fluent-plugin-systemd"
|
8
|
+
spec.version = "0.0.3"
|
9
|
+
spec.authors = ["Ed Robinson"]
|
10
|
+
spec.email = ["ed@reevoo.com"]
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
12
|
+
spec.summary = "Input plugin to read from systemd journal."
|
13
|
+
spec.description = "This is a fluentd input plugin. It reads logs from the systemd journal."
|
14
|
+
spec.homepage = "https://github.com/assemblyline/fluent-plugin-systemd"
|
15
|
+
spec.license = "MIT"
|
16
16
|
|
17
17
|
|
18
|
-
spec.files =
|
19
|
-
spec.
|
20
|
-
spec.require_paths = ['lib']
|
18
|
+
spec.files = Dir["**/**"].reject { |f| f.match(/^(test|spec|features)\//) }
|
19
|
+
spec.require_paths = ["lib"]
|
21
20
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
25
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
23
|
+
spec.add_development_dependency "test-unit", "~> 2.5"
|
24
|
+
spec.add_development_dependency "reevoocop"
|
26
25
|
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
26
|
+
spec.add_runtime_dependency "fluentd", "~> 0.12"
|
27
|
+
spec.add_runtime_dependency "systemd-journal", "~> 1.2"
|
29
28
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "systemd/journal"
|
2
|
+
require "fluent/plugin/systemd/pos_writer"
|
3
3
|
|
4
4
|
module Fluent
|
5
5
|
class SystemdInput < Input
|
6
|
-
Fluent::Plugin.register_input(
|
6
|
+
Fluent::Plugin.register_input("systemd", self)
|
7
7
|
|
8
|
-
config_param :path, :string, default:
|
8
|
+
config_param :path, :string, default: "/var/log/journal"
|
9
9
|
config_param :filters, :array, default: []
|
10
10
|
config_param :pos_file, :string, default: nil
|
11
11
|
config_param :read_from_head, :bool, default: false
|
@@ -16,11 +16,11 @@ module Fluent
|
|
16
16
|
|
17
17
|
def configure(conf)
|
18
18
|
super
|
19
|
-
@pos_writer = PosWriter.new(conf[
|
19
|
+
@pos_writer = PosWriter.new(conf["pos_file"])
|
20
20
|
@journal = Systemd::Journal.new(path: path)
|
21
|
+
@read_from_head = conf["read_from_head"]
|
21
22
|
journal.filter(*filters)
|
22
|
-
|
23
|
-
journal.seek(read_from)
|
23
|
+
seek
|
24
24
|
end
|
25
25
|
|
26
26
|
def start
|
@@ -38,7 +38,18 @@ module Fluent
|
|
38
38
|
|
39
39
|
private
|
40
40
|
|
41
|
-
attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer, :strip_underscores
|
41
|
+
attr_reader :journal, :running, :lock, :cursor, :path, :pos_writer, :strip_underscores, :read_from_head
|
42
|
+
|
43
|
+
def seek
|
44
|
+
journal.seek(@pos_writer.cursor || read_from)
|
45
|
+
rescue Systemd::JournalError
|
46
|
+
log.warn("Could not seek to cursor #{@pos_writer.cursor} found in pos file: #{@pos_writer.path}")
|
47
|
+
journal.seek(read_from)
|
48
|
+
end
|
49
|
+
|
50
|
+
def read_from
|
51
|
+
read_from_head ? :head : :tail
|
52
|
+
end
|
42
53
|
|
43
54
|
def run
|
44
55
|
watch do |entry|
|
@@ -48,7 +59,7 @@ module Fluent
|
|
48
59
|
|
49
60
|
def formatted(entry)
|
50
61
|
return entry.to_h unless strip_underscores
|
51
|
-
Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/,
|
62
|
+
Hash[entry.to_h.map { |k, v| [k.gsub(/\A_+/, ""), v] }]
|
52
63
|
end
|
53
64
|
|
54
65
|
def watch
|
@@ -6,7 +6,7 @@ module Fluent
|
|
6
6
|
setup
|
7
7
|
end
|
8
8
|
|
9
|
-
attr_reader :cursor
|
9
|
+
attr_reader :cursor, :path
|
10
10
|
|
11
11
|
def start
|
12
12
|
return unless path
|
@@ -28,7 +28,7 @@ module Fluent
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
-
attr_reader :
|
31
|
+
attr_reader :lock, :thread, :running
|
32
32
|
|
33
33
|
def setup
|
34
34
|
return unless path
|
@@ -46,7 +46,7 @@ module Fluent
|
|
46
46
|
def write_pos
|
47
47
|
lock.synchronize do
|
48
48
|
if @written_cursor != cursor
|
49
|
-
file = File.open(path,
|
49
|
+
file = File.open(path, "w+")
|
50
50
|
file.print cursor
|
51
51
|
file.close
|
52
52
|
@written_cursor = cursor
|
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: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ed Robinson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.5'
|
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: '
|
54
|
+
version: '2.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: reevoocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -101,9 +101,6 @@ executables: []
|
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
103
103
|
files:
|
104
|
-
- ".gitignore"
|
105
|
-
- ".travis.yml"
|
106
|
-
- Dockerfile
|
107
104
|
- Gemfile
|
108
105
|
- LICENCE
|
109
106
|
- README.md
|
@@ -131,8 +128,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
128
|
version: '0'
|
132
129
|
requirements: []
|
133
130
|
rubyforge_project:
|
134
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.4.5.1
|
135
132
|
signing_key:
|
136
133
|
specification_version: 4
|
137
134
|
summary: Input plugin to read from systemd journal.
|
138
135
|
test_files: []
|
136
|
+
has_rdoc:
|
data/.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
Gemfile.lock
|
data/.travis.yml
DELETED
data/Dockerfile
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
FROM quay.io/assemblyline/buildpack_deps:15.10
|
2
|
-
|
3
|
-
RUN echo "deb http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu vivid main" | tee /etc/apt/sources.list.d/ruby-ng.list \
|
4
|
-
&& echo "deb-src http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu vivid main" | tee -a /etc/apt/sources.list.d/ruby-ng.list \
|
5
|
-
&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys C3173AA6 \
|
6
|
-
&& apt-get update -q && apt-get install -qy --no-install-recommends \
|
7
|
-
ruby2.2 \
|
8
|
-
ruby2.2-dev \
|
9
|
-
libsystemd-dev \
|
10
|
-
&& apt-get clean \
|
11
|
-
&& rm -rf /var/lib/apt/lists/* \
|
12
|
-
&& truncate -s 0 /var/log/*log \
|
13
|
-
&& gem install bundler
|
14
|
-
|
15
|
-
WORKDIR /usr/local/src
|
16
|
-
|
17
|
-
COPY Gemfile ./
|
18
|
-
COPY fluent-plugin-systemd.gemspec ./
|
19
|
-
RUN bundle install -j4 -r3
|
20
|
-
COPY . .
|
21
|
-
RUN bundle exec rake
|