fluent-plugin-lm-logs 1.0.6 → 1.2.0
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 +1 -0
- data/lib/fluent/plugin/out_lm.rb +44 -20
- data/lib/fluent/plugin/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9029af24ba774f88379606844f5faabf062c5bfe4df7f47386dccd72ceb62217
|
4
|
+
data.tar.gz: e2418db14714305e3cec4103255d9ee86a28b2abfdecceb35ec2976b0b78858d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f63f0f6a27956cbd08bc8272fcbaebd50f93fd2338b4f17ea9480f2ab35579b86078a8d422476e235dbf6c8e3e014c022158bca72ce6e621399f6d724db95ed0
|
7
|
+
data.tar.gz: 3abdc791dceb1d87407004537ad6f4ec1e40bf730aea9680f4124846d6eb506c9e14817a57a7da8c26af2b01894a9f8353489ad2d6ecfbf6297972f93a028f84
|
data/README.md
CHANGED
@@ -66,6 +66,7 @@ See the [LogicMonitor Helm repository](https://github.com/logicmonitor/k8s-helm-
|
|
66
66
|
| `resource_mapping` | The mapping that defines the source of the log event to the LM resource. In this case, the `<event_key>` in the incoming event is mapped to the value of `<lm_property>`.|
|
67
67
|
| `access_id` | LM API Token access ID. |
|
68
68
|
| `access_key` | LM API Token access key. |
|
69
|
+
| `bearer_token` | LM API Bearer Token. Either specify `access_id` and `access_key` both or `bearer_token`. If all specified, LMv1 token(`access_id` and `access_key`) will be used for authentication with Logicmonitor. |
|
69
70
|
| `flush_interval` | Defines the time in seconds to wait before sending batches of logs to LogicMonitor. Default is `60s`. |
|
70
71
|
| `debug` | When `true`, logs more information to the fluentd console. |
|
71
72
|
| `force_encoding` | Specify charset when logs contains invalid utf-8 characters. |
|
data/lib/fluent/plugin/out_lm.rb
CHANGED
@@ -25,9 +25,9 @@ module Fluent
|
|
25
25
|
|
26
26
|
# config_param defines a parameter. You can refer a parameter via @path instance variable
|
27
27
|
|
28
|
-
config_param :access_id, :string, :default =>
|
28
|
+
config_param :access_id, :string, :default => nil
|
29
29
|
|
30
|
-
config_param :access_key, :string, :default =>
|
30
|
+
config_param :access_key, :string, :default => nil, secret: true
|
31
31
|
|
32
32
|
config_param :company_name, :string, :default => "company_name"
|
33
33
|
|
@@ -36,7 +36,7 @@ module Fluent
|
|
36
36
|
config_param :debug, :bool, :default => false
|
37
37
|
|
38
38
|
config_param :include_metadata, :bool, :default => false
|
39
|
-
|
39
|
+
|
40
40
|
config_param :force_encoding, :string, :default => ""
|
41
41
|
|
42
42
|
config_param :compression, :string, :default => ""
|
@@ -48,7 +48,10 @@ module Fluent
|
|
48
48
|
config_param :device_less_logs, :bool, :default => false
|
49
49
|
|
50
50
|
config_param :http_proxy, :string, :default => nil
|
51
|
-
|
51
|
+
|
52
|
+
# Use bearer token for auth.
|
53
|
+
config_param :bearer_token, :string, :default => nil, secret: true
|
54
|
+
|
52
55
|
# This method is called before starting.
|
53
56
|
# 'conf' is a Hash that includes configuration parameters.
|
54
57
|
# If the configuration is invalid, raise Fluent::ConfigError.
|
@@ -56,10 +59,15 @@ module Fluent
|
|
56
59
|
super
|
57
60
|
end
|
58
61
|
|
62
|
+
def multi_workers_ready?
|
63
|
+
true
|
64
|
+
end
|
65
|
+
|
59
66
|
# This method is called when starting.
|
60
67
|
# Open sockets or files here.
|
61
68
|
def start
|
62
69
|
super
|
70
|
+
configure_auth
|
63
71
|
proxy_uri = :ENV
|
64
72
|
if @http_proxy
|
65
73
|
proxy_uri = URI.parse(http_proxy)
|
@@ -73,6 +81,17 @@ module Fluent
|
|
73
81
|
@uri = URI.parse(@url)
|
74
82
|
end
|
75
83
|
|
84
|
+
def configure_auth
|
85
|
+
@use_bearer_instead_of_lmv1 = false
|
86
|
+
if @access_id == nil || @access_key == nil
|
87
|
+
log.info "Access Id or access key null. Using bearer token for authentication."
|
88
|
+
@use_bearer_instead_of_lmv1 = true
|
89
|
+
end
|
90
|
+
if @use_bearer_instead_of_lmv1 && @bearer_token == nil
|
91
|
+
log.error "Bearer token not specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor."
|
92
|
+
raise ArgumentError, 'No valid authentication specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor.'
|
93
|
+
end
|
94
|
+
end
|
76
95
|
# This method is called when shutting down.
|
77
96
|
# Shutdown the thread and close sockets or files here.
|
78
97
|
def shutdown
|
@@ -135,7 +154,7 @@ module Fluent
|
|
135
154
|
else
|
136
155
|
lm_event[DEVICELESS_KEY_SERVICE] = encode_if_necessary(record[DEVICELESS_KEY_SERVICE])
|
137
156
|
if record[DEVICELESS_KEY_NAMESPACE]!=nil
|
138
|
-
lm_event[DEVICELESS_KEY_NAMESPACE] = encode_if_necessary(record[DEVICELESS_KEY_NAMESPACE])
|
157
|
+
lm_event[DEVICELESS_KEY_NAMESPACE] = encode_if_necessary(record[DEVICELESS_KEY_NAMESPACE])
|
139
158
|
end
|
140
159
|
end
|
141
160
|
end
|
@@ -152,13 +171,13 @@ module Fluent
|
|
152
171
|
end
|
153
172
|
|
154
173
|
def get_metadata(record)
|
155
|
-
#if encoding is not defined we will skip going through each key val
|
174
|
+
#if encoding is not defined we will skip going through each key val
|
156
175
|
#and return the whole record for performance reasons in case of a bulky record.
|
157
|
-
if @force_encoding == ""
|
176
|
+
if @force_encoding == ""
|
158
177
|
return record
|
159
178
|
else
|
160
179
|
lm_event = {}
|
161
|
-
record.each do |key, value|
|
180
|
+
record.each do |key, value|
|
162
181
|
lm_event["#{key}"] = get_encoded_string(value)
|
163
182
|
end
|
164
183
|
return lm_event
|
@@ -179,7 +198,7 @@ module Fluent
|
|
179
198
|
|
180
199
|
def send_batch(events)
|
181
200
|
body = events.to_json
|
182
|
-
|
201
|
+
|
183
202
|
if @debug
|
184
203
|
log.info "Sending #{events.length} events to logic monitor at #{@url}"
|
185
204
|
log.info "Request json #{body}"
|
@@ -203,22 +222,27 @@ module Fluent
|
|
203
222
|
end
|
204
223
|
|
205
224
|
resp = @http_client.request @uri, request
|
206
|
-
if @debug || resp.kind_of?(Net::HTTPMultiStatus) || !resp.kind_of?(Net::HTTPSuccess)
|
225
|
+
if @debug || resp.kind_of?(Net::HTTPMultiStatus) || !resp.kind_of?(Net::HTTPSuccess)
|
207
226
|
log.info "Status code:#{resp.code} Request Id:#{resp.header['x-request-id']} message:#{resp.body}"
|
208
227
|
end
|
209
228
|
end
|
210
229
|
|
211
230
|
|
212
231
|
def generate_token(events)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
232
|
+
|
233
|
+
if @use_bearer_instead_of_lmv1
|
234
|
+
return "Bearer #{@bearer_token}"
|
235
|
+
else
|
236
|
+
timestamp = DateTime.now.strftime('%Q')
|
237
|
+
signature = Base64.strict_encode64(
|
238
|
+
OpenSSL::HMAC.hexdigest(
|
239
|
+
OpenSSL::Digest.new('sha256'),
|
240
|
+
@access_key,
|
241
|
+
"POST#{timestamp}#{events.to_json}/log/ingest"
|
242
|
+
)
|
243
|
+
)
|
244
|
+
return "LMv1 #{@access_id}:#{signature}:#{timestamp}"
|
245
|
+
end
|
222
246
|
end
|
223
247
|
end
|
224
|
-
end
|
248
|
+
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LogicMonitor
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|