fluent-plugin-lm-logs 1.0.1 → 1.0.2
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/README.md +7 -2
- data/Rakefile +6 -0
- data/fluent-plugin-lm-logs.gemspec +1 -1
- data/lib/fluent/plugin/out_lm.rb +52 -20
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1c2298de6fe81e9eb49052ee49d55180193d254fee912339b9c8f6fad6c7aea1
|
|
4
|
+
data.tar.gz: 0a64fdb982ca4d8768175db534198b942d96fdcb22519913c5c077b7201bb6ea
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 95fe45b670b97925e672ecad76a724ed9eef24fd1e1685a131a4375ac7e662161aa5612ec34f3fc99e0f5817b24e7d640481b457bd466f2d2b3455f8e004e394
|
|
7
|
+
data.tar.gz: c69f47a5aad81cb1fbf778f14bc3238ee0271cb9530516a31120e46829aa7cf28336d509f9d6be2ddb155794ec9926896b2fc9738f524a30cf222f31013e322c
|
data/README.md
CHANGED
|
@@ -6,8 +6,8 @@ This output plugin sends Fluentd records to the configured LogicMonitor account.
|
|
|
6
6
|
## Prerequisites
|
|
7
7
|
|
|
8
8
|
Install the plugin:
|
|
9
|
-
* With gem: `gem install fluent-plugin-lm-logs`
|
|
10
|
-
* For
|
|
9
|
+
* With gem (if td-agent/fluentd is installed along with native ruby): `gem install fluent-plugin-lm-logs`
|
|
10
|
+
* For native td-agent/fluentd plugin handling: `td-agent-gem install fluent-plugin-lm-logs`
|
|
11
11
|
|
|
12
12
|
Alternatively, you can add `out_lm.rb` to your Fluentd plugins directory.
|
|
13
13
|
|
|
@@ -69,3 +69,8 @@ See the [LogicMonitor Helm repository](https://github.com/logicmonitor/k8s-helm-
|
|
|
69
69
|
| `flush_interval` | Defines the time in seconds to wait before sending batches of logs to LogicMonitor. Default is `60s`. |
|
|
70
70
|
| `debug` | When `true`, logs more information to the fluentd console. |
|
|
71
71
|
| `force_encoding` | Specify charset when logs contains invalid utf-8 characters. |
|
|
72
|
+
| `include_metadata` | When `true`, appends additional metadata to the log. default `false`. |
|
|
73
|
+
| `device_less_logs` | When `true`, do not map log with any resource. record must have `service` and `namespace` when `true`. default `false`. |
|
|
74
|
+
| `metadata_to_exclude` | `String array` of keys of metadata to exclude. default `empty` |
|
|
75
|
+
|
|
76
|
+
|
data/Rakefile
CHANGED
data/lib/fluent/plugin/out_lm.rb
CHANGED
|
@@ -26,6 +26,8 @@ module Fluent
|
|
|
26
26
|
config_param :resource_mapping, :hash, :default => {"host": "system.hostname", "hostname": "system.hostname"}
|
|
27
27
|
|
|
28
28
|
config_param :debug, :bool, :default => false
|
|
29
|
+
|
|
30
|
+
config_param :include_metadata, :bool, :default => false
|
|
29
31
|
|
|
30
32
|
config_param :force_encoding, :string, :default => ""
|
|
31
33
|
|
|
@@ -34,7 +36,11 @@ module Fluent
|
|
|
34
36
|
config_param :log_source, :string, :default => "lm-logs-fluentd"
|
|
35
37
|
|
|
36
38
|
config_param :version_id, :string, :default => "version_id"
|
|
37
|
-
|
|
39
|
+
|
|
40
|
+
config_param :device_less_logs, :bool, :default => false
|
|
41
|
+
|
|
42
|
+
config_param :metadata_to_exclude, :array, default: [], value_type: :string
|
|
43
|
+
|
|
38
44
|
# This method is called before starting.
|
|
39
45
|
# 'conf' is a Hash that includes configuration parameters.
|
|
40
46
|
# If the configuration is invalid, raise Fluent::ConfigError.
|
|
@@ -71,7 +77,9 @@ module Fluent
|
|
|
71
77
|
events = []
|
|
72
78
|
chunk.msgpack_each do |(tag, time, record)|
|
|
73
79
|
event = process_record(tag,time,record)
|
|
74
|
-
|
|
80
|
+
if event != nil
|
|
81
|
+
events.push(event)
|
|
82
|
+
end
|
|
75
83
|
end
|
|
76
84
|
send_batch(events)
|
|
77
85
|
end
|
|
@@ -79,24 +87,20 @@ module Fluent
|
|
|
79
87
|
def process_record(tag, time, record)
|
|
80
88
|
resource_map = {}
|
|
81
89
|
lm_event = {}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
nestedVal = record
|
|
92
|
-
key.to_s.split('.').each { |x| nestedVal = nestedVal[x] }
|
|
93
|
-
if nestedVal != nil
|
|
94
|
-
resource_map[k] = nestedVal
|
|
90
|
+
if !@device_less_logs
|
|
91
|
+
if record["_lm.resourceId"] == nil
|
|
92
|
+
@resource_mapping.each do |key, value|
|
|
93
|
+
k = value
|
|
94
|
+
nestedVal = record
|
|
95
|
+
key.to_s.split('.').each { |x| nestedVal = nestedVal[x] }
|
|
96
|
+
if nestedVal != nil
|
|
97
|
+
resource_map[k] = nestedVal
|
|
98
|
+
end
|
|
95
99
|
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
lm_event["_lm.resourceId"] = resource_map
|
|
101
|
+
else
|
|
102
|
+
lm_event["_lm.resourceId"] = record["_lm.resourceId"]
|
|
103
|
+
end
|
|
100
104
|
end
|
|
101
105
|
|
|
102
106
|
if record["timestamp"] != nil
|
|
@@ -105,6 +109,34 @@ module Fluent
|
|
|
105
109
|
lm_event["timestamp"] = Time.at(time).utc.to_datetime.rfc3339
|
|
106
110
|
end
|
|
107
111
|
|
|
112
|
+
if @include_metadata
|
|
113
|
+
record.each do |key, value|
|
|
114
|
+
case key
|
|
115
|
+
when *@metadata_to_exclude.concat(["timestamp","_lm.resourceId","log","message"])
|
|
116
|
+
else
|
|
117
|
+
lm_event["#{key}"] = value
|
|
118
|
+
|
|
119
|
+
if @force_encoding != ""
|
|
120
|
+
lm_event["#{key}"] = lm_event["#{key}"].force_encoding(@force_encoding).encode("UTF-8")
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
lm_event["message"] = record["message"]
|
|
126
|
+
|
|
127
|
+
if @force_encoding != ""
|
|
128
|
+
lm_event["message"] = lm_event["message"].force_encoding(@force_encoding).encode("UTF-8")
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
if @device_less_logs
|
|
132
|
+
if record["service"]==nil || record["namespace"] == nil
|
|
133
|
+
log.error "When device_less_logs is set \'true\', record must have \'service\' and \'namespace\'. Ignoring this event #{lm_event}."
|
|
134
|
+
return nil
|
|
135
|
+
else
|
|
136
|
+
lm_event["service"] = record["service"]
|
|
137
|
+
lm_event["namespace"] = record["namespace"]
|
|
138
|
+
end
|
|
139
|
+
end
|
|
108
140
|
return lm_event
|
|
109
141
|
end
|
|
110
142
|
|
|
@@ -159,4 +191,4 @@ module Fluent
|
|
|
159
191
|
"LMv1 #{@access_id}:#{signature}:#{timestamp}"
|
|
160
192
|
end
|
|
161
193
|
end
|
|
162
|
-
end
|
|
194
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-lm-logs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- LogicMonitor
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-03-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: fluentd
|
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
66
|
version: '0'
|
|
67
67
|
requirements: []
|
|
68
|
-
rubygems_version: 3.
|
|
68
|
+
rubygems_version: 3.3.7
|
|
69
69
|
signing_key:
|
|
70
70
|
specification_version: 4
|
|
71
71
|
summary: LogicMonitor logs fluentd output plugin
|