logstash-core 6.0.0.alpha2-java → 6.0.0.beta1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. checksums.yaml +5 -5
  2. data/gemspec_jars.rb +6 -4
  3. data/lib/logstash-core/logstash-core.jar +0 -0
  4. data/lib/logstash-core/logstash-core.rb +2 -2
  5. data/lib/logstash-core/version.rb +1 -1
  6. data/lib/logstash-core_jars.rb +14 -10
  7. data/lib/logstash/agent.rb +4 -2
  8. data/lib/logstash/api/commands/default_metadata.rb +1 -1
  9. data/lib/logstash/api/commands/hot_threads_reporter.rb +8 -2
  10. data/lib/logstash/api/commands/node.rb +2 -2
  11. data/lib/logstash/api/commands/stats.rb +2 -2
  12. data/lib/logstash/bootstrap_check/bad_ruby.rb +2 -2
  13. data/lib/logstash/bootstrap_check/default_config.rb +2 -3
  14. data/lib/logstash/compiler.rb +12 -12
  15. data/lib/logstash/compiler/lscl.rb +17 -7
  16. data/lib/logstash/compiler/treetop_monkeypatches.rb +1 -0
  17. data/lib/logstash/config/config_ast.rb +11 -1
  18. data/lib/logstash/config/mixin.rb +5 -0
  19. data/lib/logstash/config/modules_common.rb +101 -0
  20. data/lib/logstash/config/source/base.rb +75 -0
  21. data/lib/logstash/config/source/local.rb +52 -50
  22. data/lib/logstash/config/source/modules.rb +55 -0
  23. data/lib/logstash/config/source/multi_local.rb +54 -10
  24. data/lib/logstash/config/source_loader.rb +1 -0
  25. data/lib/logstash/config/string_escape.rb +27 -0
  26. data/lib/logstash/elasticsearch_client.rb +142 -0
  27. data/lib/logstash/environment.rb +5 -1
  28. data/lib/logstash/event.rb +0 -1
  29. data/lib/logstash/instrument/global_metrics.rb +13 -0
  30. data/lib/logstash/instrument/metric_store.rb +16 -13
  31. data/lib/logstash/instrument/metric_type/counter.rb +6 -18
  32. data/lib/logstash/instrument/metric_type/gauge.rb +6 -12
  33. data/lib/logstash/instrument/periodic_poller/dlq.rb +19 -0
  34. data/lib/logstash/instrument/periodic_pollers.rb +3 -1
  35. data/lib/logstash/logging/logger.rb +43 -14
  36. data/lib/logstash/modules/cli_parser.rb +74 -0
  37. data/lib/logstash/modules/elasticsearch_config.rb +22 -0
  38. data/lib/logstash/modules/elasticsearch_importer.rb +37 -0
  39. data/lib/logstash/modules/elasticsearch_resource.rb +10 -0
  40. data/lib/logstash/modules/file_reader.rb +36 -0
  41. data/lib/logstash/modules/kibana_base.rb +24 -0
  42. data/lib/logstash/modules/kibana_client.rb +122 -0
  43. data/lib/logstash/modules/kibana_config.rb +125 -0
  44. data/lib/logstash/modules/kibana_dashboards.rb +36 -0
  45. data/lib/logstash/modules/kibana_importer.rb +17 -0
  46. data/lib/logstash/modules/kibana_resource.rb +10 -0
  47. data/lib/logstash/modules/kibana_settings.rb +40 -0
  48. data/lib/logstash/modules/logstash_config.rb +120 -0
  49. data/lib/logstash/modules/resource_base.rb +38 -0
  50. data/lib/logstash/modules/scaffold.rb +50 -0
  51. data/lib/logstash/modules/settings_merger.rb +23 -0
  52. data/lib/logstash/modules/util.rb +17 -0
  53. data/lib/logstash/namespace.rb +1 -0
  54. data/lib/logstash/pipeline.rb +66 -27
  55. data/lib/logstash/pipeline_settings.rb +1 -0
  56. data/lib/logstash/plugins/registry.rb +1 -0
  57. data/lib/logstash/runner.rb +47 -3
  58. data/lib/logstash/settings.rb +20 -1
  59. data/lib/logstash/util/dead_letter_queue_manager.rb +1 -1
  60. data/lib/logstash/util/safe_uri.rb +146 -11
  61. data/lib/logstash/util/thread_dump.rb +4 -3
  62. data/lib/logstash/util/wrapped_acked_queue.rb +28 -24
  63. data/lib/logstash/util/wrapped_synchronous_queue.rb +19 -20
  64. data/lib/logstash/version.rb +1 -1
  65. data/locales/en.yml +56 -1
  66. data/logstash-core.gemspec +6 -4
  67. data/spec/logstash/agent/converge_spec.rb +2 -2
  68. data/spec/logstash/agent_spec.rb +11 -3
  69. data/spec/logstash/api/modules/logging_spec.rb +13 -7
  70. data/spec/logstash/api/modules/node_plugins_spec.rb +23 -5
  71. data/spec/logstash/api/modules/node_spec.rb +17 -15
  72. data/spec/logstash/api/modules/node_stats_spec.rb +0 -1
  73. data/spec/logstash/api/modules/plugins_spec.rb +40 -9
  74. data/spec/logstash/api/modules/root_spec.rb +0 -1
  75. data/spec/logstash/api/rack_app_spec.rb +2 -1
  76. data/spec/logstash/compiler/compiler_spec.rb +54 -7
  77. data/spec/logstash/config/config_ast_spec.rb +47 -8
  78. data/spec/logstash/config/mixin_spec.rb +14 -2
  79. data/spec/logstash/config/pipeline_config_spec.rb +7 -7
  80. data/spec/logstash/config/source/local_spec.rb +5 -2
  81. data/spec/logstash/config/source/multi_local_spec.rb +56 -10
  82. data/spec/logstash/config/source_loader_spec.rb +1 -1
  83. data/spec/logstash/config/string_escape_spec.rb +24 -0
  84. data/spec/logstash/event_spec.rb +9 -0
  85. data/spec/logstash/filters/base_spec.rb +1 -1
  86. data/spec/logstash/instrument/metric_store_spec.rb +2 -3
  87. data/spec/logstash/instrument/metric_type/counter_spec.rb +0 -12
  88. data/spec/logstash/instrument/metric_type/gauge_spec.rb +1 -8
  89. data/spec/logstash/instrument/periodic_poller/dlq_spec.rb +17 -0
  90. data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +1 -1
  91. data/spec/logstash/legacy_ruby_event_spec.rb +0 -9
  92. data/spec/logstash/legacy_ruby_timestamp_spec.rb +19 -14
  93. data/spec/logstash/modules/cli_parser_spec.rb +129 -0
  94. data/spec/logstash/modules/logstash_config_spec.rb +56 -0
  95. data/spec/logstash/modules/scaffold_spec.rb +239 -0
  96. data/spec/logstash/pipeline_dlq_commit_spec.rb +1 -1
  97. data/spec/logstash/pipeline_spec.rb +87 -20
  98. data/spec/logstash/runner_spec.rb +122 -5
  99. data/spec/logstash/setting_spec.rb +2 -2
  100. data/spec/logstash/settings/splittable_string_array_spec.rb +51 -0
  101. data/spec/logstash/timestamp_spec.rb +8 -2
  102. data/spec/logstash/util/safe_uri_spec.rb +16 -0
  103. data/spec/logstash/util/wrapped_acked_queue_spec.rb +63 -0
  104. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +0 -22
  105. data/spec/support/helpers.rb +1 -1
  106. data/spec/support/matchers.rb +21 -4
  107. metadata +102 -19
  108. data/lib/logstash/instrument/metric_type/base.rb +0 -31
  109. data/lib/logstash/program.rb +0 -14
  110. data/lib/logstash/string_interpolation.rb +0 -18
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 58e1606b49e2fe865d648c113d2316ba19a4604d
4
- data.tar.gz: 7c50f49a82f7bd2dec47546ddb51459e35d44c0c
2
+ SHA256:
3
+ metadata.gz: 46f57cb18b555e501983b0d9d9ae61c3be63fd5925f444a4018adce705fe6b1f
4
+ data.tar.gz: 963cbd763704c8c84ca8bb5055412baa6b57d22d3e65ac03cd7f6b2434ec227a
5
5
  SHA512:
6
- metadata.gz: c8d297ddd76d6f6c2167f934169a041c7b1df0b76a39a661ddc308405159407fa0800a3a41cf0bd8aeca2a1684ebd45482672f83985f442f500b6f4ce6e9edad
7
- data.tar.gz: 8e5e40ab3a364110604e825a43f05a83ea1b8da136f50f8ee6ae475edb69d25c6f70e076c20175eabacf6dddb9032e4d111a1d251ed22d9e5f393ee3c06ef90f
6
+ metadata.gz: 93a8a8282730e5c5e687b5bf2bc48d0aab82fa5ec8398336114f3e4a3d73d6705dac0854827ab9bfd5c52173177c72db87da5e6bb9a1ca95b14a826c51ec2860
7
+ data.tar.gz: 61df6640d1d26a96b014c9eb7399982a9829465472f9f05f5b4882c4a8720a821c6e4eca9548286dcb907e792f32f91ab1ca90fdb3f9c96dfbdb1b45d9e0b6a0
data/gemspec_jars.rb CHANGED
@@ -2,9 +2,11 @@
2
2
  # runtime dependencies to generate this gemspec dependencies file to be eval'ed by the gemspec
3
3
  # for the jar-dependencies requirements.
4
4
 
5
+ gem.requirements << "jar org.apache.logging.log4j:log4j-slf4j-impl, 2.6.2"
5
6
  gem.requirements << "jar org.apache.logging.log4j:log4j-api, 2.6.2"
6
7
  gem.requirements << "jar org.apache.logging.log4j:log4j-core, 2.6.2"
7
- gem.requirements << "jar com.fasterxml.jackson.core:jackson-core, 2.7.4"
8
- gem.requirements << "jar com.fasterxml.jackson.core:jackson-databind, 2.7.4"
9
- gem.requirements << "jar com.fasterxml.jackson.module:jackson-module-afterburner, 2.7.4"
10
- gem.requirements << "jar com.fasterxml.jackson.dataformat:jackson-dataformat-cbor, 2.7.4"
8
+ gem.requirements << "jar com.fasterxml.jackson.core:jackson-core, 2.7.3"
9
+ gem.requirements << "jar com.fasterxml.jackson.core:jackson-databind, 2.7.3"
10
+ gem.requirements << "jar com.fasterxml.jackson.core:jackson-annotations, 2.7.3"
11
+ gem.requirements << "jar com.fasterxml.jackson.module:jackson-module-afterburner, 2.7.3"
12
+ gem.requirements << "jar com.fasterxml.jackson.dataformat:jackson-dataformat-cbor, 2.7.3"
Binary file
@@ -8,8 +8,8 @@ end
8
8
  require "logstash-core_jars"
9
9
 
10
10
  # local dev setup
11
- classes_dir = File.expand_path("../../../build/classes/main", __FILE__)
12
- resources_dir = File.expand_path("../../../build/resources/main", __FILE__)
11
+ classes_dir = File.expand_path("../../../out/production/classes", __FILE__)
12
+ resources_dir = File.expand_path("../../../out/production/resources", __FILE__)
13
13
 
14
14
  if File.directory?(classes_dir) && File.directory?(resources_dir)
15
15
  # if in local dev setup, add target to classpath
@@ -5,4 +5,4 @@
5
5
  # Note to authors: this should not include dashes because 'gem' barfs if
6
6
  # you include a dash in the version string.
7
7
 
8
- LOGSTASH_CORE_VERSION = "6.0.0-alpha2"
8
+ LOGSTASH_CORE_VERSION = "6.0.0-beta1"
@@ -2,21 +2,25 @@
2
2
  begin
3
3
  require 'jar_dependencies'
4
4
  rescue LoadError
5
+ require 'com/fasterxml/jackson/core/jackson-databind/2.7.3/jackson-databind-2.7.3.jar'
5
6
  require 'org/apache/logging/log4j/log4j-core/2.6.2/log4j-core-2.6.2.jar'
6
- require 'com/fasterxml/jackson/module/jackson-module-afterburner/2.7.4/jackson-module-afterburner-2.7.4.jar'
7
7
  require 'org/apache/logging/log4j/log4j-api/2.6.2/log4j-api-2.6.2.jar'
