fluent-plugin-insight 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 287cbbf3842b2af256f8ee95a49a7a6e182f2104
4
- data.tar.gz: ac0ff0277597bc853337c2e3ce67d4b916442844
3
+ metadata.gz: 42809ac213a6e323aac43cbd493b444ae4e8cfe8
4
+ data.tar.gz: 7469107f4c6746f4c696395298aee34aeccf0d09
5
5
  SHA512:
6
- metadata.gz: 55ec27d97d5b8a49a72e2679cfbead30b32f66411e9b7c39f8c38f2e64aaddc453d39e16cb387be4a6b729bbc7471ef6fed8405d0e08ae0a54f8243804343741
7
- data.tar.gz: dc1da043b1d38347fe060261bfab70f80dc83a9e58aeb7bb3bfe3446383a3ca8d70916d369a54392bcf6c4966dbb31a44280358324881160a1a01f1a4c99a28d
6
+ metadata.gz: 0ddb6c35492da2bd47b1d531a45037c02eed817ec2e7459f8a6d6bade98e3406b56a1d7eddc6274a1d9950c6974efcc999294473c7779707c8b3cd1457989e34
7
+ data.tar.gz: 5c1be0ee9a982f658e84d70513f82cb798a65469f173f4da65fcf3d16ec10c9386287317c60c982700e8b31260c31f550cbf5ad98b409e8c7719ab45049a4407
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-insight"
7
- spec.version = "0.0.2"
7
+ spec.version = "0.0.3"
8
8
  spec.authors = ["AndrewChubatiuk"]
9
9
  spec.email = ["ops@tweddle.com"]
10
10
  spec.summary = "InsightOPS output plugin for Fluent event collector"
@@ -22,6 +22,7 @@ class Fluent::InsightOutput < Fluent::BufferedOutput
22
22
  config_param :tags, :string, :default => ''
23
23
  config_param :prefix, :string, :default => ''
24
24
  config_param :default, :string, :default => 'default'
25
+ config_param :key, :string, :default => 'log'
25
26
  config_param :api_key
26
27
  config_param :logset_id
27
28
  config_param :region
@@ -37,7 +38,7 @@ class Fluent::InsightOutput < Fluent::BufferedOutput
37
38
  threads = []
38
39
  @tokens = Hash.new
39
40
  mutex = Mutex.new
40
- if logset_body.key?('logset')
41
+ if logset_body.instance_of?(Hash) and logset_body.key?('logset')
41
42
  logset_info = logset_body['logset']
42
43
  if logset_info.key?('logs_info')
43
44
  logs_info = logset_info['logs_info']
@@ -74,13 +75,13 @@ class Fluent::InsightOutput < Fluent::BufferedOutput
74
75
  if response.code == "200"
75
76
  return JSON.parse(response.body)
76
77
  end
77
- log.error "Request was failed HTTP #{response.code}: \n#{response.body}"
78
+ log.error "Request was failed HTTP #{response.code}: \n#{response.body}"
78
79
  end
79
80
 
80
81
  def insight_log_token(url)
81
82
  log_body = insight_rest_request(url)
82
- if log_body.key?('log')
83
- log_info = log_body['log']
83
+ if log_body.key?(@key)
84
+ log_info = log_body[@key]
84
85
  if log_info.key?('tokens')
85
86
  log.info "Found log #{log_info['name']}"
86
87
  return log_info['name'], log_info['tokens'][0]
@@ -124,8 +125,8 @@ class Fluent::InsightOutput < Fluent::BufferedOutput
124
125
  @insight_tags[k] = record[k]
125
126
  }
126
127
  symbolized_tags = @insight_tags.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
127
- if @tokens.key?(record['log'])
128
- token = @tokens[record['log']]
128
+ if @tokens.key?(record[@key])
129
+ token = @tokens[record[@key]]
129
130
  prefix = @prefix % symbolized_tags
130
131
  send_insight(token, "#{prefix} #{message}")
131
132
  elsif @tokens.key?(@default)
@@ -133,7 +134,7 @@ class Fluent::InsightOutput < Fluent::BufferedOutput
133
134
  prefix = @prefix % symbolized_tags
134
135
  send_insight(token, "#{prefix} #{message}")
135
136
  else
136
- log.debug "No token found for #{record['log']} and default log doesn't exist"
137
+ log.debug "No token found for #{record[@key]} and default log doesn't exist"
137
138
  end
138
139
  end
139
140
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-insight
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AndrewChubatiuk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-07 00:00:00.000000000 Z
11
+ date: 2019-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler