logstash-core 2.4.1-java → 5.0.0.alpha1-java
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of logstash-core might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/logstash-core/version.rb +1 -1
- data/lib/logstash/agent.rb +124 -411
- data/lib/logstash/api/init.ru +31 -0
- data/lib/logstash/api/lib/app.rb +40 -0
- data/lib/logstash/api/lib/app/command.rb +29 -0
- data/lib/logstash/api/lib/app/command_factory.rb +29 -0
- data/lib/logstash/api/lib/app/commands/stats/events_command.rb +13 -0
- data/lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb +120 -0
- data/lib/logstash/api/lib/app/commands/stats/memory_command.rb +25 -0
- data/lib/logstash/api/lib/app/commands/system/basicinfo_command.rb +15 -0
- data/lib/logstash/api/lib/app/commands/system/plugins_command.rb +28 -0
- data/lib/logstash/api/lib/app/modules/node.rb +25 -0
- data/lib/logstash/api/lib/app/modules/node_stats.rb +51 -0
- data/lib/logstash/api/lib/app/modules/plugins.rb +15 -0
- data/lib/logstash/api/lib/app/modules/stats.rb +21 -0
- data/lib/logstash/api/lib/app/root.rb +13 -0
- data/lib/logstash/api/lib/app/service.rb +61 -0
- data/lib/logstash/api/lib/app/stats.rb +56 -0
- data/lib/logstash/api/lib/helpers/app_helpers.rb +23 -0
- data/lib/logstash/codecs/base.rb +1 -29
- data/lib/logstash/config/config_ast.rb +18 -31
- data/lib/logstash/config/loader.rb +3 -5
- data/lib/logstash/config/mixin.rb +25 -64
- data/lib/logstash/filter_delegator.rb +65 -0
- data/lib/logstash/inputs/base.rb +1 -1
- data/lib/logstash/inputs/metrics.rb +47 -0
- data/lib/logstash/instrument/collector.rb +109 -0
- data/lib/logstash/instrument/metric.rb +102 -0
- data/lib/logstash/instrument/metric_store.rb +228 -0
- data/lib/logstash/instrument/metric_type.rb +24 -0
- data/lib/logstash/instrument/metric_type/base.rb +35 -0
- data/lib/logstash/instrument/metric_type/counter.rb +29 -0
- data/lib/logstash/instrument/metric_type/gauge.rb +22 -0
- data/lib/logstash/instrument/metric_type/mean.rb +33 -0
- data/lib/logstash/instrument/namespaced_metric.rb +54 -0
- data/lib/logstash/instrument/null_metric.rb +4 -3
- data/lib/logstash/instrument/periodic_poller/base.rb +57 -0
- data/lib/logstash/instrument/periodic_poller/jvm.rb +92 -0
- data/lib/logstash/instrument/periodic_poller/os.rb +13 -0
- data/lib/logstash/instrument/periodic_poller/periodic_poller_observer.rb +19 -0
- data/lib/logstash/instrument/periodic_pollers.rb +26 -0
- data/lib/logstash/instrument/snapshot.rb +16 -0
- data/lib/logstash/json.rb +2 -3
- data/lib/logstash/namespace.rb +1 -0
- data/lib/logstash/output_delegator.rb +16 -3
- data/lib/logstash/outputs/base.rb +1 -32
- data/lib/logstash/pipeline.rb +67 -8
- data/lib/logstash/plugin.rb +57 -19
- data/lib/logstash/runner.rb +348 -84
- data/lib/logstash/util.rb +9 -0
- data/lib/logstash/util/duration_formatter.rb +15 -0
- data/lib/logstash/util/java_version.rb +2 -4
- data/lib/logstash/util/loggable.rb +29 -0
- data/lib/logstash/version.rb +1 -1
- data/lib/logstash/webserver.rb +98 -0
- data/locales/en.yml +42 -24
- data/logstash-core.gemspec +9 -6
- data/spec/api/lib/api/node_spec.rb +64 -0
- data/spec/api/lib/api/node_stats_spec.rb +68 -0
- data/spec/api/lib/api/plugins_spec.rb +57 -0
- data/spec/api/lib/api/root_spec.rb +20 -0
- data/spec/api/lib/api/stats_spec.rb +19 -0
- data/spec/api/lib/commands/events_spec.rb +17 -0
- data/spec/api/lib/commands/jvm_spec.rb +45 -0
- data/spec/api/spec_helper.rb +128 -0
- data/spec/logstash/agent_spec.rb +62 -169
- data/spec/logstash/config/config_ast_spec.rb +2 -47
- data/spec/logstash/config/mixin_spec.rb +0 -157
- data/spec/logstash/filter_delegator_spec.rb +143 -0
- data/spec/logstash/inputs/metrics_spec.rb +52 -0
- data/spec/logstash/instrument/collector_spec.rb +49 -0
- data/spec/logstash/instrument/metric_spec.rb +110 -0
- data/spec/logstash/instrument/metric_store_spec.rb +163 -0
- data/spec/logstash/instrument/metric_type/counter_spec.rb +40 -0
- data/spec/logstash/instrument/metric_type/gauge_spec.rb +40 -0
- data/spec/logstash/instrument/namespaced_metric_spec.rb +25 -0
- data/spec/logstash/instrument/null_metric_spec.rb +9 -51
- data/spec/logstash/json_spec.rb +14 -0
- data/spec/logstash/output_delegator_spec.rb +6 -3
- data/spec/logstash/outputs/base_spec.rb +0 -107
- data/spec/logstash/pipeline_spec.rb +204 -33
- data/spec/logstash/plugin_spec.rb +80 -15
- data/spec/logstash/runner_spec.rb +134 -38
- data/spec/logstash/shutdown_watcher_spec.rb +0 -1
- data/spec/logstash/util/duration_formatter_spec.rb +11 -0
- data/spec/logstash/util/java_version_spec.rb +10 -2
- data/spec/logstash/util_spec.rb +28 -0
- data/spec/support/matchers.rb +30 -0
- metadata +154 -20
- data/lib/logstash/logging/json.rb +0 -21
- data/lib/logstash/special_agent.rb +0 -8
- data/lib/logstash/util/safe_uri.rb +0 -50
- data/spec/logstash/codecs/base_spec.rb +0 -74
- data/spec/static/i18n_spec.rb +0 -25
data/lib/logstash/util.rb
CHANGED
@@ -184,6 +184,15 @@ module LogStash::Util
|
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
+
# Take a instance reference and return the name of the class
|
188
|
+
# stripping all the modules.
|
189
|
+
#
|
190
|
+
# @param [Object] The object to return the class)
|
191
|
+
# @return [String] The name of the class
|
192
|
+
def self.class_name(instance)
|
193
|
+
instance.class.name.split("::").last
|
194
|
+
end
|
195
|
+
|
187
196
|
def self.deep_clone(o)
|
188
197
|
case o
|
189
198
|
when Hash
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "chronic_duration"
|
3
|
+
module LogStash::Util::DurationFormatter
|
4
|
+
CHRONIC_OPTIONS = { :format => :short }
|
5
|
+
|
6
|
+
# Take a duration in milliseconds and transform it into
|
7
|
+
# a format that a human can understand. This is currently used by
|
8
|
+
# the API.
|
9
|
+
#
|
10
|
+
# @param [Fixnum] Duration in milliseconds
|
11
|
+
# @return [String] Duration in human format
|
12
|
+
def self.human_format(duration)
|
13
|
+
ChronicDuration.output(duration / 1000, CHRONIC_OPTIONS)
|
14
|
+
end
|
15
|
+
end
|
@@ -9,7 +9,7 @@ module LogStash::Util::JavaVersion
|
|
9
9
|
# Print a warning if we're on a bad version of java
|
10
10
|
def self.warn_on_bad_java_version
|
11
11
|
if self.bad_java_version?(self.version)
|
12
|
-
msg = "!!! Please upgrade your java version, the current version '#{self.version}'
|
12
|
+
msg = "!!! Please upgrade your java version, the current version '#{self.version}' is not supported. We recommend a minimum version of Java 8"
|
13
13
|
STDERR.puts(msg)
|
14
14
|
logger.warn(msg)
|
15
15
|
end
|
@@ -55,9 +55,7 @@ module LogStash::Util::JavaVersion
|
|
55
55
|
parsed = parse_java_version(version_string)
|
56
56
|
return false unless parsed
|
57
57
|
|
58
|
-
if parsed[:major] == 1 && parsed[:minor]
|
59
|
-
true
|
60
|
-
elsif parsed[:major] == 1 && parsed[:minor] < 7
|
58
|
+
if parsed[:major] == 1 && parsed[:minor] < 8
|
61
59
|
true
|
62
60
|
else
|
63
61
|
false
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "logstash/namespace"
|
3
|
+
require "cabin"
|
4
|
+
|
5
|
+
module LogStash module Util
|
6
|
+
module Loggable
|
7
|
+
class << self
|
8
|
+
def logger=(new_logger)
|
9
|
+
@logger = new_logger
|
10
|
+
end
|
11
|
+
|
12
|
+
def logger
|
13
|
+
@logger ||= Cabin::Channel.get(LogStash)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.included(base)
|
18
|
+
class << base
|
19
|
+
def logger
|
20
|
+
Loggable.logger
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def logger
|
26
|
+
Loggable.logger
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end; end
|
data/lib/logstash/version.rb
CHANGED
@@ -0,0 +1,98 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "puma"
|
3
|
+
require "puma/single"
|
4
|
+
require "puma/binder"
|
5
|
+
require "puma/configuration"
|
6
|
+
require "puma/commonlogger"
|
7
|
+
|
8
|
+
module LogStash
|
9
|
+
class WebServer
|
10
|
+
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
attr_reader :logger, :status, :config, :options, :cli_options, :runner, :binder, :events
|
14
|
+
|
15
|
+
def_delegator :@runner, :stats
|
16
|
+
|
17
|
+
DEFAULT_HOST = "127.0.0.1".freeze
|
18
|
+
DEFAULT_PORT = 9600.freeze
|
19
|
+
|
20
|
+
def initialize(logger, options={})
|
21
|
+
@logger = logger
|
22
|
+
http_host = options[:http_host] || DEFAULT_HOST
|
23
|
+
http_port = options[:http_port] || DEFAULT_PORT
|
24
|
+
@options = {}
|
25
|
+
@cli_options = options.merge({ :rackup => ::File.join(::File.dirname(__FILE__), "api", "init.ru"),
|
26
|
+
:binds => ["tcp://#{http_host}:#{http_port}"],
|
27
|
+
:debug => logger.debug?,
|
28
|
+
# Prevent puma from queueing request when not able to properly handling them,
|
29
|
+
# fixed https://github.com/elastic/logstash/issues/4674. See
|
30
|
+
# https://github.com/puma/puma/pull/640 for mode internal details in PUMA.
|
31
|
+
:queue_requests => false
|
32
|
+
})
|
33
|
+
@status = nil
|
34
|
+
|
35
|
+
parse_options
|
36
|
+
|
37
|
+
@runner = nil
|
38
|
+
@events = ::Puma::Events.strings
|
39
|
+
@binder = ::Puma::Binder.new(@events)
|
40
|
+
@binder.import_from_env
|
41
|
+
|
42
|
+
set_environment
|
43
|
+
end
|
44
|
+
|
45
|
+
def run
|
46
|
+
log "=== puma start: #{Time.now} ==="
|
47
|
+
|
48
|
+
@runner = Puma::Single.new(self)
|
49
|
+
@status = :run
|
50
|
+
@runner.run
|
51
|
+
stop(:graceful => true)
|
52
|
+
end
|
53
|
+
|
54
|
+
def log(str)
|
55
|
+
logger.debug(str)
|
56
|
+
end
|
57
|
+
|
58
|
+
def error(str)
|
59
|
+
logger.error(str)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Empty method, this method is required because of the puma usage we make through
|
63
|
+
# the Single interface, https://github.com/puma/puma/blob/master/lib/puma/single.rb#L82
|
64
|
+
# for more details. This can always be implemented when we want to keep track of this
|
65
|
+
# bit of data.
|
66
|
+
def write_state; end
|
67
|
+
|
68
|
+
def stop(options={})
|
69
|
+
graceful = options.fetch(:graceful, true)
|
70
|
+
|
71
|
+
if graceful
|
72
|
+
@runner.stop_blocked
|
73
|
+
else
|
74
|
+
@runner.stop
|
75
|
+
end rescue nil
|
76
|
+
|
77
|
+
@status = :stop
|
78
|
+
log "=== puma shutdown: #{Time.now} ==="
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def env
|
84
|
+
@options[:debug] ? "development" : "production"
|
85
|
+
end
|
86
|
+
|
87
|
+
def set_environment
|
88
|
+
@options[:environment] = env
|
89
|
+
ENV['RACK_ENV'] = env
|
90
|
+
end
|
91
|
+
|
92
|
+
def parse_options
|
93
|
+
@config = ::Puma::Configuration.new(cli_options)
|
94
|
+
@config.load
|
95
|
+
@options = @config.options
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
data/locales/en.yml
CHANGED
@@ -6,6 +6,8 @@ en:
|
|
6
6
|
oops: |-
|
7
7
|
An unexpected error occurred!
|
8
8
|
logstash:
|
9
|
+
error: >-
|
10
|
+
Error: %{error}
|
9
11
|
environment:
|
10
12
|
jruby-required: >-
|
11
13
|
JRuby is required
|
@@ -56,15 +58,6 @@ en:
|
|
56
58
|
agent:
|
57
59
|
sighup: >-
|
58
60
|
SIGHUP received.
|
59
|
-
missing-configuration: >-
|
60
|
-
No configuration file was specified. Perhaps you forgot to provide
|
61
|
-
the '-f yourlogstash.conf' flag?
|
62
|
-
invalid-configuration: >-
|
63
|
-
The given configuration is invalid. Reason: %{error}
|
64
|
-
reload-without-config-path: >-
|
65
|
-
Configuration reloading also requires passing a configuration path with '-f yourlogstash.conf'
|
66
|
-
error: >-
|
67
|
-
Error: %{error}
|
68
61
|
sigint: >-
|
69
62
|
SIGINT received. Shutting down the agent.
|
70
63
|
sigterm: >-
|
@@ -78,11 +71,38 @@ en:
|
|
78
71
|
non_reloadable_config_reload: >-
|
79
72
|
Unable to reload configuration because it does not support dynamic reloading
|
80
73
|
non_reloadable_config_register: |-
|
81
|
-
Logstash
|
74
|
+
Logstash was not able to load configuration since it does not support
|
75
|
+
dynamic reloading and -r or --auto-reload flag was enabled
|
76
|
+
web_api:
|
77
|
+
flag:
|
78
|
+
http_host: Web API binding host
|
79
|
+
http_port: Web API http port
|
80
|
+
hot_threads:
|
81
|
+
title: |-
|
82
|
+
::: {%{hostname}}
|
83
|
+
Hot threads at %{time}, busiestThreads=%{top_count}:
|
84
|
+
thread_title: |-
|
85
|
+
%{percent_of_cpu_time} % of cpu usage by %{thread_state} thread named '%{thread_name}'
|
86
|
+
runner:
|
87
|
+
short-help: |-
|
88
|
+
usage:
|
89
|
+
bin/logstash -f CONFIG_PATH [-t] [-r] [--quiet|verbose|debug] [-w COUNT] [-l LOG]
|
90
|
+
bin/logstash -e CONFIG_STR [-t] [--quiet|verbose|debug] [-w COUNT] [-l LOG]
|
91
|
+
bin/logstash -i SHELL [--quiet|verbose|debug]
|
92
|
+
bin/logstash -V [--verbose|debug]
|
93
|
+
bin/logstash --help
|
94
|
+
invalid-configuration: >-
|
95
|
+
The given configuration is invalid. Reason: %{error}
|
96
|
+
missing-configuration: >-
|
97
|
+
No configuration file was specified. Perhaps you forgot to provide
|
98
|
+
the '-f yourlogstash.conf' flag?
|
99
|
+
reload-without-config-path: >-
|
100
|
+
Configuration reloading also requires passing a configuration path with '-f yourlogstash.conf'
|
101
|
+
invalid-shell: >-
|
102
|
+
Invalid option for interactive Ruby shell. Use either "irb" or "pry"
|
82
103
|
configtest-flag-information: |-
|
83
|
-
You may be interested in the '--configtest' flag which you can
|
84
|
-
|
85
|
-
to restart a running system.
|
104
|
+
You may be interested in the '--configtest' flag which you can use to validate
|
105
|
+
logstash's configuration before you choose to restart a running system.
|
86
106
|
configuration:
|
87
107
|
obsolete: >-
|
88
108
|
The setting `%{name}` in plugin `%{plugin}` is obsolete and is no
|
@@ -168,8 +188,6 @@ en:
|
|
168
188
|
with the respective environment variable value named "VAR".
|
169
189
|
pipeline-workers: |+
|
170
190
|
Sets the number of pipeline workers to run.
|
171
|
-
filterworkers: |+
|
172
|
-
DEPRECATED. Now an alias for --pipeline-workers and -w
|
173
191
|
pipeline-batch-size: |+
|
174
192
|
Size of batches the pipeline is to work in.
|
175
193
|
pipeline-batch-delay: |+
|
@@ -212,20 +230,20 @@ en:
|
|
212
230
|
debug: |+
|
213
231
|
Most verbose logging. This causes 'debug'
|
214
232
|
level logs to be emitted.
|
215
|
-
debug-config: |+
|
216
|
-
Print the compiled config ruby code out as a debug log (you must also have --debug enabled).
|
217
|
-
WARNING: This will include any 'password' options passed to plugin configs as plaintext, and may result
|
218
|
-
in plaintext passwords appearing in your logs!
|
219
233
|
unsafe_shutdown: |+
|
220
234
|
Force logstash to exit during shutdown even
|
221
235
|
if there are still inflight events in memory.
|
222
236
|
By default, logstash will refuse to quit until all
|
223
237
|
received events have been pushed to the outputs.
|
238
|
+
rubyshell: |+
|
239
|
+
Drop to shell instead of running as normal.
|
240
|
+
Valid shells are "irb" and "pry"
|
241
|
+
node_name: |+
|
242
|
+
Specify the name of this logstash instance, if no value is given
|
243
|
+
it will default to the current hostname.
|
244
|
+
agent: |+
|
245
|
+
Specify an alternate agent plugin name.
|
224
246
|
debug_config: |+
|
225
247
|
Print the compiled config ruby code out as a debug log (you must also have --debug enabled).
|
226
248
|
WARNING: This will include any 'password' options passed to plugin configs as plaintext, and may result
|
227
|
-
in plaintext passwords appearing in your logs!
|
228
|
-
log-in-json: |+
|
229
|
-
Specify that Logstash should write its own logs in JSON form - one
|
230
|
-
event per line. If false, Logstash will log using Ruby's
|
231
|
-
Object#inspect (not easy to machine-parse)
|
249
|
+
in plaintext passwords appearing in your logs!
|
data/logstash-core.gemspec
CHANGED
@@ -11,14 +11,13 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
|
12
12
|
gem.license = "Apache License (2.0)"
|
13
13
|
|
14
|
-
gem.files = Dir.glob(["logstash-core.gemspec", "lib/**/*.rb", "spec/**/*.rb", "locales/*"])
|
14
|
+
gem.files = Dir.glob(["logstash-core.gemspec", "lib/**/*.rb", "spec/**/*.rb", "locales/*", "lib/logstash/api/init.ru"])
|
15
15
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
16
16
|
gem.name = "logstash-core"
|
17
17
|
gem.require_paths = ["lib"]
|
18
|
-
gem.version = LOGSTASH_CORE_VERSION
|
18
|
+
gem.version = LOGSTASH_CORE_VERSION.gsub(/-/, '.')
|
19
19
|
|
20
|
-
gem.add_runtime_dependency "logstash-core-event", "
|
21
|
-
# gem.add_runtime_dependency "logstash-core-event-java", "2.4.0.dev"
|
20
|
+
gem.add_runtime_dependency "logstash-core-event-java", "~> 5.0.0.alpha1"
|
22
21
|
|
23
22
|
gem.add_runtime_dependency "cabin", "~> 0.8.0" #(Apache 2.0 license)
|
24
23
|
gem.add_runtime_dependency "pry", "~> 0.10.1" #(Ruby license)
|
@@ -26,8 +25,12 @@ Gem::Specification.new do |gem|
|
|
26
25
|
gem.add_runtime_dependency "clamp", "~> 0.6.5" #(MIT license) for command line args/flags
|
27
26
|
gem.add_runtime_dependency "filesize", "0.0.4" #(MIT license) for :bytes config validator
|
28
27
|
gem.add_runtime_dependency "gems", "~> 0.8.3" #(MIT license)
|
29
|
-
gem.add_runtime_dependency "concurrent-ruby", "0.
|
30
|
-
gem.add_runtime_dependency "
|
28
|
+
gem.add_runtime_dependency "concurrent-ruby", "1.0.0"
|
29
|
+
gem.add_runtime_dependency "sinatra", '~> 1.4', '>= 1.4.6'
|
30
|
+
gem.add_runtime_dependency 'puma', '~> 2.16', '>= 2.16.0'
|
31
|
+
gem.add_runtime_dependency "jruby-openssl", "0.9.13" # Required to support TLSv1.2
|
32
|
+
gem.add_runtime_dependency "chronic_duration", "0.10.6"
|
33
|
+
gem.add_runtime_dependency "jruby-monitoring", '~> 0.3.1'
|
31
34
|
|
32
35
|
# TODO(sissel): Treetop 1.5.x doesn't seem to work well, but I haven't
|
33
36
|
# investigated what the cause might be. -Jordan
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative "../../spec_helper"
|
3
|
+
require "sinatra"
|
4
|
+
require "app/modules/node"
|
5
|
+
require "logstash/json"
|
6
|
+
|
7
|
+
describe LogStash::Api::Node do
|
8
|
+
|
9
|
+
include Rack::Test::Methods
|
10
|
+
|
11
|
+
def app()
|
12
|
+
described_class
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "#hot threads" do
|
16
|
+
|
17
|
+
before(:all) do
|
18
|
+
do_request { get "/hot_threads" }
|
19
|
+
end
|
20
|
+
|
21
|
+
it "respond OK" do
|
22
|
+
expect(last_response).to be_ok
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return a JSON object" do
|
26
|
+
expect{ LogStash::Json.load(last_response.body) }.not_to raise_error
|
27
|
+
end
|
28
|
+
|
29
|
+
context "#threads count" do
|
30
|
+
|
31
|
+
before(:all) do
|
32
|
+
do_request { get "/hot_threads?threads=5" }
|
33
|
+
end
|
34
|
+
|
35
|
+
let(:payload) { LogStash::Json.load(last_response.body) }
|
36
|
+
|
37
|
+
it "should return a json payload content type" do
|
38
|
+
expect(last_response.content_type).to eq("application/json")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should return information for <= # requested threads" do
|
42
|
+
expect(payload["threads"].count).to be <= 5
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "when asking for human output" do
|
47
|
+
|
48
|
+
before(:all) do
|
49
|
+
do_request { get "/hot_threads?human" }
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:payload) { last_response.body }
|
53
|
+
|
54
|
+
it "should return a text/plain content type" do
|
55
|
+
expect(last_response.content_type).to eq("text/plain;charset=utf-8")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should return a plain text payload" do
|
59
|
+
expect{ JSON.parse(payload) }.to raise_error
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require_relative "../../spec_helper"
|
3
|
+
require "sinatra"
|
4
|
+
require "app/modules/node_stats"
|
5
|
+
require "logstash/json"
|
6
|
+
|
7
|
+
describe LogStash::Api::NodeStats do
|
8
|
+
|
9
|
+
include Rack::Test::Methods
|
10
|
+
|
11
|
+
def app()
|
12
|
+
described_class
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:payload) { LogStash::Json.load(last_response.body) }
|
16
|
+
|
17
|
+
context "#root" do
|
18
|
+
|
19
|
+
before(:all) do
|
20
|
+
do_request { get "/" }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "respond OK" do
|
24
|
+
expect(last_response).to be_ok
|
25
|
+
end
|
26
|
+
|
27
|
+
["events", "jvm"].each do |key|
|
28
|
+
it "contains #{key} information" do
|
29
|
+
expect(payload).to include(key)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context "#events" do
|
35
|
+
|
36
|
+
let(:payload) { LogStash::Json.load(last_response.body) }
|
37
|
+
|
38
|
+
before(:all) do
|
39
|
+
do_request { get "/events" }
|
40
|
+
end
|
41
|
+
|
42
|
+
it "respond OK" do
|
43
|
+
expect(last_response).to be_ok
|
44
|
+
end
|
45
|
+
|
46
|
+
it "contains events information" do
|
47
|
+
expect(payload).to include("events")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "#jvm" do
|
52
|
+
|
53
|
+
let(:payload) { LogStash::Json.load(last_response.body) }
|
54
|
+
|
55
|
+
before(:all) do
|
56
|
+
do_request { get "/jvm" }
|
57
|
+
end
|
58
|
+
|
59
|
+
it "respond OK" do
|
60
|
+
expect(last_response).to be_ok
|
61
|
+
end
|
62
|
+
|
63
|
+
it "contains memory information" do
|
64
|
+
expect(payload).to include("mem")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|