8
- require 'com/fasterxml/jackson/core/jackson-core/2.7.4/jackson-core-2.7.4.jar'
9
- require 'com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar'
10
- require 'com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.7.4/jackson-dataformat-cbor-2.7.4.jar'
11
- require 'com/fasterxml/jackson/core/jackson-databind/2.7.4/jackson-databind-2.7.4.jar'
8
+ require 'org/slf4j/slf4j-api/1.7.21/slf4j-api-1.7.21.jar'
9
+ require 'com/fasterxml/jackson/core/jackson-annotations/2.7.3/jackson-annotations-2.7.3.jar'
10
+ require 'org/apache/logging/log4j/log4j-slf4j-impl/2.6.2/log4j-slf4j-impl-2.6.2.jar'
11
+ require 'com/fasterxml/jackson/module/jackson-module-afterburner/2.7.3/jackson-module-afterburner-2.7.3.jar'
12
+ require 'com/fasterxml/jackson/dataformat/jackson-dataformat-cbor/2.7.3/jackson-dataformat-cbor-2.7.3.jar'
13
+ require 'com/fasterxml/jackson/core/jackson-core/2.7.3/jackson-core-2.7.3.jar'
12
14
  end
13
15
 
14
16
  if defined? Jars
17
+ require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.7.3' )
15
18
  require_jar( 'org.apache.logging.log4j', 'log4j-core', '2.6.2' )
16
- require_jar( 'com.fasterxml.jackson.module', 'jackson-module-afterburner', '2.7.4' )
17
19
  require_jar( 'org.apache.logging.log4j', 'log4j-api', '2.6.2' )
18
- require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.7.4' )
19
- require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.7.0' )
20
- require_jar( 'com.fasterxml.jackson.dataformat', 'jackson-dataformat-cbor', '2.7.4' )
21
- require_jar( 'com.fasterxml.jackson.core', 'jackson-databind', '2.7.4' )
20
+ require_jar( 'org.slf4j', 'slf4j-api', '1.7.21' )
21
+ require_jar( 'com.fasterxml.jackson.core', 'jackson-annotations', '2.7.3' )
22
+ require_jar( 'org.apache.logging.log4j', 'log4j-slf4j-impl', '2.6.2' )
23
+ require_jar( 'com.fasterxml.jackson.module', 'jackson-module-afterburner', '2.7.3' )
24
+ require_jar( 'com.fasterxml.jackson.dataformat', 'jackson-dataformat-cbor', '2.7.3' )
25
+ require_jar( 'com.fasterxml.jackson.core', 'jackson-core', '2.7.3' )
22
26
  end
@@ -25,7 +25,7 @@ class LogStash::Agent
25
25
  include LogStash::Util::Loggable
26
26
  STARTED_AT = Time.now.freeze
27
27
 
28
- attr_reader :metric, :name, :settings, :webserver, :dispatcher
28
+ attr_reader :metric, :name, :settings, :webserver, :dispatcher, :ephemeral_id
29
29
  attr_accessor :logger
30
30
 
31
31
  # initialize method for LogStash::Agent
@@ -37,6 +37,7 @@ class LogStash::Agent
37
37
  @logger = self.class.logger
38
38
  @settings = settings
39
39
  @auto_reload = setting("config.reload.automatic")
40
+ @ephemeral_id = SecureRandom.uuid
40
41
 
41
42
  # Do not use @pipelines directly. Use #with_pipelines which does locking
42
43
  @pipelines = {}
@@ -57,7 +58,8 @@ class LogStash::Agent
57
58
  @source_loader = source_loader
58
59
  end
59
60
 
60
- @reload_interval = setting("config.reload.interval")
61
+ # Normalize time interval to seconds
62
+ @reload_interval = setting("config.reload.interval") / 1_000_000_000.0
61
63
 
62
64
  @collect_metric = setting("metric.collect")
63
65
 
@@ -12,7 +12,7 @@ module LogStash
12
12
  end
13
13
 
14
14
  def host
15
- Socket.gethostname
15
+ @@host ||= Socket.gethostname
16
16
  end
17
17
 
18
18
  def version
