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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 96ad0689fab60285dcec67ecf8af27c56491d6d6432df70615a4bf4e8a3b3772
4
- data.tar.gz: 2ac60436522d4d133cb89b9af6fe67cc443092257fba60ad104cd3a2e3f613c4
3
+ metadata.gz: a5ec89dff9f872d7371462dc0e39118ac9e0fa9d662fa5eecd4e99e9565f29d7
4
+ data.tar.gz: b598d411be65be2e16c9ce26d6d954cc63496085b714e66bc6274af6c42ef765
5
5
  SHA512:
6
- metadata.gz: e696333ac21b6b22cf62631eed79052ce05e0ec2febb69371c4827273124a4f7695becf05a9d9e843c33142ddf6518a8f4e69ff6e0c2bed51b42e8d00158ff1a
7
- data.tar.gz: 89b9e6fe0e6a3acacd8db5ca993085aad0c52e8720ea5748ad031e920b611da7e4b0b4ad0e1b52bb68025e51964cee8fd8a026ebf57343e35cc50705bb0657c1
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 URL'
20
- config :url, :validate => :string, :required => true
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 = loki_http_request(payload)
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 loki_http_request(payload)
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: @url)
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 client
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
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-edge_loki'
3
- s.version = '1.0.6'
3
+ s.version = '1.0.8'
4
4
  s.authors = ['Britto Prabhu']
5
5
  s.email = ['britto.prabhu@apmterminals.com']
6
6
 
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.6
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-03 00:00:00.000000000 Z
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