fluent-plugin-papertrail 0.1.2 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13f071d87f88a75ef2453e21eafd29feebff7b91
4
- data.tar.gz: 4abf3a957a68b902098a944577a1d2c3c5ec75ca
3
+ metadata.gz: 0c64afb4983305a88b12faeb066bedb5dd09c077
4
+ data.tar.gz: dd5f6d86951f19f121609a5fab36aac1b6a30658
5
5
  SHA512:
6
- metadata.gz: 9fcdbd9fd6d970117b86d27c6455019ce459da0a5315521e37c0f0ddf21d5d182f2f5cbbd8de785cefb44ac744a70d667432cc887cf54ad9859a0c647a401378
7
- data.tar.gz: 18dfa2b58cae05762579db20ddff31dbee6efc3b40f42797cdff7d5e9e41b42e4a98dca5a07c1b635f11b3b7d84ddbba929e10dae075c53dc16da595d7fd261f
6
+ metadata.gz: 991a840b6840f26e3812b95908905ce16e9151b3d1c1c15d0ca81a10079f2967324ee78614ca830db6d14211d0b48bd16cb54e365cb2ad809bf0df352506c679
7
+ data.tar.gz: '056480b9fb04bc1789745c5cc0481e21761e7e8651aad1b01946598dd6daa5194f73b3227349a5f70e98b061c145da14d2674f8d53abfde9965a9a060571a089'
data/README.md CHANGED
@@ -31,7 +31,9 @@ To configure this in fluentd:
31
31
  </match>
32
32
  ```
33
33
 
34
- Use a record transform plugin to populate within the record the following fields:
34
+ ### Configuring a record_transformer
35
+
36
+ This plugin expects the following fields to be set for each Fluent record:
35
37
  ```
36
38
  message The log
37
39
  program The program/tag
@@ -40,8 +42,7 @@ Use a record transform plugin to populate within the record the following fields
40
42
  hostname The source hostname for papertrail logging
41
43
  ```
42
44
 
43
- The following snippet sets up the records for Kubernetes and assumes you are using
44
- the [fluent-plugin-kubernetes_metadata_filter](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter) plugin which populates the record with useful metadata:
45
+ The following example is a `record_transformer` filter, from the [Kubernetes assets](docker/conf/kubernetes.conf) in this repo, that is used along with the [fluent-plugin-kubernetes_metadata_filter](https://github.com/fabric8io/fluent-plugin-kubernetes_metadata_filter) to populate the required fields for our plugin:
45
46
  ```yaml
46
47
  <filter kubernetes.**>
47
48
  type kubernetes_metadata