@@ -17,7 +17,12 @@ class HotThreadsReport
17
17
  report << '=' * STRING_SEPARATOR_LENGTH
18
18
  report << "\n"
19
19
  hash[:threads].each do |thread|
20
- thread_report = "#{I18n.t("logstash.web_api.hot_threads.thread_title", :percent_of_cpu_time => thread[:percent_of_cpu_time], :thread_state => thread[:state], :thread_name => thread[:name])} \n"
20
+ line_str = I18n.t("logstash.web_api.hot_threads.thread_title",
21
+ :percent_of_cpu_time => thread[:percent_of_cpu_time],
22
+ :thread_state => thread[:state],
23
+ :thread_name => thread[:name],
24
+ :thread_id => thread[:thread_id])
25
+ thread_report = "#{line_str} \n"
21
26
  thread_report << "#{thread[:path]}\n" if thread[:path]
22
27
  thread[:traces].each do |trace|
23
28
  thread_report << "\t#{trace}\n"
@@ -31,9 +36,10 @@ class HotThreadsReport
31
36
 
32
37
  def to_hash
33
38
  hash = { :time => Time.now.iso8601, :busiest_threads => @thread_dump.top_count, :threads => [] }
34
- @thread_dump.each do |thread_name, _hash|
39
+ @thread_dump.each do |_hash|
35
40
  thread_name, thread_path = _hash["thread.name"].split(": ")
36
41
  thread = { :name => thread_name,
42
+ :thread_id => _hash["thread.id"],
37
43
  :percent_of_cpu_time => cpu_time_as_percent(_hash),
38
44
  :state => _hash["thread.state"]
39
45
  }
@@ -27,8 +27,8 @@ module LogStash
27
27
  def pipeline(pipeline_id)
28
28
  extract_metrics(
29
29
  [:stats, :pipelines, pipeline_id.to_sym, :config],
30
- :workers, :batch_size, :batch_delay, :config_reload_automatic, :config_reload_interval
31
- )
30
+ :workers, :batch_size, :batch_delay, :config_reload_automatic, :config_reload_interval, :dead_letter_queue_enabled, :dead_letter_queue_path
31
+ ).reject{|_, v|v.nil?}
32
32
  rescue
33
33
  {}
34
34
  end
@@ -120,8 +120,8 @@ module LogStash
120
120
  },
121
121
  :reloads => stats[:reloads],
122
122
  :queue => stats[:queue]
123
- }
124
- end
123
+ }.merge(stats[:dlq] ? {:dead_letter_queue => stats[:dlq]} : {})
124
+ end
125
125
  end # module PluginsStats
126
126
  end
127
127
  end
@@ -4,8 +4,8 @@ require "logstash/errors"
4
4
  module LogStash module BootstrapCheck
5
5
  class BadRuby
6
6
  def self.check(settings)
7
- if RUBY_VERSION < "1.9.2"
8
- raise LogStash::BootstrapCheckError, "Ruby 1.9.2 or later is required. (You are running: " + RUBY_VERSION + ")"
7
+ if RUBY_VERSION < "2.0"
8
+ raise LogStash::BootstrapCheckError, "Ruby 2.0 or later is required. (You are running: " + RUBY_VERSION + ")"
9
9
  end
10
10
  end
11
11
  end
@@ -1,13 +1,12 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/errors"
3
+ require "logstash/logging"
3
4
 
4
5
  module LogStash module BootstrapCheck
5
6
  class DefaultConfig
6
7
  def self.check(settings)
7
8
  # currently none of the checks applies if there are multiple pipelines
8
- if settings.get("config.reload.automatic") && settings.get_setting("config.string").set?
9
- raise LogStash::BootstrapCheckError, I18n.t("logstash.runner.reload-with-config-string")
10
- end
9
+ # See LogStash::Config::Source::Base for any further settings conflict checks
11
10
  end
12
11
  end
13
12
  end end
@@ -2,19 +2,18 @@ require 'logstash/util/loggable'
2
2
  require 'logstash/compiler/lscl/lscl_grammar'
3
3
 
4
4
  java_import org.logstash.config.ir.PipelineIR
5
- java_import org.logstash.config.ir.graph.Graph;
6
- java_import org.logstash.config.ir.graph.PluginVertex;
5
+ java_import org.logstash.config.ir.graph.Graph
7
6
 
