logstash-output-monasca_log_api 0.5.3 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +9 -0
- data/README.md +32 -16
- data/docs/index.asciidoc +179 -0
- data/lib/logstash/outputs/monasca/monasca_log_api_client.rb +12 -4
- data/lib/logstash/outputs/monasca_log_api.rb +47 -28
- data/logstash-output-monasca_log_api.gemspec +6 -4
- data/spec/outputs/monasca/monasca_log_api_client_spec.rb +26 -3
- data/spec/outputs/spec_helper.rb +3 -0
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 07b3468037fe7a8b0bc78971454e0731fd6ef707
|
4
|
+
data.tar.gz: 79dd7e9bcf0e8279687a7a2f87aba0dd7fbbd214
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c90a198dfe9592c870d5dfd65e9efb785febdcf2c883064d8d459ad52d610782a2901a4a0191aef743cc012a52343385877547c988e714a7e8d2275c92a6921
|
7
|
+
data.tar.gz: 9703a5aac084c490bac8d1457e839f5d831a22a335f9eb8b68e8ac005b02e9968142b94721cd9cdfe24a996ca6ae7722281d522469c1512de4c554fa36e3dc55
|
data/Gemfile
CHANGED
@@ -1,2 +1,11 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
+
|
2
3
|
gemspec
|
4
|
+
|
5
|
+
logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
|
6
|
+
use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
|
7
|
+
|
8
|
+
if Dir.exist?(logstash_path) && use_logstash_source
|
9
|
+
gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
|
10
|
+
gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
|
11
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# logstash-output-monasca_log_api
|
2
|
+
|
3
|
+
[![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-monasca_log_api.svg)](https://travis-ci.org/logstash-plugins/logstash-output-monasca_log_api)
|
4
|
+
|
2
5
|
This module is a logstash-output-plugin for the Monasca Log Api.
|
3
6
|
|
7
|
+
Compatible logstash version: [Logstash 2.3.4](https://download.elastic.co/logstash/logstash/logstash-2.3.4.tar.gz)
|
8
|
+
|
4
9
|
## Get latest stable version
|
5
10
|
https://rubygems.org/gems/logstash-output-monasca_log_api
|
6
11
|
|
@@ -31,23 +36,23 @@ source /home/vagrant/.rvm/scripts/rvm
|
|
31
36
|
rvm install jruby
|
32
37
|
```
|
33
38
|
|
34
|
-
|
39
|
+
#### Clone project
|
35
40
|
|
36
41
|
```bash
|
37
|
-
git clone https://github.com/
|
42
|
+
git clone https://github.com/logstash-plugins/logstash-output-monasca_log_api.git
|
38
43
|
```
|
39
44
|
|
40
|
-
|
45
|
+
#### Use jruby
|
41
46
|
```bash
|
42
47
|
rvm use jruby
|
43
48
|
```
|
44
49
|
|
45
|
-
|
50
|
+
#### Install bundler
|
46
51
|
```bash
|
47
52
|
gem install bundler
|
48
53
|
```
|
49
54
|
|
50
|
-
|
55
|
+
#### Fetch dependencies
|
51
56
|
```bash
|
52
57
|
bundle install
|
53
58
|
```
|
@@ -92,20 +97,12 @@ gem build logstash-output-monasca_log_api.gemspec
|
|
92
97
|
|
93
98
|
### Deploy Gemfile to logstash
|
94
99
|
|
95
|
-
* [Download logstash](https://download.elastic.co/logstash/logstash/logstash-2.
|
100
|
+
* [Download logstash](https://download.elastic.co/logstash/logstash/logstash-2.3.4.tar.gz) (>=2.3.4)
|
96
101
|
* Extract logstash and navigate into the folder
|
97
|
-
* Add this line to the Gemfile
|
98
|
-
|
99
|
-
```bash
|
100
|
-
gem "logstash-output-monasca_log_api", :path => "/vagrant_home/cloudmonitor/logstash-output-monasca_log_api"
|
101
|
-
```
|
102
|
-
|
103
|
-
* __logstash-output-monasca_log_api__ = name of the gem
|
104
|
-
* __/vagrant_home/cloudmonitor/logstash-output-monasca_log_api__ = Path to git workspace
|
105
102
|
|
106
103
|
Run this command from logstash folder to install the plugin
|
107
104
|
```bash
|
108
|
-
bin/plugin install
|
105
|
+
bin/logstash-plugin install /my/logstash/plugins/logstash-output-monasca_log_api-1.0.0.gem
|
109
106
|
```
|
110
107
|
|
111
108
|
Verify installed plugins:
|
@@ -208,6 +205,25 @@ input {
|
|
208
205
|
}
|
209
206
|
```
|
210
207
|
|
208
|
+
#### Cross tenant functionality
|
209
|
+
|
210
|
+
The output plugin is able to post data on behalf of another tenant to the monasca-log-api.
|
211
|
+
For example you can use a user of tenant X to send logs to the monasca-log-api for another tenant Y. The logs will be stored in the index of tenant Y.
|
212
|
+
|
213
|
+
To use this functionality you need to pass through another field called ```cross_tenant``` to each incoming event. This can be done by using the ```add_field``` for file [input plugin](https://www.elastic.co/guide/en/logstash/2.4/plugins-inputs-file.html). Example configuration:
|
214
|
+
|
215
|
+
```bash
|
216
|
+
input {
|
217
|
+
file {
|
218
|
+
add_field => { "dimensions" => { "service" => "neutron" "component" => "firewall" }}
|
219
|
+
add_field => { "cross_tenant" => "903ac629d8424dc39ae928a5fff338e7" }
|
220
|
+
path => "/var/log/neutron/firewall.log"
|
221
|
+
}
|
222
|
+
}
|
223
|
+
```
|
224
|
+
|
225
|
+
**Important:** The user which is sending the data on behalf of other tenants requires a specific role. This role is defined in the configuration file of the monasca-log-api as ```delegate_roles```.
|
226
|
+
|
211
227
|
## Open tasks
|
212
228
|
* Language translations (Replace hardcoded String messages with a configuration/language file)
|
213
229
|
* Exception handling (monasca-api requests)
|
data/docs/index.asciidoc
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
:plugin: monasca_log_api
|
2
|
+
:type: output
|
3
|
+
|
4
|
+
///////////////////////////////////////////
|
5
|
+
START - GENERATED VARIABLES, DO NOT EDIT!
|
6
|
+
///////////////////////////////////////////
|
7
|
+
:version: %VERSION%
|
8
|
+
:release_date: %RELEASE_DATE%
|
9
|
+
:changelog_url: %CHANGELOG_URL%
|
10
|
+
:include_path: ../../../../logstash/docs/include
|
11
|
+
///////////////////////////////////////////
|
12
|
+
END - GENERATED VARIABLES, DO NOT EDIT!
|
13
|
+
///////////////////////////////////////////
|
14
|
+
|
15
|
+
[id="plugins-{type}s-{plugin}"]
|
16
|
+
|
17
|
+
=== Monasca_log_api output plugin
|
18
|
+
|
19
|
+
include::{include_path}/plugin_header.asciidoc[]
|
20
|
+
|
21
|
+
==== Description
|
22
|
+
|
23
|
+
relative requirements
|
24
|
+
This Logstash Output plugin, sends events to monasca-api.
|
25
|
+
It authenticates against keystone and gets a token.
|
26
|
+
The token is used to authenticate against the monasca-api and send log events.
|
27
|
+
|
28
|
+
[id="plugins-{type}s-{plugin}-options"]
|
29
|
+
==== Monasca_log_api Output Configuration Options
|
30
|
+
|
31
|
+
This plugin supports the following configuration options plus the <<plugins-{type}s-{plugin}-common-options>> described later.
|
32
|
+
|
33
|
+
[cols="<,<,<",options="header",]
|
34
|
+
|=======================================================================
|
35
|
+
|Setting |Input type|Required
|
36
|
+
| <<plugins-{type}s-{plugin}-delay>> |<<number,number>>|No
|
37
|
+
| <<plugins-{type}s-{plugin}-dimensions>> |<<array,array>>|No
|
38
|
+
| <<plugins-{type}s-{plugin}-elapsed_time_sec>> |<<number,number>>|No
|
39
|
+
| <<plugins-{type}s-{plugin}-keystone_api_insecure>> |<<boolean,boolean>>|No
|
40
|
+
| <<plugins-{type}s-{plugin}-keystone_api_url>> |<<string,string>>|Yes
|
41
|
+
| <<plugins-{type}s-{plugin}-max_data_size_kb>> |<<number,number>>|No
|
42
|
+
| <<plugins-{type}s-{plugin}-monasca_log_api_insecure>> |<<boolean,boolean>>|No
|
43
|
+
| <<plugins-{type}s-{plugin}-monasca_log_api_url>> |<<string,string>>|Yes
|
44
|
+
| <<plugins-{type}s-{plugin}-num_of_logs>> |<<number,number>>|No
|
45
|
+
| <<plugins-{type}s-{plugin}-password>> |<<string,string>>|Yes
|
46
|
+
| <<plugins-{type}s-{plugin}-project_domain_name>> |<<string,string>>|Yes
|
47
|
+
| <<plugins-{type}s-{plugin}-project_name>> |<<string,string>>|Yes
|
48
|
+
| <<plugins-{type}s-{plugin}-user_domain_name>> |<<string,string>>|Yes
|
49
|
+
| <<plugins-{type}s-{plugin}-username>> |<<string,string>>|Yes
|
50
|
+
|=======================================================================
|
51
|
+
|
52
|
+
Also see <<plugins-{type}s-{plugin}-common-options>> for a list of options supported by all
|
53
|
+
output plugins.
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
[id="plugins-{type}s-{plugin}-delay"]
|
58
|
+
===== `delay`
|
59
|
+
|
60
|
+
* Value type is <<number,number>>
|
61
|
+
* Default value is `10`
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
[id="plugins-{type}s-{plugin}-dimensions"]
|
66
|
+
===== `dimensions`
|
67
|
+
|
68
|
+
* Value type is <<array,array>>
|
69
|
+
* There is no default value for this setting.
|
70
|
+
|
71
|
+
global dimensions
|
72
|
+
|
73
|
+
[id="plugins-{type}s-{plugin}-elapsed_time_sec"]
|
74
|
+
===== `elapsed_time_sec`
|
75
|
+
|
76
|
+
* Value type is <<number,number>>
|
77
|
+
* Default value is `30`
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
[id="plugins-{type}s-{plugin}-keystone_api_insecure"]
|
82
|
+
===== `keystone_api_insecure`
|
83
|
+
|
84
|
+
* Value type is <<boolean,boolean>>
|
85
|
+
* Default value is `false`
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
[id="plugins-{type}s-{plugin}-keystone_api_url"]
|
90
|
+
===== `keystone_api_url`
|
91
|
+
|
92
|
+
* This is a required setting.
|
93
|
+
* Value type is <<string,string>>
|
94
|
+
* There is no default value for this setting.
|
95
|
+
|
96
|
+
keystone configuration
|
97
|
+
|
98
|
+
[id="plugins-{type}s-{plugin}-max_data_size_kb"]
|
99
|
+
===== `max_data_size_kb`
|
100
|
+
|
101
|
+
* Value type is <<number,number>>
|
102
|
+
* Default value is `5120`
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
[id="plugins-{type}s-{plugin}-monasca_log_api_insecure"]
|
107
|
+
===== `monasca_log_api_insecure`
|
108
|
+
|
109
|
+
* Value type is <<boolean,boolean>>
|
110
|
+
* Default value is `false`
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
[id="plugins-{type}s-{plugin}-monasca_log_api_url"]
|
115
|
+
===== `monasca_log_api_url`
|
116
|
+
|
117
|
+
* This is a required setting.
|
118
|
+
* Value type is <<string,string>>
|
119
|
+
* There is no default value for this setting.
|
120
|
+
|
121
|
+
monasca-log-api configuration
|
122
|
+
|
123
|
+
[id="plugins-{type}s-{plugin}-num_of_logs"]
|
124
|
+
===== `num_of_logs`
|
125
|
+
|
126
|
+
* Value type is <<number,number>>
|
127
|
+
* Default value is `125`
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
[id="plugins-{type}s-{plugin}-password"]
|
132
|
+
===== `password`
|
133
|
+
|
134
|
+
* This is a required setting.
|
135
|
+
* Value type is <<string,string>>
|
136
|
+
* There is no default value for this setting.
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
[id="plugins-{type}s-{plugin}-project_domain_name"]
|
141
|
+
===== `project_domain_name`
|
142
|
+
|
143
|
+
* This is a required setting.
|
144
|
+
* Value type is <<string,string>>
|
145
|
+
* There is no default value for this setting.
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
[id="plugins-{type}s-{plugin}-project_name"]
|
150
|
+
===== `project_name`
|
151
|
+
|
152
|
+
* This is a required setting.
|
153
|
+
* Value type is <<string,string>>
|
154
|
+
* There is no default value for this setting.
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
[id="plugins-{type}s-{plugin}-user_domain_name"]
|
159
|
+
===== `user_domain_name`
|
160
|
+
|
161
|
+
* This is a required setting.
|
162
|
+
* Value type is <<string,string>>
|
163
|
+
* There is no default value for this setting.
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
[id="plugins-{type}s-{plugin}-username"]
|
168
|
+
===== `username`
|
169
|
+
|
170
|
+
* This is a required setting.
|
171
|
+
* Value type is <<string,string>>
|
172
|
+
* There is no default value for this setting.
|
173
|
+
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
[id="plugins-{type}s-{plugin}-common-options"]
|
179
|
+
include::{include_path}/{type}.asciidoc[]
|
@@ -33,20 +33,28 @@ module LogStash::Outputs
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
def send_logs(logs, auth_token)
|
36
|
+
def send_logs(logs, auth_token, cross_tenant)
|
37
37
|
post_header = {
|
38
38
|
'X-Auth-Token' => auth_token,
|
39
39
|
'Content-Type' => 'application/json',
|
40
40
|
}
|
41
|
-
|
41
|
+
params = Hash.new
|
42
|
+
if !cross_tenant.nil?
|
43
|
+
params[:tenant_id] = cross_tenant
|
44
|
+
end
|
45
|
+
response = request('/logs', post_header, logs.to_json, params)
|
42
46
|
handle_response(response)
|
43
47
|
end
|
44
48
|
|
45
49
|
private
|
46
50
|
|
47
|
-
def request(path, header, body)
|
51
|
+
def request(path, header, body, params)
|
48
52
|
@logger.debug('Sending data to ', :url => @uri.to_s)
|
49
|
-
|
53
|
+
uri = URI::HTTP.build( :path => @uri.path + path)
|
54
|
+
if !params.empty?
|
55
|
+
uri.query = URI.encode_www_form(params)
|
56
|
+
end
|
57
|
+
post_request = Net::HTTP::Post.new(uri.request_uri, header)
|
50
58
|
post_request.body = body
|
51
59
|
@http.request(post_request)
|
52
60
|
end
|
@@ -70,6 +70,7 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
70
70
|
.new monasca_log_api_url, monasca_log_api_insecure
|
71
71
|
@logs = Hash.new
|
72
72
|
@start_time = nil
|
73
|
+
@cross_tenant = nil
|
73
74
|
init_token
|
74
75
|
initialize_logs_object
|
75
76
|
start_time_check
|
@@ -95,46 +96,62 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
95
96
|
end
|
96
97
|
|
97
98
|
def encode(event)
|
98
|
-
log = generate_log_from_event(event)
|
99
|
+
log, cross_tenant = generate_log_from_event(event)
|
99
100
|
log_bytesize = bytesize_of(log)
|
100
101
|
logs_bytesize = bytesize_of(@logs)
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
@
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
103
|
+
if @logs[JSON_LOGS]
|
104
|
+
# if new cross_tenant appears request has to be sent
|
105
|
+
if @cross_tenant != cross_tenant
|
106
|
+
@logger.debug('new cross_tenant. Sending logs.')
|
107
|
+
@mutex.synchronize do
|
108
|
+
send_logs
|
109
|
+
add_log log, cross_tenant
|
110
|
+
end
|
111
|
+
return
|
112
|
+
|
113
|
+
# if new log would exceed the bytesize then send logs without the new log
|
114
|
+
elsif (logs_bytesize + log_bytesize) > max_data_size_kb
|
115
|
+
@logger.debug('bytesize reached. Sending logs')
|
116
|
+
@mutex.synchronize do
|
117
|
+
send_logs
|
118
|
+
add_log log, cross_tenant
|
119
|
+
end
|
120
|
+
return
|
121
|
+
|
122
|
+
# if the new log would reach the maximum bytesize or the maximum allowed
|
123
|
+
# number of sendable logs is reached
|
124
|
+
elsif (@logs[JSON_LOGS].size + 1 >= num_of_logs)
|
125
|
+
@logger.debug('bytesize or maximum number of logs reached. Sending logs')
|
126
|
+
@mutex.synchronize do
|
127
|
+
add_log log, cross_tenant
|
128
|
+
send_logs
|
129
|
+
end
|
130
|
+
return
|
118
131
|
end
|
119
|
-
|
132
|
+
end
|
120
133
|
|
121
134
|
# still free space to collect logs
|
122
|
-
|
123
|
-
|
124
|
-
add_log log
|
125
|
-
end
|
126
|
-
return
|
135
|
+
@mutex.synchronize do
|
136
|
+
add_log log, cross_tenant
|
127
137
|
end
|
138
|
+
return
|
128
139
|
end
|
129
140
|
|
130
141
|
def generate_log_from_event(event)
|
131
142
|
message = event.to_hash['message']
|
132
|
-
path = event.to_hash['path']
|
143
|
+
path = event.to_hash['path'] if event.to_hash['path']
|
144
|
+
stream = event.to_hash['stream'] if event.to_hash['stream']
|
133
145
|
local_dims = JSON.parse(event.to_hash['dimensions'].to_s) if
|
134
146
|
event.to_hash['dimensions']
|
135
147
|
type = event.to_hash['type'] if event.to_hash['type']
|
148
|
+
cross_tenant = event.to_hash['cross_tenant'] if
|
149
|
+
event.to_hash['cross_tenant']
|
150
|
+
|
151
|
+
log = { 'message' => message, 'dimensions' => {} }
|
152
|
+
path && log['dimensions']['path'] = path
|
153
|
+
stream && log['dimensions']['stream'] = stream
|
136
154
|
|
137
|
-
log = { 'message' => message, 'dimensions' => { 'path' => path }}
|
138
155
|
log[JSON_DIMS]['type'] = type if type
|
139
156
|
if local_dims
|
140
157
|
begin
|
@@ -147,7 +164,7 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
147
164
|
log[JSON_DIMS][local_dims[0].strip] = local_dims[1].strip
|
148
165
|
end
|
149
166
|
end
|
150
|
-
log
|
167
|
+
return log, cross_tenant
|
151
168
|
end
|
152
169
|
|
153
170
|
def initialize_logs_object
|
@@ -159,6 +176,7 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
159
176
|
@logs = {}
|
160
177
|
@logs[JSON_DIMS] = global_dims unless global_dims.empty?
|
161
178
|
@logs[JSON_LOGS] = []
|
179
|
+
@cross_tenant = nil
|
162
180
|
end
|
163
181
|
end
|
164
182
|
|
@@ -206,7 +224,7 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
206
224
|
retry_tries = 5
|
207
225
|
begin
|
208
226
|
tries ||= retry_tries
|
209
|
-
@monasca_log_api_client.send_logs(@logs, token.id)
|
227
|
+
@monasca_log_api_client.send_logs(@logs, token.id, @cross_tenant)
|
210
228
|
rescue LogStash::Outputs::Monasca::MonascaLogApiClient::InvalidTokenError => e
|
211
229
|
tries -= 1
|
212
230
|
if tries > 0
|
@@ -229,11 +247,12 @@ class LogStash::Outputs::MonascaLogApi < LogStash::Outputs::Base
|
|
229
247
|
end
|
230
248
|
end
|
231
249
|
|
232
|
-
def add_log(log)
|
250
|
+
def add_log(log, cross_tenant)
|
233
251
|
@logs[JSON_LOGS].push(log)
|
234
252
|
if @logs[JSON_LOGS].size == 1
|
235
253
|
@start_time = Time.now
|
236
254
|
end
|
255
|
+
@cross_tenant = cross_tenant
|
237
256
|
end
|
238
257
|
|
239
258
|
def check_config
|
@@ -1,16 +1,16 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'logstash-output-monasca_log_api'
|
3
|
-
s.version
|
3
|
+
s.version = '1.0.2'
|
4
4
|
s.licenses = ['Apache-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'
|
7
7
|
s.authors = ['Fujitsu Enabling Software Technology GmbH']
|
8
|
-
s.email = 'kamil.choroba@est.fujitsu.com,
|
8
|
+
s.email = 'kamil.choroba@est.fujitsu.com,witold.bedyk@est.fujitsu.com'
|
9
9
|
s.require_paths = ['lib']
|
10
|
-
s.homepage = 'https://github.com/
|
10
|
+
s.homepage = 'https://github.com/logstash-plugins/logstash-output-monasca_log_api'
|
11
11
|
|
12
12
|
# Files
|
13
|
-
s.files = Dir["lib/**/*",
|
13
|
+
s.files = Dir["lib/**/*","spec/**/*","*.gemspec","*.md","CONTRIBUTORS","Gemfile","LICENSE","NOTICE.TXT", "vendor/jar-dependencies/**/*.jar", "vendor/jar-dependencies/**/*.rb", "VERSION", "docs/**/*"]
|
14
14
|
|
15
15
|
# Tests
|
16
16
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
@@ -24,6 +24,8 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.add_runtime_dependency 'logstash-codec-json', '~> 2.0'
|
25
25
|
s.add_development_dependency 'logstash-devutils', '~> 0.0.14'
|
26
26
|
s.add_development_dependency 'simplecov', '~> 0.10'
|
27
|
+
s.add_development_dependency 'simplecov-rcov', '~> 0.2.0'
|
28
|
+
s.add_development_dependency 'rspec_junit_formatter', '~> 0.2.3'
|
27
29
|
s.add_development_dependency 'rubocop', '~> 0.37.2'
|
28
30
|
s.add_development_dependency 'webmock', '~> 2.0'
|
29
31
|
end
|
@@ -23,6 +23,9 @@ describe LogStash::Outputs::Monasca::MonascaLogApiClient do
|
|
23
23
|
let (:monasca_log_api_url_https) { 'https://monasca-log-api:5607/v3.0' }
|
24
24
|
let (:monasca_log_api_url_post) { monasca_log_api_url + "/logs" }
|
25
25
|
let (:token) { "f8cdafb7dce94444ad781a53ddaff693" }
|
26
|
+
let (:cross_tenant) { "396ffadd35a187da44449ecd7bfadc8f" }
|
27
|
+
let (:monasca_log_api_url_post_with_tenant) { monasca_log_api_url_post +
|
28
|
+
"?tenant_id=" + cross_tenant}
|
26
29
|
let (:logs) {
|
27
30
|
{
|
28
31
|
"dimensions" =>
|
@@ -75,7 +78,27 @@ describe LogStash::Outputs::Monasca::MonascaLogApiClient do
|
|
75
78
|
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
76
79
|
.new(monasca_log_api_url)
|
77
80
|
|
78
|
-
client.send_logs(logs, token)
|
81
|
+
client.send_logs(logs, token, nil)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'when requesting to monasca-log-api with cross_tenant' do
|
86
|
+
it 'sends x-auth-token and content-type in header, logs in body,'\
|
87
|
+
' and tenant_id in query parameter' do
|
88
|
+
expect_any_instance_of(Cabin::Channel).to_not receive(:error)
|
89
|
+
|
90
|
+
stub_request(:post, monasca_log_api_url_post_with_tenant)
|
91
|
+
.with(:headers => {
|
92
|
+
'Accept'=>'*/*',
|
93
|
+
'Content-Type'=>'application/json',
|
94
|
+
'User-Agent'=>'Ruby',
|
95
|
+
'X-Auth-Token'=>'f8cdafb7dce94444ad781a53ddaff693'})
|
96
|
+
.to_return(:status => 204)
|
97
|
+
|
98
|
+
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
99
|
+
.new(monasca_log_api_url)
|
100
|
+
|
101
|
+
client.send_logs(logs, token, cross_tenant)
|
79
102
|
end
|
80
103
|
end
|
81
104
|
|
@@ -114,7 +137,7 @@ describe LogStash::Outputs::Monasca::MonascaLogApiClient do
|
|
114
137
|
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
115
138
|
.new(monasca_log_api_url)
|
116
139
|
|
117
|
-
client.send_logs(logs, token)
|
140
|
+
client.send_logs(logs, token, nil)
|
118
141
|
end
|
119
142
|
end
|
120
143
|
|
@@ -135,7 +158,7 @@ describe LogStash::Outputs::Monasca::MonascaLogApiClient do
|
|
135
158
|
client = LogStash::Outputs::Monasca::MonascaLogApiClient
|
136
159
|
.new(monasca_log_api_url)
|
137
160
|
|
138
|
-
expect { client.send_logs(logs, token) }.to raise_error(
|
161
|
+
expect { client.send_logs(logs, token, nil) }.to raise_error(
|
139
162
|
LogStash::Outputs::Monasca::MonascaLogApiClient::InvalidTokenError
|
140
163
|
)
|
141
164
|
end
|
data/spec/outputs/spec_helper.rb
CHANGED
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: 0.
|
4
|
+
version: 1.0.2
|
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:
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logstash-core
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
version: '0.10'
|
81
81
|
prerelease: false
|
82
82
|
type: :development
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov-rcov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.2.0
|
90
|
+
version_requirements: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - "~>"
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.2.0
|
95
|
+
prerelease: false
|
96
|
+
type: :development
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec_junit_formatter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.2.3
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: 0.2.3
|
109
|
+
prerelease: false
|
110
|
+
type: :development
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: rubocop
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,7 +137,7 @@ dependencies:
|
|
109
137
|
prerelease: false
|
110
138
|
type: :development
|
111
139
|
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
|
112
|
-
email: kamil.choroba@est.fujitsu.com,
|
140
|
+
email: kamil.choroba@est.fujitsu.com,witold.bedyk@est.fujitsu.com
|
113
141
|
executables: []
|
114
142
|
extensions: []
|
115
143
|
extra_rdoc_files: []
|
@@ -117,6 +145,7 @@ files:
|
|
117
145
|
- Gemfile
|
118
146
|
- LICENSE
|
119
147
|
- README.md
|
148
|
+
- docs/index.asciidoc
|
120
149
|
- lib/logstash/outputs/keystone/keystone_client.rb
|
121
150
|
- lib/logstash/outputs/keystone/token.rb
|
122
151
|
- lib/logstash/outputs/monasca/monasca_log_api_client.rb
|
@@ -127,7 +156,7 @@ files:
|
|
127
156
|
- spec/outputs/monasca/monasca_log_api_client_spec.rb
|
128
157
|
- spec/outputs/monasca_log_api_spec.rb
|
129
158
|
- spec/outputs/spec_helper.rb
|
130
|
-
homepage: https://github.com/
|
159
|
+
homepage: https://github.com/logstash-plugins/logstash-output-monasca_log_api
|
131
160
|
licenses:
|
132
161
|
- Apache-2.0
|
133
162
|
metadata:
|