@@ -60,6 +61,8 @@ the [fluent-plugin-kubernetes_metadata_filter](https://github.com/fabric8io/flue
60
61
  </filter>
61
62
  ```
62
63
 
64
+ If you don't set `hostname` and `program` values in your record, they will default to the environment variable `FLUENT_HOSTNAME` or `'unidentified'` and the fluent tag, respectively.
65
+
63
66
  ### Advanced Configuration
64
67
  This plugin inherits a few useful config parameters from Fluent's `BufferedOutput` class.
65
68
 
@@ -90,6 +93,17 @@ kubectl apply -f kubernetes/fluentd-daemonset-papertrail.yaml
90
93
 
91
94
  The Dockerfile that generates [the image used in this DaemonSet](https://quay.io/repository/solarwinds/fluentd-kubernetes), can be found at `docker/Dockerfile`.
92
95
 
96
+ If you'd like to redirect Kubernetes API Server Audit logs to a seperate Papertrail destination, add the following to your `fluent.conf`:
97
+ ```
98
+ <match kube-apiserver-audit>
99
+ type papertrail
100
+ num_threads 4
101
+
102
+ papertrail_host "#{ENV['FLUENT_PAPERTRAIL_AUDIT_HOST']}"
103
+ papertrail_port "#{ENV['FLUENT_PAPERTRAIL_AUDIT_PORT']}"
104
+ </match>
105
+ ```
106
+
93
107
  ## Development
94
108
 
95
109
  This plugin is targeting Ruby 2.4 and Fluentd v1.0, although it should work with older versions of both.
@@ -113,7 +127,7 @@ To release a new version, update the version number in the [GemSpec](fluent-plug
113
127
 
114
128
  ## Contributing
115
129
 
116
- Bug reports and pull requests are welcome on GitHub at https://github.com/solarwinds/fluent-plugin-papertrail.
130
+ Bug reports and pull requests are welcome on GitHub at: https://github.com/solarwinds/fluent-plugin-papertrail
117
131
 
118
132
  ## License
119
133
 
data/docker/Dockerfile CHANGED
@@ -3,25 +3,23 @@ FROM fluent/fluentd:v1.1.1-debian
3
3
  USER root
4
4
  WORKDIR /home/fluent
5
5
  ENV PATH /home/fluent/.gem/ruby/2.3.0/bin:$PATH
6
+ ENV BUILDDEPS="sudo make gcc g++ libc-dev ruby-dev libffi-dev"
6
7
 
7
- RUN buildDeps="sudo make gcc g++ libc-dev ruby-dev libffi-dev" \
8
- && apt-get update \
9
- && apt-get upgrade -y \
10
- && apt-get install \
11
- -y --no-install-recommends \
12
- $buildDeps \
13
- && echo 'gem: --no-document' >> /etc/gemrc \
14
- && gem install fluent-plugin-secure-forward \
15
- && gem install fluent-plugin-record-reformer \
8
+ RUN apt-get update \
9
+ && apt-get upgrade -y \
10
+ && apt-get install -y --no-install-recommends \
11
+ $BUILDDEPS
12
+
13
+ RUN echo 'gem: --no-document' >> /etc/gemrc \
16
14
  && gem install fluent-plugin-systemd -v 0.3.1 \
17
15
  && gem install fluent-plugin-rewrite-tag-filter -v 1.6.0 \
18
- && gem install fluent-plugin-papertrail -v 0.1.2.pre.dev \
19
- && gem install fluent-plugin-kubernetes_metadata_filter \
20
- && gem install ffi \
21
- && SUDO_FORCE_REMOVE=yes \
16
+ && gem install fluent-plugin-papertrail -v 0.1.3 \
17
+ && gem install fluent-plugin-kubernetes_metadata_filter
18
+
19
+ RUN SUDO_FORCE_REMOVE=yes \
22
20
  apt-get purge -y --auto-remove \
23
21
  -o APT::AutoRemove::RecommendsImportant=false \
24
- $buildDeps \
22
+ $BUILDDEPS \
25
23
  && rm -rf /var/lib/apt/lists/* \
26
24
  && gem sources --clear-all \
27
25
  && rm -rf /tmp/* /var/tmp/* /usr/lib/ruby/gems/*/cache/*.gem
@@ -38,13 +36,8 @@ COPY plugins /fluentd/plugins/
38
36
  ENV FLUENTD_OPT=""
39
37
  ENV FLUENTD_CONF="fluent.conf"
40
38
 
41
- # jemalloc is memory optimization only available for td-agent
42
- # td-agent is provided and QA'ed by treasuredata as rpm/deb/.. package
43
- # -> td-agent (stable) vs fluentd (edge)
44
- #ENV LD_PRELOAD="/usr/lib/libjemalloc.so.2"
45
-
46
39
  # Overriding entrypoint, otherwise parent image causes to run as user fluent
47
40
  ENTRYPOINT []
48
41
 
49
42
  # Run Fluentd
50
- CMD exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT
43
+ CMD exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-papertrail"
7
- spec.version = "0.1.2"
7
+ spec.version = "0.1.3"
8
8
  spec.authors = ["Jonathan Lozinski", "Alex Ouzounis", "Chris Rust"]
9
9
  spec.email = ["jonathan.lozinski@solarwinds.com", "alex.ouzounis@solarwinds.com", "chris.rust@solarwinds.com"]
10
10
 
@@ -1,4 +1,3 @@
1
- # Uncomment sections below to allow audit logs to go to a separate host
2
1
  apiVersion: extensions/v1beta1
3
2
  kind: DaemonSet
4
3
  metadata:
@@ -23,17 +22,13 @@ spec:
23
22
  effect: NoSchedule
24
23
  containers:
25
24
  - name: fluentd
26
- image: quay.io/solarwinds/fluentd-kubernetes:v0.12.33-debian-papertrail
25
+ image: quay.io/solarwinds/fluentd-kubernetes:v1.1.1-debian-papertrail
27
26
  imagePullPolicy: Always
28
27
  env:
29
28
  - name: FLUENT_PAPERTRAIL_HOST
30
29
  value: 'logsN.papertrailapp.com'
31
30
  - name: FLUENT_PAPERTRAIL_PORT
32
31
  value: 'NNNNN'
33
- # - name: FLUENT_PAPERTRAIL_AUDIT_HOST
34
- # value: 'logsN.papertrailapp.com'
35
- # - name: FLUENT_PAPERTRAIL_AUDIT_PORT
36
- # value: 'NNNNN'
37
32
  - name: FLUENT_HOSTNAME
38
33
  value: 'my-cluster-name'
39
34
  resources:
@@ -77,16 +72,6 @@ data:
77
72
  @include kubernetes.conf
78
73
  @include systemd.conf
79
74
 
80
- # # Capture audit logs
81
- # <match kube-apiserver-audit>
82
- # type papertrail
83
- # num_threads 4
84
- #
85
- # papertrail_host "#{ENV['FLUENT_PAPERTRAIL_AUDIT_HOST']}"
86
- # papertrail_port "#{ENV['FLUENT_PAPERTRAIL_AUDIT_PORT']}"
87
- # </match>
88
- #
89
- # Capture all unmatched tags
90
75
  <match **>
91
76
  type papertrail
92
77
  num_threads 4
@@ -8,15 +8,19 @@ module Fluent
8
8
  # if left empty in fluent config these config_param's will error
9
9
  config_param :papertrail_host, :string
10
10
  config_param :papertrail_port, :integer
11
+ # default to ENV['FLUENT_HOSTNAME'] or :default_hostname if no hostname in record
12
+ config_param :default_hostname, :string, default: 'unidentified'
11
13
  # overriding default flush_interval (60 sec) from Fluent::BufferedOutput
12
14
  config_param :flush_interval, :time, default: 1
13
15
 
16
+
14
17
  # register as 'papertrail' fluent plugin
15
18
  Fluent::Plugin.register_output('papertrail', self)
16
19
 
17
20
  def configure(conf)
18
21
  super
19
22
  @socket = create_socket(@papertrail_host, @papertrail_port)
23
+ @default_hostname = ENV['FLUENT_HOSTNAME'] || @default_hostname
20
24
  end
21
25
 
22
26
  def format(tag, time, record)
@@ -50,10 +54,10 @@ module Fluent
50
54
  def create_packet(tag,time,record)
51
55
  # construct syslog packet from fluent record
52
56
  packet = SyslogProtocol::Packet.new
53
- packet.hostname = record['hostname']
54
- packet.facility = record['facility']
55
- packet.severity = record['severity']
56
- packet.tag = record['program']
57
+ packet.hostname = record['hostname'] || @default_hostname
58
+ packet.facility = record['facility'] || 'local0'
59
+ packet.severity = record['severity'] || 'info'
60
+ packet.tag = record['program'] || tag
57
61
  packet.content = record['message']
58
62
  packet.time = time ? Time.at(time) : Time.now
59
63
  packet
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-papertrail
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Lozinski
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2018-03-10 00:00:00.000000000 Z
13
+ date: 2018-03-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluentd
@@ -132,8 +132,6 @@ files:
132
132
  - Makefile
133
133
  - README.md
134
134
  - Rakefile
135
- - bin/console
136
- - bin/setup
137
135
  - docker/Dockerfile
138
136
  - docker/conf/fluent.conf
139
137
  - docker/conf/kubernetes.conf
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "fluent/plugin/papertrail"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here