fluent-plugin-lm-logs 1.0.6 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fluent/plugin/out_lm.rb +31 -11
- data/lib/fluent/plugin/version.rb +1 -1
- 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: 19349cb3a0b92808dbf10c877ddefd7afae737fd2b643de6fb4c9b44b613dd08
|
4
|
+
data.tar.gz: 5cd7858230f353def6da39d4a3669ff236560149deb0a7ea32f344eb8d67430b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40af1f578e4307a26dce585dd5817f131fcc938cb8a16561441069960950e90a6f5db7abb5af79e091be39ed9f8eab273df33fcc64fc37a71d8d5830e2eabf79
|
7
|
+
data.tar.gz: b14b17c709c137a1b35b7043faa32bde3ede821036d22732de429757e5c70f187b82094069adeefd60a974923d4b1623ea4b0a6b6ce3e6a46b1e1e9d7f0cba4c
|
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
|
|
@@ -49,6 +49,9 @@ module Fluent
|
|
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.
|
@@ -60,6 +63,7 @@ module Fluent
|
|
60
63
|
# Open sockets or files here.
|
61
64
|
def start
|
62
65
|
super
|
66
|
+
configure_auth
|
63
67
|
proxy_uri = :ENV
|
64
68
|
if @http_proxy
|
65
69
|
proxy_uri = URI.parse(http_proxy)
|
@@ -73,6 +77,17 @@ module Fluent
|
|
73
77
|
@uri = URI.parse(@url)
|
74
78
|
end
|
75
79
|
|
80
|
+
def configure_auth
|
81
|
+
@use_bearer_instead_of_lmv1 = false
|
82
|
+
if @access_id == nil || @access_key == nil
|
83
|
+
log.info "Access Id or access key null. Using bearer token for authentication."
|
84
|
+
@use_bearer_instead_of_lmv1 = true
|
85
|
+
end
|
86
|
+
if @use_bearer_instead_of_lmv1 && @bearer_token == nil
|
87
|
+
log.error "Bearer token not specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor."
|
88
|
+
raise ArgumentError, 'No valid authentication specified. Either access_id and access_key both or bearer_token must be specified for authentication with Logicmonitor.'
|
89
|
+
end
|
90
|
+
end
|
76
91
|
# This method is called when shutting down.
|
77
92
|
# Shutdown the thread and close sockets or files here.
|
78
93
|
def shutdown
|
@@ -210,15 +225,20 @@ module Fluent
|
|
210
225
|
|
211
226
|
|
212
227
|
def generate_token(events)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
228
|
+
|
229
|
+
if @use_bearer_instead_of_lmv1
|
230
|
+
return "Bearer #{@bearer_token}"
|
231
|
+
else
|
232
|
+
timestamp = DateTime.now.strftime('%Q')
|
233
|
+
signature = Base64.strict_encode64(
|
234
|
+
OpenSSL::HMAC.hexdigest(
|
235
|
+
OpenSSL::Digest.new('sha256'),
|
236
|
+
@access_key,
|
237
|
+
"POST#{timestamp}#{events.to_json}/log/ingest"
|
238
|
+
)
|
239
|
+
)
|
240
|
+
return "LMv1 #{@access_id}:#{signature}:#{timestamp}"
|
241
|
+
end
|
222
242
|
end
|
223
243
|
end
|
224
244
|
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.1.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-06
|
11
|
+
date: 2023-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|