8
7
  module LogStash; class Compiler
9
8
  include ::LogStash::Util::Loggable
10
9
 
11
- def self.compile_sources(*sources_with_metadata)
10
+ def self.compile_sources(sources_with_metadata, settings)
12
11
  graph_sections = sources_with_metadata.map do |swm|
13
- self.compile_graph(swm)
12
+ self.compile_graph(swm, settings)
14
13
  end
15
14
 
16
- input_graph = org.logstash.config.ir.graph.Graph.combine(*graph_sections.map {|s| s[:input] }).graph
17
- output_graph = org.logstash.config.ir.graph.Graph.combine(*graph_sections.map {|s| s[:output] }).graph
15
+ input_graph = Graph.combine(*graph_sections.map {|s| s[:input] }).graph
16
+ output_graph = Graph.combine(*graph_sections.map {|s| s[:output] }).graph
18
17
 
19
18
  filter_graph = graph_sections.reduce(nil) do |acc, s|
20
19
  filter_section = s[:filter]
@@ -28,10 +27,10 @@ module LogStash; class Compiler
28
27
 
29
28
  original_source = sources_with_metadata.map(&:text).join("\n")
30
29
 
31
- org.logstash.config.ir.PipelineIR.new(input_graph, filter_graph, output_graph, original_source)
30
+ PipelineIR.new(input_graph, filter_graph, output_graph, original_source)
32
31
  end
33
32
 
34
- def self.compile_ast(source_with_metadata)
33
+ def self.compile_ast(source_with_metadata, settings)
35
34
  if !source_with_metadata.is_a?(org.logstash.common.SourceWithMetadata)
36
35
  raise ArgumentError, "Expected 'org.logstash.common.SourceWithMetadata', got #{source_with_metadata.class}"
37
36
  end
@@ -43,14 +42,15 @@ module LogStash; class Compiler
43
42
  raise ConfigurationError, grammar.failure_reason
44
43
  end
45
44
 
45
+ config.process_escape_sequences = settings.get_value("config.support_escapes")
46
46
  config.compile(source_with_metadata)
47
47
  end
48
48
 
49
- def self.compile_imperative(source_with_metadata)
50
- compile_ast(source_with_metadata)
49
+ def self.compile_imperative(source_with_metadata, settings)
50
+ compile_ast(source_with_metadata, settings)
51
51
  end
52
52
 
53
- def self.compile_graph(source_with_metadata)
54
- Hash[compile_imperative(source_with_metadata).map {|section,icompiled| [section, icompiled.toGraph]}]
53
+ def self.compile_graph(source_with_metadata, settings)
54
+ Hash[compile_imperative(source_with_metadata, settings).map {|section,icompiled| [section, icompiled.toGraph]}]
55
55
  end
56
56
  end; end
@@ -2,10 +2,14 @@
2
2
  require 'logstash/errors'
3
3
  require "treetop"
4
4
  require "logstash/compiler/treetop_monkeypatches"
5
+ require "logstash/config/string_escape"
6
+
5
7
  java_import org.logstash.config.ir.DSL
6
8
  java_import org.logstash.common.SourceWithMetadata
7
9
 
8
10
  module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSCL; module AST
11
+ PROCESS_ESCAPE_SEQUENCES = :process_escape_sequences
12
+
9
13
  # Helpers for parsing LSCL files
10
14
  module Helpers
11
15
  def source_meta
@@ -46,10 +50,6 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
46
50
  [self.input.line_of(start), self.input.column_of(start)]
47
51
  end
48
52
 
49
- def empty_source_meta()
50
- org.logstash.common.SourceWithMetadata.new(base_protocol, base_id, nil)
51
- end
52
-
53
53
  def jdsl
54
54
  org.logstash.config.ir.DSL
55
55
  end
@@ -77,6 +77,10 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
77
77
 
78
78
  class Config < Node
79
79
  include Helpers
80
+
81
+ def process_escape_sequences=(val)
82
+ set_meta(PROCESS_ESCAPE_SEQUENCES, val)
83
+ end
80
84
 
81
85
  def compile(base_source_with_metadata=nil)
82
86
  # There is no way to move vars across nodes in treetop :(
