logstash-output-monasca_log_api 0.4 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +20 -16
- data/lib/logstash/outputs/keystone/keystone_client.rb +28 -23
- data/lib/logstash/outputs/keystone/token.rb +5 -5
- data/lib/logstash/outputs/monasca/monasca_log_api_client.rb +23 -23
- data/lib/logstash/outputs/monasca_log_api.rb +24 -9
- data/logstash-output-monasca_log_api.gemspec +2 -2
- data/spec/outputs/keystone/keystone_client_spec.rb +59 -40
- data/spec/outputs/monasca/monasca_log_api_client_spec.rb +84 -32
- data/spec/outputs/monasca_log_api_spec.rb +57 -23
- data/spec/outputs/spec_helper.rb +1 -4
- metadata +16 -19
- data/lib/logstash/outputs/helper/url_helper.rb +0 -29
- data/spec/outputs/helper/url_helper_spec.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 574bed4eaf7960e5e102494e439fe7433582f50e
|
4
|
+
data.tar.gz: 3be5356921f6b101be710c2a7eaa057dad41a219
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 847120ddd6fc6a12c87ef8e8828fdfeb54e32e34d458735df35aad317d85b16fe9bf4b5c45f44fa632b8b04dc15047d4497301d5d8741a9405221954f9afb217
|
7
|
+
data.tar.gz: e369ab34daa398a122bddc9e099ee2e1c782e2321f85441849ca5829c37aaf0af598de7007985bd990715e8c63206f4131759c680d972d9d4d5d8226fdbbefde
|
data/README.md
CHANGED
@@ -121,13 +121,15 @@ Save the configfile wherever you like. For example ~/logstash.conf
|
|
121
121
|
|
122
122
|
| name | description | type | required | default | example |
|
123
123
|
| --- | --- | --- | --- | --- | --- |
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
| monasca_log_api_url | monasca log api url | string | true | | https://192.168.10.4:5607/v3.0 |
|
125
|
+
| monasca_log_api_insecure | set to true if monasca-log-api is using an insecure ssl certificate | boolean | false | false | |
|
126
|
+
| keystone_api_url | keystone api url | string | true | | http://192.168.10.5:35357/v3 |
|
127
|
+
| keystone_api_insecure | set to true if keystone is using an insecure ssl certificate | boolean | false | false | |
|
127
128
|
| project_name | Keystone user credentials: project name | string | true | | monasca |
|
128
129
|
| username | Keystone user credentials: username | string | true | | admin-agent |
|
129
130
|
| password | Keystone user credentials: password | string | true | | password |
|
130
|
-
|
|
131
|
+
| user_domain_name | Keystone user credentials: user domain name | string | true | | default |
|
132
|
+
| project_domain_name | Keystone user credentials: project domain name | string | true | | default |
|
131
133
|
| dimensions | global array dimensions in form of key-value pairs to describe the monitored node | array | false | | ['app_type:kafka', 'priority:high'] |
|
132
134
|
| num_of_logs | maximum number of logs that are send by one request to monasca-log-api | number | false | 125 | |
|
133
135
|
| elapsed_time_sec | send logs if the maximum elapsed time in seconds is reached | number | false | 30 | |
|
@@ -140,12 +142,13 @@ Save the configfile wherever you like. For example ~/logstash.conf
|
|
140
142
|
```bash
|
141
143
|
output {
|
142
144
|
monasca_log_api {
|
143
|
-
|
144
|
-
|
145
|
+
monasca_log_api_url => "http://192.168.10.4:5607/v3.0"
|
146
|
+
keystone_api_url => "http://192.168.10.5:35357/v3"
|
145
147
|
project_name => "cmm"
|
148
|
+
project_domain_name => "Default"
|
146
149
|
username => "cmm-operator"
|
150
|
+
user_domain_name => "Default"
|
147
151
|
password => "admin"
|
148
|
-
domain_id => "default"
|
149
152
|
}
|
150
153
|
}
|
151
154
|
```
|
@@ -154,17 +157,19 @@ output {
|
|
154
157
|
```bash
|
155
158
|
output {
|
156
159
|
monasca_log_api {
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
+
monasca_log_api_url => "https://192.168.10.4:5607/v3.0"
|
161
|
+
monasca_log_api_insecure => true
|
162
|
+
keystone_api_url => "http://192.168.10.5:35357/v3"
|
163
|
+
keystone_api_insecure => false
|
160
164
|
project_name => "cmm"
|
165
|
+
project_domain_name => "Default"
|
161
166
|
username => "cmm-operator"
|
167
|
+
user_domain_name => "Default"
|
162
168
|
password => "admin"
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
elapsed_time_sec => 600
|
169
|
+
dimensions => ["hostname: monasca", "ip:192.168.10.4"]
|
170
|
+
num_of_logs => 125
|
171
|
+
delay => 10
|
172
|
+
elapsed_time_sec => 30
|
168
173
|
max_data_size_kb => 5120
|
169
174
|
}
|
170
175
|
}
|
@@ -206,4 +211,3 @@ input {
|
|
206
211
|
## Open tasks
|
207
212
|
* Language translations (Replace hardcoded String messages with a configuration/language file)
|
208
213
|
* Exception handling (monasca-api requests)
|
209
|
-
* https support
|
@@ -16,8 +16,9 @@
|
|
16
16
|
|
17
17
|
require 'logstash/environment'
|
18
18
|
require 'logger'
|
19
|
+
require 'json'
|
20
|
+
require 'net/http'
|
19
21
|
|
20
|
-
require_relative '../helper/url_helper'
|
21
22
|
require_relative './token'
|
22
23
|
|
23
24
|
# This class connects to keystone and authenticates an user.
|
@@ -28,39 +29,43 @@ module LogStash::Outputs
|
|
28
29
|
|
29
30
|
@client = nil
|
30
31
|
|
31
|
-
def initialize(
|
32
|
+
def initialize(url, insecure=false)
|
32
33
|
@logger = Cabin::Channel.get(LogStash)
|
33
|
-
@
|
34
|
+
@uri = URI.parse(url)
|
35
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
36
|
+
if @uri.scheme == 'https'
|
37
|
+
@http.use_ssl = true
|
38
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE if insecure
|
39
|
+
end
|
34
40
|
end
|
35
41
|
|
36
|
-
def authenticate(
|
37
|
-
auth_hash = generate_hash(
|
38
|
-
|
42
|
+
def authenticate(username, user_domain_name, password, project_name, project_domain_name)
|
43
|
+
auth_hash = generate_hash(username, user_domain_name, password, project_name, project_domain_name)
|
44
|
+
post_header = {
|
45
|
+
'Accept' => 'application/json',
|
46
|
+
'Content-Type' => 'application/json',
|
47
|
+
}
|
48
|
+
response = request('/auth/tokens', post_header, auth_hash)
|
39
49
|
handle_response(response)
|
40
50
|
end
|
41
51
|
|
42
52
|
private
|
43
53
|
|
44
|
-
def request(
|
45
|
-
@
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
def get_client(host, path)
|
52
|
-
RestClient::Resource.new(
|
53
|
-
LogStash::Outputs::Helper::UrlHelper.generate_url(host, path).to_s)
|
54
|
+
def request(path, header, body)
|
55
|
+
@logger.debug('Sending authentication to ', :url => @uri.to_s)
|
56
|
+
post_request = Net::HTTP::Post.new(@uri.request_uri + path, header)
|
57
|
+
post_request.body = body
|
58
|
+
@http.request(post_request)
|
54
59
|
end
|
55
60
|
|
56
|
-
def generate_hash(
|
61
|
+
def generate_hash(username, user_domain_name, password, project_name, project_domain_name)
|
57
62
|
{
|
58
63
|
"auth"=>{
|
59
64
|
"identity"=>{
|
60
65
|
"methods"=>["password"],
|
61
66
|
"password"=>{
|
62
67
|
"user"=>{
|
63
|
-
"domain"=>{"
|
68
|
+
"domain"=>{"name"=>user_domain_name},
|
64
69
|
"name"=>username,
|
65
70
|
"password"=>password
|
66
71
|
}
|
@@ -68,7 +73,7 @@ module LogStash::Outputs
|
|
68
73
|
},
|
69
74
|
"scope"=>{
|
70
75
|
"project"=>{
|
71
|
-
"domain"=>{"
|
76
|
+
"domain"=>{"name"=>project_domain_name},
|
72
77
|
"name"=>project_name
|
73
78
|
}
|
74
79
|
}
|
@@ -77,16 +82,16 @@ module LogStash::Outputs
|
|
77
82
|
end
|
78
83
|
|
79
84
|
def handle_response(response)
|
80
|
-
case response
|
81
|
-
when
|
85
|
+
case response
|
86
|
+
when Net::HTTPCreated
|
82
87
|
expires_at = DateTime.parse(
|
83
88
|
JSON.parse(response.body)["token"]["expires_at"])
|
84
89
|
|
85
90
|
@logger.debug("Authentication succeed: code=#{response.code}, "\
|
86
|
-
"auth-token=#{response
|
91
|
+
"auth-token=#{response['X-Subject-Token']}, "\
|
87
92
|
"expires_at=#{expires_at.to_time}")
|
88
93
|
|
89
|
-
{:token => response
|
94
|
+
{:token => response['X-Subject-Token'],
|
90
95
|
:expires_at => expires_at}
|
91
96
|
else
|
92
97
|
@logger.info("Authentication failed. Response=#{response}")
|
@@ -24,9 +24,9 @@ module LogStash::Outputs
|
|
24
24
|
include Singleton
|
25
25
|
attr_accessor :id, :expires_at, :keystone_client
|
26
26
|
|
27
|
-
def request_new_token(
|
27
|
+
def request_new_token(username, user_domain_name, password, project_name, project_domain_name)
|
28
28
|
token = @keystone_client
|
29
|
-
.authenticate(
|
29
|
+
.authenticate(username, user_domain_name, password, project_name, project_domain_name)
|
30
30
|
set_token(token[:token], token[:expires_at])
|
31
31
|
@logger.info("New token requested")
|
32
32
|
@logger.debug("token=#{@id}, expire_at=#{@expires_at}")
|
@@ -37,9 +37,9 @@ module LogStash::Outputs
|
|
37
37
|
@expires_at = expires_at
|
38
38
|
end
|
39
39
|
|
40
|
-
def set_keystone_client
|
40
|
+
def set_keystone_client(keystone_api, insecure)
|
41
41
|
@keystone_client = LogStash::Outputs::Keystone::KeystoneClient
|
42
|
-
.new
|
42
|
+
.new(keystone_api, insecure)
|
43
43
|
end
|
44
44
|
|
45
45
|
def initialize
|
@@ -57,4 +57,4 @@ module LogStash::Outputs
|
|
57
57
|
|
58
58
|
end
|
59
59
|
end
|
60
|
-
end
|
60
|
+
end
|
@@ -14,25 +14,23 @@
|
|
14
14
|
|
15
15
|
# encoding: utf-8
|
16
16
|
|
17
|
-
require 'rest-client'
|
18
17
|
require 'logger'
|
19
|
-
require '
|
20
|
-
|
21
|
-
# relative requirements
|
22
|
-
require_relative '../helper/url_helper'
|
18
|
+
require 'json'
|
19
|
+
require 'net/http'
|
23
20
|
|
24
21
|
# This class creates a connection to monasca-log-api
|
25
22
|
module LogStash::Outputs
|
26
23
|
module Monasca
|
27
24
|
class MonascaLogApiClient
|
28
25
|
|
29
|
-
|
30
|
-
|
31
|
-
def initialize(host, version)
|
26
|
+
def initialize(url, insecure=false)
|
32
27
|
@logger = Cabin::Channel.get(LogStash)
|
33
|
-
|
34
|
-
|
35
|
-
@
|
28
|
+
@uri = URI.parse(url)
|
29
|
+
@http = Net::HTTP.new(@uri.host, @uri.port)
|
30
|
+
if @uri.scheme == 'https'
|
31
|
+
@http.use_ssl = true
|
32
|
+
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE if insecure
|
33
|
+
end
|
36
34
|
end
|
37
35
|
|
38
36
|
def send_logs(logs, auth_token)
|
@@ -41,7 +39,8 @@ module LogStash::Outputs
|
|
41
39
|
'X-Auth-Token' => auth_token,
|
42
40
|
'Content-Type' => 'application/json',
|
43
41
|
}
|
44
|
-
request(logs
|
42
|
+
response = request('/logs', post_header, logs.to_json)
|
43
|
+
handle_response(response)
|
45
44
|
rescue => e
|
46
45
|
@logger.warn('Sending event to monasca-log-api threw exception',
|
47
46
|
:exceptionew => e)
|
@@ -50,20 +49,21 @@ module LogStash::Outputs
|
|
50
49
|
|
51
50
|
private
|
52
51
|
|
53
|
-
def request(
|
54
|
-
@logger.debug('Sending data to ', :url => @
|
55
|
-
@
|
52
|
+
def request(path, header, body)
|
53
|
+
@logger.debug('Sending data to ', :url => @uri.to_s)
|
54
|
+
post_request = Net::HTTP::Post.new(@uri.request_uri + path, header)
|
55
|
+
post_request.body = body
|
56
|
+
@http.request(post_request)
|
56
57
|
end
|
57
58
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
def handle_response(response)
|
60
|
+
case response
|
61
|
+
when Net::HTTPNoContent
|
62
|
+
@logger.debug("Successfully sent logs")
|
63
|
+
else
|
64
|
+
# TODO: Handle logs which could not be sent
|
65
|
+
@logger.error("Failed to send logs. Response=#{response}")
|
64
66
|
end
|
65
|
-
|
66
|
-
version
|
67
67
|
end
|
68
68
|
|
69
69
|
end
|
@@ -32,16 +32,19 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
32
32
|
config_name 'monasca_log_api'
|
33
33
|
|
34
34
|
# monasca-log-api configuration
|
35
|
-
config :
|
36
|
-
config :
|
37
|
-
:default =>
|
35
|
+
config :monasca_log_api_url, :validate => :string, :required => true
|
36
|
+
config :monasca_log_api_insecure, :validate => :boolean, :required => false,
|
37
|
+
:default => false
|
38
38
|
|
39
39
|
# keystone configuration
|
40
|
-
config :
|
40
|
+
config :keystone_api_url, :validate => :string, :required => true
|
41
|
+
config :keystone_api_insecure, :validate => :boolean, :required => false,
|
42
|
+
:default => false
|
41
43
|
config :project_name, :validate => :string, :required => true
|
42
44
|
config :username, :validate => :string, :required => true
|
43
45
|
config :password, :validate => :string, :required => true
|
44
|
-
config :
|
46
|
+
config :user_domain_name, :validate => :string, :required => true
|
47
|
+
config :project_domain_name, :validate => :string, :required => true
|
45
48
|
|
46
49
|
# global dimensions
|
47
50
|
config :dimensions, :validate => :array, :required => false
|
@@ -60,11 +63,12 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
60
63
|
|
61
64
|
public
|
62
65
|
def register
|
66
|
+
check_config
|
63
67
|
@mutex = Mutex.new
|
64
68
|
@logger.info('Registering keystone user',
|
65
69
|
:username => username, :project_name => project_name)
|
66
70
|
@monasca_log_api_client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
67
|
-
.new
|
71
|
+
.new monasca_log_api_url, monasca_log_api_insecure
|
68
72
|
@logs = Hash.new
|
69
73
|
@start_time = nil
|
70
74
|
init_token
|
@@ -87,13 +91,12 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
87
91
|
|
88
92
|
def init_token
|
89
93
|
token = LogStash::Outputs::Keystone::Token.instance
|
90
|
-
token.set_keystone_client(
|
94
|
+
token.set_keystone_client(keystone_api_url, keystone_api_insecure)
|
91
95
|
check_token
|
92
96
|
end
|
93
97
|
|
94
98
|
def encode(event)
|
95
99
|
log = generate_log_from_event(event)
|
96
|
-
|
97
100
|
log_bytesize = bytesize_of(log)
|
98
101
|
logs_bytesize = bytesize_of(@logs)
|
99
102
|
|
@@ -163,7 +166,8 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
163
166
|
def check_token
|
164
167
|
token = LogStash::Outputs::Keystone::Token.instance
|
165
168
|
token.request_new_token(
|
166
|
-
|
169
|
+
username, user_domain_name, password,
|
170
|
+
project_name, project_domain_name) unless token.valid?
|
167
171
|
end
|
168
172
|
|
169
173
|
def start_time_check
|
@@ -213,4 +217,15 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
213
217
|
end
|
214
218
|
end
|
215
219
|
|
220
|
+
def check_config
|
221
|
+
bad_val = []
|
222
|
+
bad_val << 'num_of_logs' if num_of_logs <= 0
|
223
|
+
bad_val << 'elapsed_time_sec' if elapsed_time_sec <= 0
|
224
|
+
bad_val << 'delay' if delay <= 0
|
225
|
+
bad_val << 'max_data_size_kb' if max_data_size_kb <= 0
|
226
|
+
unless bad_val.empty?
|
227
|
+
err = "Value of #{bad_val.join(', ')} need to be bigger than 0"
|
228
|
+
raise LogStash::ConfigurationError, err
|
229
|
+
end
|
230
|
+
end
|
216
231
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-monasca_log_api'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.5.1'
|
4
4
|
s.licenses = ['Apache License 2.0']
|
5
5
|
s.summary = 'This gem is a logstash output plugin to connect via http to monasca-log-api.'
|
6
6
|
s.description = 'This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program'
|
@@ -22,9 +22,9 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.add_runtime_dependency 'logstash-core', '~> 2.0'
|
23
23
|
s.add_runtime_dependency 'logstash-codec-plain', '~> 2.0'
|
24
24
|
s.add_runtime_dependency 'logstash-codec-json', '~> 2.0'
|
25
|
-
s.add_runtime_dependency 'rest-client', '~> 1.8'
|
26
25
|
s.add_runtime_dependency 'vine', '~> 0.2'
|
27
26
|
s.add_development_dependency 'logstash-devutils', '~> 0.0.14'
|
28
27
|
s.add_development_dependency 'simplecov', '~> 0.10'
|
29
28
|
s.add_development_dependency 'rubocop', '~> 0.37.2'
|
29
|
+
s.add_development_dependency 'webmock', '~> 2.0'
|
30
30
|
end
|
@@ -15,17 +15,22 @@
|
|
15
15
|
# encoding: utf-8
|
16
16
|
|
17
17
|
require_relative '../spec_helper'
|
18
|
+
require 'webmock/rspec'
|
18
19
|
|
19
20
|
describe LogStash::Outputs::Keystone::KeystoneClient do
|
20
21
|
|
22
|
+
let (:keystone_url) { 'http://keystone:5000/v3' }
|
23
|
+
let (:keystone_url_post) { keystone_url + '/auth/tokens' }
|
24
|
+
let (:keystone_url_https) { 'https://keystone:5000/v3' }
|
21
25
|
let (:valid_date) { DateTime.now + Rational(1, 1440) }
|
22
26
|
let (:token) { "f8cdafb7dce94444ad781a53ddaff693" }
|
23
|
-
let (:valid_token) { {
|
24
|
-
|
25
|
-
let (:domain_id) { "default" }
|
27
|
+
let (:valid_token) { {"token" => token,
|
28
|
+
"expires_at" => valid_date } }
|
26
29
|
let (:username) { "operator" }
|
30
|
+
let (:user_domain_name) { "Default" }
|
27
31
|
let (:password) { "zPrHGl<IJtn=ux;{&T/nfXh=H" }
|
28
32
|
let (:project_name) { "monasca" }
|
33
|
+
let (:project_domain_name) { "Default" }
|
29
34
|
let (:auth_hash) {
|
30
35
|
{
|
31
36
|
"auth"=>{
|
@@ -33,7 +38,7 @@ describe LogStash::Outputs::Keystone::KeystoneClient do
|
|
33
38
|
"methods"=>["password"],
|
34
39
|
"password"=>{
|
35
40
|
"user"=>{
|
36
|
-
"domain"=>{"
|
41
|
+
"domain"=>{"name"=>user_domain_name},
|
37
42
|
"name"=>username,
|
38
43
|
"password"=>password
|
39
44
|
}
|
@@ -41,7 +46,7 @@ describe LogStash::Outputs::Keystone::KeystoneClient do
|
|
41
46
|
},
|
42
47
|
"scope"=>{
|
43
48
|
"project"=>{
|
44
|
-
"domain"=>{"
|
49
|
+
"domain"=>{"name"=>project_domain_name},
|
45
50
|
"name"=>project_name
|
46
51
|
}
|
47
52
|
}
|
@@ -49,8 +54,7 @@ describe LogStash::Outputs::Keystone::KeystoneClient do
|
|
49
54
|
}.to_json
|
50
55
|
}
|
51
56
|
|
52
|
-
let (:
|
53
|
-
{:x_subject_token => token},
|
57
|
+
let (:ok_response_body) {
|
54
58
|
{
|
55
59
|
"token"=>{
|
56
60
|
"methods"=>["password"],
|
@@ -84,11 +88,10 @@ describe LogStash::Outputs::Keystone::KeystoneClient do
|
|
84
88
|
"audit_ids"=>["ORap7R56S2S-p6tFVeMkpg"],
|
85
89
|
"issued_at"=>"2015-05-26T07:55:36.774146Z"
|
86
90
|
}
|
87
|
-
}.to_json
|
91
|
+
}.to_json
|
88
92
|
}
|
89
93
|
|
90
|
-
let (:
|
91
|
-
{:x_subject_token => ""},
|
94
|
+
let (:failed_response_body) {
|
92
95
|
{
|
93
96
|
"error"=>{
|
94
97
|
"message"=>"Could not find project: f8cdafb7dce94444ad781a53ddaff693 "\
|
@@ -96,13 +99,13 @@ describe LogStash::Outputs::Keystone::KeystoneClient do
|
|
96
99
|
"code"=>401,
|
97
100
|
"title"=>"Unauthorized"
|
98
101
|
}
|
99
|
-
}.to_json
|
102
|
+
}.to_json
|
100
103
|
}
|
101
104
|
|
102
105
|
context 'when initializing' do
|
103
106
|
it 'then it should register without exceptions' do
|
104
|
-
expect {LogStash::Outputs::Keystone::KeystoneClient
|
105
|
-
.to_not raise_error
|
107
|
+
expect {LogStash::Outputs::Keystone::KeystoneClient
|
108
|
+
.new(keystone_url)}.to_not raise_error
|
106
109
|
end
|
107
110
|
|
108
111
|
it "returns a failure if arguments are missing" do
|
@@ -113,57 +116,73 @@ describe LogStash::Outputs::Keystone::KeystoneClient do
|
|
113
116
|
|
114
117
|
context 'when authenticates' do
|
115
118
|
it 'then it should request to keystone' do
|
116
|
-
expect_any_instance_of(
|
117
|
-
.with(
|
118
|
-
:accept => 'application/json').and_return(ok_response)
|
119
|
+
expect_any_instance_of(Net::HTTP).to receive(:request)
|
120
|
+
.with(an_instance_of(Net::HTTP::Post))
|
119
121
|
|
120
122
|
keystone_client = LogStash::Outputs::Keystone::KeystoneClient
|
121
|
-
.new(
|
122
|
-
keystone_client.authenticate(
|
123
|
+
.new(keystone_url)
|
124
|
+
keystone_client.authenticate(username, user_domain_name, password, project_name, project_domain_name)
|
123
125
|
end
|
124
126
|
|
125
127
|
it 'then it should return a token' do
|
126
|
-
|
127
|
-
|
128
|
+
|
129
|
+
stub_request(:post, keystone_url_post)
|
130
|
+
.to_return(:status => 201,
|
131
|
+
:body => ok_response_body,
|
132
|
+
:headers => { 'X-Subject-Token' => token })
|
133
|
+
|
128
134
|
keystone_client = LogStash::Outputs::Keystone::KeystoneClient
|
129
|
-
.new(
|
135
|
+
.new(keystone_url)
|
130
136
|
token = keystone_client
|
131
|
-
.authenticate(
|
132
|
-
|
133
|
-
expect(token[
|
137
|
+
.authenticate(username, user_domain_name, password, project_name, project_domain_name)
|
138
|
+
|
139
|
+
expect(token[:token]).to eq(valid_token["token"])
|
140
|
+
expect(token[:expires_at].to_s).to eq(valid_token["expires_at"].to_s)
|
134
141
|
end
|
135
142
|
end
|
136
143
|
|
137
144
|
context 'when authentication failed' do
|
138
145
|
it 'then it should log an information' do
|
139
|
-
expect_any_instance_of(RestClient::Resource).to receive(:post)
|
140
|
-
.and_return(failed_response)
|
141
146
|
expect_any_instance_of(Cabin::Channel).to receive(:info)
|
142
147
|
|
148
|
+
stub_request(:post, keystone_url_post)
|
149
|
+
.to_return(:status => 401,
|
150
|
+
:body => failed_response_body)
|
151
|
+
|
143
152
|
keystone_client = LogStash::Outputs::Keystone::KeystoneClient
|
144
|
-
.new(
|
145
|
-
keystone_client.authenticate(
|
153
|
+
.new(keystone_url)
|
154
|
+
keystone_client.authenticate(username, user_domain_name, password, project_name, project_domain_name)
|
146
155
|
end
|
147
156
|
|
148
157
|
it 'then it should return nil' do
|
149
|
-
expect_any_instance_of(RestClient::Resource).to receive(:post)
|
150
|
-
.and_return(failed_response)
|
151
158
|
expect_any_instance_of(Cabin::Channel).to receive(:info)
|
152
159
|
|
160
|
+
stub_request(:post, keystone_url_post)
|
161
|
+
.to_return(:status => 401,
|
162
|
+
:body => failed_response_body)
|
163
|
+
|
153
164
|
keystone_client = LogStash::Outputs::Keystone::KeystoneClient
|
154
|
-
.new(
|
165
|
+
.new(keystone_url)
|
155
166
|
expect(keystone_client
|
156
|
-
.authenticate(
|
167
|
+
.authenticate(username, user_domain_name, password, project_name, project_domain_name)).to eq(nil)
|
157
168
|
end
|
158
169
|
end
|
159
170
|
|
160
|
-
|
171
|
+
context 'when using https' do
|
172
|
+
it 'should change use_ssl property' do
|
173
|
+
client = LogStash::Outputs::Keystone::KeystoneClient
|
174
|
+
.new(keystone_url_https)
|
175
|
+
http = client.instance_variable_get(:@http)
|
176
|
+
expect(http.use_ssl?).to be true
|
177
|
+
expect(http.verify_mode).to eq(nil)
|
178
|
+
end
|
161
179
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
180
|
+
it 'in case of insecure mode it should change verify_mode property' do
|
181
|
+
client = LogStash::Outputs::Keystone::KeystoneClient
|
182
|
+
.new(keystone_url_https, true)
|
183
|
+
http = client.instance_variable_get(:@http)
|
184
|
+
expect(http.use_ssl?).to be true
|
185
|
+
expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
186
|
+
end
|
168
187
|
end
|
169
|
-
end
|
188
|
+
end
|
@@ -15,65 +15,117 @@
|
|
15
15
|
# encoding: utf-8
|
16
16
|
|
17
17
|
require_relative '../spec_helper'
|
18
|
+
require 'webmock/rspec'
|
18
19
|
|
19
20
|
describe LogStash::Outputs::Monasca::MonascaLogApiClient do
|
20
21
|
|
21
|
-
let (:
|
22
|
-
let (:
|
23
|
-
let (:
|
24
|
-
|
25
|
-
let (:logs) {
|
22
|
+
let (:monasca_log_api_url) { 'http://monasca-log-api:5607/v3.0' }
|
23
|
+
let (:monasca_log_api_url_https) { 'https://monasca-log-api:5607/v3.0' }
|
24
|
+
let (:monasca_log_api_url_post) { monasca_log_api_url + "/logs" }
|
25
|
+
let (:token) { "f8cdafb7dce94444ad781a53ddaff693" }
|
26
|
+
let (:logs) {
|
27
|
+
{
|
28
|
+
"dimensions" =>
|
29
|
+
{ "hostname" => "monasca",
|
30
|
+
"ip" => "192.168.10.4"
|
31
|
+
},
|
32
|
+
"logs" =>
|
33
|
+
[
|
34
|
+
{
|
35
|
+
"message" => "x-image-meta-min_disk: 0",
|
36
|
+
"dimensions" =>
|
37
|
+
{
|
38
|
+
"path" => "/var/log/monasca/log-api/info.log",
|
39
|
+
"service" => "monasca-log-api",
|
40
|
+
"language" => "python"
|
41
|
+
}
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
26
47
|
let (:header) { header = { 'X-Auth-Token' => token,
|
27
48
|
'Content-Type' => 'application/json' } }
|
28
49
|
|
29
|
-
before(:each) do
|
30
|
-
stub_const(
|
31
|
-
"LogStash::Outputs::Monasca::MonascaLogApiClient::SUPPORTED_API_VERSION",
|
32
|
-
[version])
|
33
|
-
end
|
34
|
-
|
35
50
|
context 'when initializing' do
|
36
51
|
it 'then it should register without exceptions' do
|
37
52
|
expect {LogStash::Outputs::Monasca::MonascaLogApiClient
|
38
|
-
.new(
|
53
|
+
.new(monasca_log_api_url)}.to_not raise_error
|
54
|
+
|
55
|
+
expect {LogStash::Outputs::Monasca::MonascaLogApiClient
|
56
|
+
.new(monasca_log_api_url, false)}.to_not raise_error
|
57
|
+
|
58
|
+
expect {LogStash::Outputs::Monasca::MonascaLogApiClient
|
59
|
+
.new(monasca_log_api_url, true)}.to_not raise_error
|
39
60
|
end
|
40
61
|
end
|
41
62
|
|
42
63
|
context 'when requesting to monasca-log-api' do
|
43
64
|
it 'sends x-auth-token and content-type in header, logs in body' do
|
65
|
+
expect_any_instance_of(Cabin::Channel).to_not receive(:error)
|
66
|
+
|
67
|
+
stub_request(:post, monasca_log_api_url_post)
|
68
|
+
.with(:headers => {
|
69
|
+
'Accept'=>'*/*',
|
70
|
+
'Content-Type'=>'application/json',
|
71
|
+
'User-Agent'=>'Ruby',
|
72
|
+
'X-Auth-Token'=>'f8cdafb7dce94444ad781a53ddaff693'})
|
73
|
+
.to_return(:status => 204)
|
74
|
+
|
44
75
|
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
45
|
-
.new(
|
46
|
-
|
47
|
-
.with(logs.to_json, header)
|
76
|
+
.new(monasca_log_api_url)
|
77
|
+
|
48
78
|
client.send_logs(logs, token)
|
49
79
|
end
|
50
80
|
end
|
51
81
|
|
82
|
+
context 'when using https' do
|
83
|
+
it 'should change use_ssl property' do
|
84
|
+
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
85
|
+
.new(monasca_log_api_url_https)
|
86
|
+
http = client.instance_variable_get(:@http)
|
87
|
+
expect(http.use_ssl?).to be true
|
88
|
+
expect(http.verify_mode).to eq(nil)
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'in case of insecure mode it should change verify_mode property' do
|
92
|
+
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
93
|
+
.new(monasca_log_api_url_https, true)
|
94
|
+
http = client.instance_variable_get(:@http)
|
95
|
+
expect(http.use_ssl?).to be true
|
96
|
+
expect(http.verify_mode).to eq(OpenSSL::SSL::VERIFY_NONE)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
52
100
|
context 'when request failed' do
|
53
|
-
it '
|
101
|
+
it 'logs a failure' do
|
102
|
+
expect_any_instance_of(Cabin::Channel).to receive(:error)
|
103
|
+
|
104
|
+
stub_request(:post, monasca_log_api_url_post)
|
105
|
+
.with(:headers => {
|
106
|
+
'Accept'=>'*/*',
|
107
|
+
'Content-Type'=>'application/json',
|
108
|
+
'User-Agent'=>'Ruby',
|
109
|
+
'X-Auth-Token'=>'f8cdafb7dce94444ad781a53ddaff693'})
|
110
|
+
.to_return(:status => 401)
|
111
|
+
|
54
112
|
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
55
|
-
.new(
|
56
|
-
|
57
|
-
expect_any_instance_of(RestClient::Resource).to receive(:post)
|
58
|
-
.and_raise(Errno::ECONNREFUSED)
|
113
|
+
.new(monasca_log_api_url)
|
114
|
+
|
59
115
|
client.send_logs(logs, token)
|
60
116
|
end
|
61
117
|
end
|
62
118
|
|
63
|
-
context '
|
64
|
-
it '
|
65
|
-
|
66
|
-
.new('hostname:8080', 'v3.0')}.to_not raise_error
|
67
|
-
end
|
119
|
+
context 'when request throws an exception' do
|
120
|
+
it 'rescued the exception and logs a failure' do
|
121
|
+
expect_any_instance_of(Cabin::Channel).to receive(:warn)
|
68
122
|
|
69
|
-
|
70
|
-
|
71
|
-
.new('hostname:8080', '3.0')}.to_not raise_error
|
72
|
-
end
|
123
|
+
stub_request(:post, monasca_log_api_url_post)
|
124
|
+
.to_raise(Errno::ECONNREFUSED)
|
73
125
|
|
74
|
-
|
75
|
-
|
76
|
-
|
126
|
+
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
127
|
+
.new(monasca_log_api_url)
|
128
|
+
client.send_logs(logs, token)
|
77
129
|
end
|
78
130
|
end
|
79
131
|
|
@@ -25,7 +25,7 @@ describe 'outputs/monasca_log_api' do
|
|
25
25
|
'@version' => '1',
|
26
26
|
'@timestamp' => '2015-08-13T08:37:00.287Z',
|
27
27
|
'path' => '/opt/logstash-2.2.0/test.log',
|
28
|
-
'host' => '
|
28
|
+
'host' => 'monasca',
|
29
29
|
'type' => 'test-type',
|
30
30
|
'tags' => ['test-service', 'high']
|
31
31
|
})
|
@@ -56,7 +56,7 @@ describe 'outputs/monasca_log_api' do
|
|
56
56
|
'@version' => '1',
|
57
57
|
'@timestamp' => '2015-08-13T08:37:00.287Z',
|
58
58
|
'path' => '/opt/logstash-2.2.0/test.log',
|
59
|
-
'host' => '
|
59
|
+
'host' => 'monasca',
|
60
60
|
'type' => 'test-type',
|
61
61
|
'dimensions' => '["[\"service\", \"nova\"]", "[\"priority\", \"high\"]"]',
|
62
62
|
'tags' => ['test-service', 'high']
|
@@ -69,7 +69,7 @@ describe 'outputs/monasca_log_api' do
|
|
69
69
|
'@version' => '1',
|
70
70
|
'@timestamp' => '2015-08-13T08:37:00.287Z',
|
71
71
|
'path' => '/opt/logstash-2.2.0/test.log',
|
72
|
-
'host' => '
|
72
|
+
'host' => 'monasca',
|
73
73
|
'type' => 'test-type',
|
74
74
|
'tags' => ['test-service', 'high']
|
75
75
|
})
|
@@ -81,7 +81,7 @@ describe 'outputs/monasca_log_api' do
|
|
81
81
|
'@version' => '1',
|
82
82
|
'@timestamp' => '2015-08-13T08:37:00.287Z',
|
83
83
|
'path' => '/opt/logstash-2.2.0/test.log',
|
84
|
-
'host' => '
|
84
|
+
'host' => 'monasca',
|
85
85
|
'type' => 'test-type',
|
86
86
|
'dimensions' => '["service", "nova"]',
|
87
87
|
'tags' => ['test-service', 'high']
|
@@ -94,7 +94,7 @@ describe 'outputs/monasca_log_api' do
|
|
94
94
|
'@version' => '1',
|
95
95
|
'@timestamp' => '2015-08-13T08:37:00.287Z',
|
96
96
|
'path' => '/opt/logstash-2.2.0/test.log',
|
97
|
-
'host' => '
|
97
|
+
'host' => 'monasca',
|
98
98
|
'type' => 'test-type',
|
99
99
|
'dimensions' => '["[\"service\", \"nova\"]", "[\"priority\", \"high\"]"]',
|
100
100
|
'tags' => ['test-service', 'high']
|
@@ -102,18 +102,25 @@ describe 'outputs/monasca_log_api' do
|
|
102
102
|
}
|
103
103
|
|
104
104
|
let (:project_name) { 'monasca' }
|
105
|
+
let (:project_domain_name) { 'Admin' }
|
105
106
|
let (:username) { 'operator' }
|
107
|
+
let (:user_domain_name) { 'Default' }
|
106
108
|
let (:password) { 'qweqwe' }
|
107
109
|
|
110
|
+
let (:monasca_log_api_url) { 'http://192.168.10.4:5607/v3.0' }
|
111
|
+
let (:keystone_api_url) { 'http://192.168.10.5:5000/v3' }
|
112
|
+
|
108
113
|
let (:complete_config) {
|
109
114
|
{
|
110
|
-
'
|
111
|
-
'
|
112
|
-
'
|
115
|
+
'monasca_log_api_url' => monasca_log_api_url,
|
116
|
+
'monasca_log_api_insecure' => false,
|
117
|
+
'keystone_api_url' => keystone_api_url,
|
118
|
+
'keystone_api_insecure' => false,
|
113
119
|
'project_name' => project_name,
|
120
|
+
'project_domain_name' => project_domain_name,
|
114
121
|
'username' => username,
|
122
|
+
'user_domain_name' => user_domain_name,
|
115
123
|
'password' => password,
|
116
|
-
'domain_id' => 'abadcf984cf7401e88579d393317b0d9',
|
117
124
|
'dimensions' => ['service:test'],
|
118
125
|
'num_of_logs' => 3,
|
119
126
|
'elapsed_time_sec' => 5000,
|
@@ -124,13 +131,15 @@ describe 'outputs/monasca_log_api' do
|
|
124
131
|
|
125
132
|
let (:complete_config_short_elapsed_time) {
|
126
133
|
{
|
127
|
-
'
|
128
|
-
'
|
129
|
-
'
|
134
|
+
'monasca_log_api_url' => monasca_log_api_url,
|
135
|
+
'monasca_log_api_insecure' => false,
|
136
|
+
'keystone_api_url' => keystone_api_url,
|
137
|
+
'keystone_api_insecure' => false,
|
130
138
|
'project_name' => project_name,
|
139
|
+
'project_domain_name' => project_domain_name,
|
131
140
|
'username' => username,
|
141
|
+
'user_domain_name' => user_domain_name,
|
132
142
|
'password' => password,
|
133
|
-
'domain_id' => 'abadcf984cf7401e88579d393317b0d9',
|
134
143
|
'dimensions' => ['service:test'],
|
135
144
|
'num_of_logs' => 3,
|
136
145
|
'elapsed_time_sec' => 1,
|
@@ -141,12 +150,29 @@ describe 'outputs/monasca_log_api' do
|
|
141
150
|
|
142
151
|
let (:simple_config) {
|
143
152
|
{
|
144
|
-
'
|
145
|
-
'
|
153
|
+
'monasca_log_api_url' => monasca_log_api_url,
|
154
|
+
'keystone_api_url' => keystone_api_url,
|
155
|
+
'project_name' => project_name,
|
156
|
+
'project_domain_name' => project_domain_name,
|
157
|
+
'username' => username,
|
158
|
+
'user_domain_name' => user_domain_name,
|
159
|
+
'password' => password,
|
160
|
+
}
|
161
|
+
}
|
162
|
+
|
163
|
+
let (:config_negative) {
|
164
|
+
{
|
165
|
+
'monasca_log_api_url' => monasca_log_api_url,
|
166
|
+
'keystone_api_url' => keystone_api_url,
|
146
167
|
'project_name' => project_name,
|
168
|
+
'project_domain_name' => project_domain_name,
|
147
169
|
'username' => username,
|
170
|
+
'user_domain_name' => user_domain_name,
|
148
171
|
'password' => password,
|
149
|
-
'
|
172
|
+
'num_of_logs' => rand(-999_999..-1),
|
173
|
+
'elapsed_time_sec' => rand(-999_999..-1),
|
174
|
+
'delay' => rand(-999_999..-1),
|
175
|
+
'max_data_size_kb' => rand(-999_999..-1),
|
150
176
|
}
|
151
177
|
}
|
152
178
|
|
@@ -179,8 +205,7 @@ describe 'outputs/monasca_log_api' do
|
|
179
205
|
monasca_log_api = LogStash::Plugin.lookup('output', 'monasca_log_api')
|
180
206
|
.new(simple_config)
|
181
207
|
|
182
|
-
expect(monasca_log_api.
|
183
|
-
expect(monasca_log_api.monasca_log_api_version).not_to be_empty
|
208
|
+
expect(monasca_log_api.monasca_log_api_insecure).to be_falsey
|
184
209
|
expect(monasca_log_api.dimensions).to be_nil
|
185
210
|
expect(monasca_log_api.num_of_logs).to be_instance_of(Fixnum)
|
186
211
|
expect(monasca_log_api.elapsed_time_sec).to be_instance_of(Fixnum)
|
@@ -192,8 +217,8 @@ describe 'outputs/monasca_log_api' do
|
|
192
217
|
monasca_log_api = LogStash::Plugin.lookup('output', 'monasca_log_api')
|
193
218
|
.new(complete_config)
|
194
219
|
|
195
|
-
expect(monasca_log_api.
|
196
|
-
.to eq(complete_config['
|
220
|
+
expect(monasca_log_api.monasca_log_api_insecure)
|
221
|
+
.to eq(complete_config['monasca_log_api_insecure'])
|
197
222
|
expect(monasca_log_api.dimensions).to eq(complete_config['dimensions'])
|
198
223
|
expect(monasca_log_api.num_of_logs).to eq(complete_config['num_of_logs'])
|
199
224
|
expect(monasca_log_api.elapsed_time_sec)
|
@@ -202,6 +227,14 @@ describe 'outputs/monasca_log_api' do
|
|
202
227
|
expect(monasca_log_api.max_data_size_kb)
|
203
228
|
.to eq(complete_config['max_data_size_kb'])
|
204
229
|
end
|
230
|
+
|
231
|
+
it 'with negative numbers in configuration, then raise error' do
|
232
|
+
monasca_log_api = LogStash::Plugin.lookup('output', 'monasca_log_api')
|
233
|
+
.new(config_negative)
|
234
|
+
|
235
|
+
expect { monasca_log_api.register }
|
236
|
+
.to raise_error(LogStash::ConfigurationError), config_negative.to_s
|
237
|
+
end
|
205
238
|
end
|
206
239
|
|
207
240
|
context 'when registering' do
|
@@ -406,10 +439,11 @@ describe 'outputs/monasca_log_api' do
|
|
406
439
|
expect_any_instance_of(LogStash::Outputs::Monasca::MonascaLogApiClient)
|
407
440
|
.to receive(:send_logs)
|
408
441
|
expect_any_instance_of(LogStash::Outputs::Keystone::KeystoneClient)
|
409
|
-
.to receive(:authenticate).with(complete_config['
|
410
|
-
complete_config['
|
442
|
+
.to receive(:authenticate).with(complete_config['username'],
|
443
|
+
complete_config['user_domain_name'],
|
411
444
|
complete_config['password'],
|
412
|
-
complete_config['project_name']
|
445
|
+
complete_config['project_name'],
|
446
|
+
complete_config['project_domain_name'])
|
413
447
|
.and_return(expired_token, valid_token)
|
414
448
|
monasca_log_api = LogStash::Outputs::MonascaLogApi.new(complete_config)
|
415
449
|
allow(monasca_log_api).to receive(:start_time_check)
|
data/spec/outputs/spec_helper.rb
CHANGED
@@ -13,6 +13,7 @@
|
|
13
13
|
# the License.
|
14
14
|
|
15
15
|
# encoding: utf-8
|
16
|
+
require 'yaml'
|
16
17
|
|
17
18
|
require 'simplecov'
|
18
19
|
SimpleCov.start do
|
@@ -26,7 +27,3 @@ require_relative '../../lib/logstash/outputs/monasca_log_api'
|
|
26
27
|
require_relative '../../lib/logstash/outputs/keystone/keystone_client'
|
27
28
|
require_relative '../../lib/logstash/outputs/keystone/token'
|
28
29
|
require_relative '../../lib/logstash/outputs/monasca/monasca_log_api_client'
|
29
|
-
require_relative '../../lib/logstash/outputs/helper/url_helper'
|
30
|
-
|
31
|
-
require 'yaml'
|
32
|
-
require 'rest-client'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-output-monasca_log_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fujitsu Enabling Software Technology GmbH
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -52,20 +52,6 @@ dependencies:
|
|
52
52
|
version: '2.0'
|
53
53
|
prerelease: false
|
54
54
|
type: :runtime
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rest-client
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ~>
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.8'
|
62
|
-
requirement: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - ~>
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.8'
|
67
|
-
prerelease: false
|
68
|
-
type: :runtime
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
56
|
name: vine
|
71
57
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -122,6 +108,20 @@ dependencies:
|
|
122
108
|
version: 0.37.2
|
123
109
|
prerelease: false
|
124
110
|
type: :development
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.0'
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ~>
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '2.0'
|
123
|
+
prerelease: false
|
124
|
+
type: :development
|
125
125
|
description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
|
126
126
|
email: kamil.choroba@est.fujitsu.com,tomasz.trebski@ts.fujitsu.com
|
127
127
|
executables: []
|
@@ -131,13 +131,11 @@ files:
|
|
131
131
|
- Gemfile
|
132
132
|
- LICENSE
|
133
133
|
- README.md
|
134
|
-
- lib/logstash/outputs/helper/url_helper.rb
|
135
134
|
- lib/logstash/outputs/keystone/keystone_client.rb
|
136
135
|
- lib/logstash/outputs/keystone/token.rb
|
137
136
|
- lib/logstash/outputs/monasca/monasca_log_api_client.rb
|
138
137
|
- lib/logstash/outputs/monasca_log_api.rb
|
139
138
|
- logstash-output-monasca_log_api.gemspec
|
140
|
-
- spec/outputs/helper/url_helper_spec.rb
|
141
139
|
- spec/outputs/keystone/keystone_client_spec.rb
|
142
140
|
- spec/outputs/keystone/token_spec.rb
|
143
141
|
- spec/outputs/monasca/monasca_log_api_client_spec.rb
|
@@ -170,7 +168,6 @@ signing_key:
|
|
170
168
|
specification_version: 4
|
171
169
|
summary: This gem is a logstash output plugin to connect via http to monasca-log-api.
|
172
170
|
test_files:
|
173
|
-
- spec/outputs/helper/url_helper_spec.rb
|
174
171
|
- spec/outputs/keystone/keystone_client_spec.rb
|
175
172
|
- spec/outputs/keystone/token_spec.rb
|
176
173
|
- spec/outputs/monasca/monasca_log_api_client_spec.rb
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# Copyright 2016 FUJITSU LIMITED
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
4
|
-
# use this file except in compliance with the License. You may obtain a copy of
|
5
|
-
# the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
12
|
-
# License for the specific language governing permissions and limitations under
|
13
|
-
# the License.
|
14
|
-
|
15
|
-
# encoding: utf-8
|
16
|
-
|
17
|
-
require 'uri'
|
18
|
-
|
19
|
-
module LogStash::Outputs
|
20
|
-
module Helper
|
21
|
-
class UrlHelper
|
22
|
-
def self.generate_url(host, path)
|
23
|
-
uri = URI.parse(host)
|
24
|
-
URI::HTTP.new(uri.scheme, nil, uri.host, uri.port, nil, path, nil,
|
25
|
-
nil, nil)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# Copyright 2016 FUJITSU LIMITED
|
2
|
-
#
|
3
|
-
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
4
|
-
# use this file except in compliance with the License. You may obtain a copy of
|
5
|
-
# the License at
|
6
|
-
#
|
7
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
#
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
11
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
12
|
-
# License for the specific language governing permissions and limitations under
|
13
|
-
# the License.
|
14
|
-
|
15
|
-
# encoding: utf-8
|
16
|
-
|
17
|
-
require_relative '../spec_helper'
|
18
|
-
|
19
|
-
describe LogStash::Outputs::Helper::UrlHelper do
|
20
|
-
|
21
|
-
describe ".generate_url" do
|
22
|
-
it "generates a URI::HTTP object" do
|
23
|
-
expect(LogStash::Outputs::Helper::UrlHelper
|
24
|
-
.generate_url('http://192.168.10.5:8080', '/v2.0')).to be_a URI::HTTP
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should match a http url" do
|
28
|
-
expect(LogStash::Outputs::Helper::UrlHelper
|
29
|
-
.generate_url('http://192.168.10.5:8080', '/v2.0').to_s)
|
30
|
-
.to eq('http://192.168.10.5:8080/v2.0')
|
31
|
-
expect(LogStash::Outputs::Helper::UrlHelper
|
32
|
-
.generate_url('http://est.fujitsu:40', nil).to_s)
|
33
|
-
.to eq('http://est.fujitsu:40')
|
34
|
-
expect(LogStash::Outputs::Helper::UrlHelper
|
35
|
-
.generate_url('http://est.fujitsu:80', nil).to_s)
|
36
|
-
.to eq('http://est.fujitsu')
|
37
|
-
expect(LogStash::Outputs::Helper::UrlHelper
|
38
|
-
.generate_url('https://192.168.10.5:8080', '/v2.0').to_s)
|
39
|
-
.to eq('https://192.168.10.5:8080/v2.0')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|