logstash-output-edge_loki 1.0.6 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/logstash/outputs/edge_loki.rb +32 -7
- data/logstash-output-edge_loki.gemspec +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: a5ec89dff9f872d7371462dc0e39118ac9e0fa9d662fa5eecd4e99e9565f29d7
|
4
|
+
data.tar.gz: b598d411be65be2e16c9ce26d6d954cc63496085b714e66bc6274af6c42ef765
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eef5ab0b6d08ab8968575e33cb60b88ecc6b45775df95c7abde04229bcc80577f394a976d4041bdd954772f598b67b94ce9da028c4f4ce32cd67a03bd5739da
|
7
|
+
data.tar.gz: b7f7529cc7d32de3e6c47a579f5db49595f2671d156660add48091ff4be26a83621ecb1196b3769854d7eae22ade1e0dbf4ad9bbd3008327a9c6fe83b0b6ee9f
|
@@ -15,9 +15,12 @@ class LogStash::Outputs::EDGE_Loki < LogStash::Outputs::Base
|
|
15
15
|
|
16
16
|
## 'A single instance of the Output will be shared among the pipeline worker threads'
|
17
17
|
concurrency :single
|
18
|
+
|
19
|
+
## 'Loki Domain'
|
20
|
+
config :domain, :validate => :string, :required => true
|
18
21
|
|
19
|
-
## 'Loki
|
20
|
-
config :
|
22
|
+
## 'Loki Endpoint'
|
23
|
+
config :endpoint, :validate => :string, :required => true
|
21
24
|
|
22
25
|
## 'BasicAuth credentials'
|
23
26
|
config :client_id, :validate => :string, :required => false
|
@@ -224,9 +227,10 @@ class LogStash::Outputs::EDGE_Loki < LogStash::Outputs::Base
|
|
224
227
|
|
225
228
|
def send(batch)
|
226
229
|
@logger.info("send: started method")
|
227
|
-
createClient()
|
230
|
+
token = createClient()
|
228
231
|
payload = batch.to_json
|
229
|
-
res =
|
232
|
+
res = pensive_http_request(token, payload)
|
233
|
+
@logger.info("send result: ", res => res)
|
230
234
|
if res.is_a?(Net::HTTPSuccess)
|
231
235
|
@logger.debug("Successfully pushed data to loki")
|
232
236
|
else
|
@@ -234,11 +238,24 @@ class LogStash::Outputs::EDGE_Loki < LogStash::Outputs::Base
|
|
234
238
|
end
|
235
239
|
end
|
236
240
|
|
237
|
-
def
|
241
|
+
def send1(batch)
|
242
|
+
@logger.info("send: started method")
|
243
|
+
token = createClient()
|
244
|
+
payload = batch.to_json
|
245
|
+
res = loki_http_request(token, payload)
|
246
|
+
if res.is_a?(Net::HTTPSuccess)
|
247
|
+
@logger.debug("Successfully pushed data to loki")
|
248
|
+
else
|
249
|
+
@logger.debug("failed payload", :payload => payload)
|
250
|
+
end
|
251
|
+
end
|
252
|
+
|
253
|
+
def loki_http_request(token, payload)
|
238
254
|
@logger.info("loki_http_request: started method")
|
239
255
|
req = Net::HTTP::Post.new(
|
240
256
|
@uri.request_uri
|
241
257
|
)
|
258
|
+
|
242
259
|
req.add_field('Content-Type', 'application/json')
|
243
260
|
req.add_field('X-Scope-OrgID', @tenant_id) if @tenant_id
|
244
261
|
req['User-Agent']= 'loki-logstash'
|
@@ -276,11 +293,19 @@ class LogStash::Outputs::EDGE_Loki < LogStash::Outputs::Base
|
|
276
293
|
|
277
294
|
def createClient
|
278
295
|
@logger.info("createClient: started method")
|
279
|
-
client = OAuth2::Client.new(@client_id, @client_secret, site: @
|
296
|
+
client = OAuth2::Client.new(@client_id, @client_secret, site: @domain + @endpoint)
|
280
297
|
client.auth_code.authorize_url(redirect_uri: @token_url)
|
298
|
+
token = client.auth_code.get_token(code, :redirect_uri => @token_url)
|
281
299
|
@logger.info("createClient: started method", :client => client)
|
282
|
-
return
|
300
|
+
return token
|
283
301
|
end
|
284
302
|
|
303
|
+
def pensive_http_request(token, payload)
|
304
|
+
@logger.info("pensive_http_request: started method")
|
305
|
+
response = token.get(@endpoint, :headers => { 'Accept' => 'application/json', 'X-Scope-OrgID', @tenant_id }, :params => { page: 1 })
|
306
|
+
hash = JSON.parse(response.body)
|
307
|
+
@logger.info("pensive_http_request: ", :token_output => hash)
|
308
|
+
return hash
|
309
|
+
end
|
285
310
|
end
|
286
311
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-edge_loki
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Britto Prabhu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|