@@ -99,11 +103,12 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
99
103
  end
100
104
  end
101
105
 
106
+ compiled_section_map = {}
102
107
  section_map.keys.each do |key|
103
- section_map[key] = compose_for(key).call(empty_source_meta, *section_map[key])
108
+ compiled_section_map[key] = compose_for(key).call(*section_map[key])
104
109
  end
105
110
 
106
- section_map
111
+ compiled_section_map
107
112
  end
108
113
  end
109
114
 
@@ -179,7 +184,12 @@ module LogStashCompilerLSCLGrammar; module LogStash; module Compiler; module LSC
179
184
 
180
185
  class String < Value
181
186
  def expr
182
- jdsl.e_value(source_meta, text_value[1...-1])
187
+ value = if get_meta(PROCESS_ESCAPE_SEQUENCES)
188
+ ::LogStash::Config::StringEscape.process_escapes(text_value[1...-1])
189
+ else
190
+ text_value[1...-1]
191
+ end
192
+ jdsl.eValue(source_meta, value)
183
193
  end
184
194
  end
185
195
 
@@ -10,6 +10,7 @@ class Treetop::Runtime::SyntaxNode
10
10
  @ast_metadata ||= {}
11
11
  @ast_metadata[key] = value
12
12
  end
13
+
13
14
  def compile
14
15
  return "" if elements.nil?
15
16
  return elements.collect(&:compile).reject(&:empty?).join("")
@@ -5,6 +5,7 @@ require "treetop"
5
5
  require "logstash/compiler/treetop_monkeypatches"
6
6
 
7
7
  module LogStash; module Config; module AST
8
+ PROCESS_ESCAPE_SEQUENCES = :process_escape_sequences
8
9
 
9
10
  def self.deferred_conditionals=(val)
10
11
  @deferred_conditionals = val
@@ -37,6 +38,11 @@ module LogStash; module Config; module AST
37
38
  end
38
39
 
39
40
  class Config < Node
41
+ def process_escape_sequences=(val)
42
+ set_meta(PROCESS_ESCAPE_SEQUENCES, val)
43
+ end
44
+
45
+
40
46
  def compile
41
47
  LogStash::Config::AST.deferred_conditionals = []
42
48
  LogStash::Config::AST.deferred_conditionals_index = 0
@@ -279,7 +285,11 @@ module LogStash; module Config; module AST
279
285
  end
280
286
  class String < Value
281
287
  def compile
282
- return Unicode.wrap(text_value[1...-1])
288
+ if get_meta(PROCESS_ESCAPE_SEQUENCES)
289
+ Unicode.wrap(LogStash::Config::StringEscape.process_escapes(text_value[1...-1]))
290
+ else
291
+ Unicode.wrap(text_value[1...-1])
292
+ end
283
293
  end
284
294
  end
285
295
  class RegExp < Value
@@ -143,6 +143,9 @@ module LogStash::Config::Mixin
143
143
  end # def config_init
144
144
 
145
145
  module DSL
146
+
147
+ include LogStash::Util::EnvironmentVariables
148
+
146
149
  attr_accessor :flags
147
150
 
148
151
  # If name is given, set the name and return it.
@@ -388,6 +391,8 @@ module LogStash::Config::Mixin
388
391
  # (see LogStash::Inputs::File for example)
389
392
  result = nil
390
393
 
394
+ value = deep_replace(value)
395
+
391
396
  if validator.nil?
392
397
  return true, value
393
398
  elsif validator.is_a?(Array)
@@ -0,0 +1,101 @@
1
+ # encoding: utf-8
2
+ require "logstash/util/loggable"
3
+ require "logstash/elasticsearch_client"
4
+ require "logstash/modules/kibana_client"
5
+ require "logstash/modules/elasticsearch_importer"
6
+ require "logstash/modules/kibana_importer"
7
+ require "logstash/modules/settings_merger"
8
+ require "logstash/errors"
9
+
10
+ module LogStash module Config
11
+ class ModulesCommon # extracted here for bwc with 5.x
12
+ include LogStash::Util::Loggable
13
+
14
+ MODULES_MAX_PIPELINES = 1
15
+
16
+ def self.pipeline_configs(settings)
17
+ pipelines = []
18
+ plugin_modules = LogStash::PLUGIN_REGISTRY.plugins_with_type(:modules)
19
+
20
+ cli_settings = settings.get("modules.cli")
21
+ yml_settings = settings.get("modules")
22
+
23
+ modules_array = if !(cli_settings.empty? && yml_settings.empty?)
24
+ LogStash::Modules::SettingsMerger.merge(cli_settings, yml_settings)
25
+ elsif cli_settings.empty?
26
+ yml_settings
27
+ else
28
+ cli_settings
29
+ end
30
+
31
+ if modules_array.empty?
32
+ # no specifed modules
33
+ return pipelines
34
+ end
35
+ logger.debug("Specified modules", :modules_array => modules_array.to_s)
36
+
37
+ module_names = modules_array.collect {|module_hash| module_hash["name"]}
38
+ if module_names.size > MODULES_MAX_PIPELINES
39
+ error_message = I18n.t("logstash.modules.configuration.modules-too-many-specified", :max => MODULES_MAX_PIPELINES, :specified_modules => module_names.join(', '))
40
+ raise LogStash::ConfigLoadingError, error_message
41
+ end
42
+
43
+ if module_names.length > module_names.uniq.length
44
+ duplicate_modules = module_names.group_by(&:to_s).select { |_,v| v.size > 1 }.keys
45
+ raise LogStash::ConfigLoadingError, I18n.t("logstash.modules.configuration.modules-must-be-unique", :duplicate_modules => duplicate_modules)
46
+ end
47
+
48
+ available_module_names = plugin_modules.map(&:module_name)
49
+ specified_and_available_names = module_names & available_module_names
50
+
51
+ if (specified_and_available_names).empty?
52
+ i18n_opts = {:specified_modules => module_names, :available_modules => available_module_names}
53
+ raise LogStash::ConfigLoadingError, I18n.t("logstash.modules.configuration.modules-unavailable", i18n_opts)
54
+ end
55
+
56
+ specified_and_available_names.each do |module_name|
57
+ connect_fail_args = {}
58
+ begin
59
+ module_settings = settings.clone
60
+
61
+ module_hash = modules_array.find {|m| m["name"] == module_name}
62
+ current_module = plugin_modules.find { |allmodules| allmodules.module_name == module_name }
63
+
64
+ alt_name = "module-#{module_name}"
65
+ pipeline_id = alt_name
66
+ module_settings.set("pipeline.id", pipeline_id)
67
+ current_module.with_settings(module_hash)
68
+ config_test = settings.get("config.test_and_exit")
69
+ if !config_test
70
+ esclient = LogStash::ElasticsearchClient.build(module_hash)
71
+ kbnclient = LogStash::Modules::KibanaClient.new(module_hash)
72
+ esconnected = esclient.can_connect?
73
+ kbnconnected = kbnclient.can_connect?
74
+ if esconnected && kbnconnected
75
+ current_module.add_kibana_version(kbnclient.version_parts)
76
+ current_module.import(
77
+ LogStash::Modules::ElasticsearchImporter.new(esclient),
78
+ LogStash::Modules::KibanaImporter.new(kbnclient)
79
+ )
80
+ else
81
+ connect_fail_args[:module_name] = module_name
82
+ connect_fail_args[:elasticsearch_hosts] = esclient.host_settings
83
+ connect_fail_args[:kibana_hosts] = kbnclient.host_settings
84
+ end
85
+ end
86
+ config_string = current_module.config_string
87
+ pipelines << {"pipeline_id" => pipeline_id, "alt_name" => alt_name, "config_string" => config_string, "settings" => module_settings}
88
+ rescue => e
89
+ new_error = LogStash::ConfigLoadingError.new(I18n.t("logstash.modules.configuration.parse-failed", :error => e.message))
90
+ new_error.set_backtrace(e.backtrace)
91
+ raise new_error
92
+ end
93
+
94
+ if !connect_fail_args.empty?
95
+ raise LogStash::ConfigLoadingError, I18n.t("logstash.modules.configuration.elasticsearch_connection_failed", connect_fail_args)
96
+ end
97
+ end
98
+ pipelines
99
+ end
100
+ end
101
+ end end