Commit graph

835 commits

Author SHA1 Message Date
kaisecheng
3fb12747f5
enable agent to stop pipeline by pipeline_id (#12582)
* This PR allows the agent to stop pipeline by pipeline_id instead of fetching the full set of pipelines from elasticsearch and compute the pipeline actions internally

Fixed: #12560
2021-01-29 14:29:56 +01:00
Rob Bavey
aef3a99920
Fix sub second config.reload.interval (#12589)
* Fix sub second `config.reload.interval`

Due to a change in #11803, using `to_seconds` to normalize values of `config.reload.interval`
would resolve to a value of 0 causing issues in tests where short reload intervals were desired.
This commit uses the `to_nanos` method to preserve the previous functionality.


Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2021-01-27 14:52:38 -05:00
andsel
99679870c6 Implements scripted log4j filters and appenders to Java, avoid usage of deprecated Javascript Nashorn (#12512)
- replaces all scripted filters with custom Java implementation
- implemented routing appender per pipeline in Java
- adapted log4j configuration shipped with Logstash
- exit the Logstash process if it detects an scripted log4j configuration
2021-01-25 02:25:09 -08:00
kaisecheng
4bc9dad69c
Remove ruby execution engine (#12517)
* remove Logstash::Pipeline
* remove logstash/event, Logstash::SignalEvent
* remove Engine.Ruby on java side
* remove config pipeline.java_execution
Fixed: #11236
2020-12-15 10:41:27 +01:00
Ry Biesemeyer
0ff682040d
plugin: adds :validate => :field_reference (#12459)
* plugin: adds `:validate => :field_reference`

Provide plugins a way of validating that an input is a literal field-reference.

This is useful for input plugins that implement a `target` or other
non-interpolated directive, and allows these plugins to reject invalid
configuration before start-up instead of at run-time.

Plugins should not use this named validator directly, as doing so would cause
validation to fail with "Unknown validator" when the plugin is run on older
releases of Logstash. Instead, plugins should use the `validator_support`
adapter mixin that provides back-ports when necessary.

Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com>
2020-12-14 22:05:34 -08:00
andsel
1a62dc79e0 Moved LogStash::Util::TimeValue to Java 2020-11-30 05:01:56 -08:00
andsel
fa3891953d Moved ModulesSettingArray from Ruby to Java.
The ModulesSettingArray is responsible to obfuscate password in arrays of settings.
The test are still in Ruby to proove the interoperability with Ruby code that used the previous version.

Added method to mimic .first and .last methods of Ruby Array
2020-11-30 01:27:44 -08:00
kaisecheng
69451e5017
clean up field-reference-parser (#12466)
remove field-reference-parser for version 8
Fixed: #12355
2020-11-24 17:58:10 +01:00
andsel
ca81a8f4a3 Drop Password Ruby class to use only the Java version
There is two Password classes that almost does the same thing. One in Ruby (LogStash::Util::Password) and one in Java (co.elastic.logstash.api.Password).
This commit drop the the Ruby implementation to import the Java version in the LogStash::Util so that existing Ruby code haven't to be changed, works as it is.
2020-11-19 07:12:53 -08:00
andsel
b0920eb6ff Move code of CloudSettingAuth to Java
- moved the class's code
- moved spec tests to JUnit tests
2020-11-18 08:14:56 -08:00
andsel
2545fa45ba Moved CloudSettingId class and tests to Java 2020-11-12 09:14:56 -08:00
kaisecheng
244a9f4024
delete pipeline in registry (#12414)
deletes the pipeline in the pipelines_registry if it is terminated and is removed in the source

Fixed: #12414
2020-11-06 22:43:33 +01:00
Rob Bavey
baca4ca8bf
Add addresses to p2pipeline input and output plugin metrics (#12394)
This commit adds context to the pipeline to pipeline input and output
plugins by adding a string containing the `address` field to the input
plugin, and an array containing the `send_to` field to the output plugin.
This helps gain a picture of how pipeline to pipeline enabled configurations
are communicating with each other, without having to refer back to the pipeline
definition
2020-11-04 15:26:50 -05:00
João Duarte
c7c0cb3ea7
Improve error message for non-existing settings (#12395) 2020-11-03 09:46:15 +00:00
Rob Bavey
002de11fe6
Add optional sourceURL to license report CSV (#12346)
* Add optional sourceURL to license report CSV

This commit adds an extra optional column 'sourceURL' to the license report. This
column contains a pointer to the source code, which is optional for most dependencies,
but a requirement for some, such as the Red Hat Universal Base Image.

This commit also populates the 'copyright' field, which previously was an used
column in the CSV definition

Relates #12297
2020-10-19 11:03:29 -04:00
Colin Surprenant
20f5512103
stop inputs upon a worker error before terminating the pipeline (#12307)
This addresses an incomplete fix in #12019 starting in 7.8.1 where upon catching a worker exception (to avoid crashing the whole logstash per #12306) the input plugin(s) are not terminated prior to closing the pipeline leading to the input plugin(s) continuing execution and failing with IllegalStateException & Tried to write to a closed queue since closing the pipeline also correctly closes the queue.
2020-10-13 15:55:53 -04:00
Rob Bavey
06af15030a
Write DLQ entries to temp file first (#12304)
* Write DLQ entries to temp file first

This commit changes the DLQ writer to write to a temporary file
 which will be renamed on "completion", to avoid the possibility
 of the DLQ reader reading an incomplete DLQ segment. The temp file
 will be renamed and made available, either when the capacity of this
 segment is reached, or if a configurable 'flush interval' has elapsed
 since the last event reached the dead letter queue.

This commit fixes #8022, #10275, #10967
This commit replaces #11127
2020-10-07 11:46:17 -04:00
Ry Biesemeyer
08d1ef0b49
ECS Compatibility (#12305)
Implements a plugin `ecs_compatibility` option, whose default value is powered
by the pipeline-level setting `pipeline.ecs_compatibility`, in line with the
proposal in elastic/logstash#11623:

In order to increase the confidence a user has when upgrading Logstash, this
implementation uses the deprecation logger to warn when `ecs_compatibility` is
used without an explicit directive.

For now, as we continue to add ECS Compatibility Modes, an opting into a
specific ECS Compatibility mode at a pipeline level is considered a BETA
feature. All plugins using the [ECS Compatibility Support][] adapter will
use the setting correctly, but pipelines configured in this way do not
guarantee consistent behaviour across minor versions of Logstash or the
plugins it bundles (e.g., upgraded plugins that have newly-implemented an ECS
Compatibility mode will use the pipeline-level setting as a default, causing
them to potentially behave differently after the upgrade).

This change-set also includes a significant amount of work within the
`PluginFactory`, which allows us to ensure that pipeline-level settings are
available to a Logstash plugin _before_ its `initialize` is executed,
including the maintaining of context for codecs that are routinely cloned.

* JEE: instantiate codecs only once
* PluginFactory: use passed FilterDelegator class
* PluginFactory: require engine name in init
* NOOP: remove useless secondary plugin factory interface
* PluginFactory: simplify, compute java args only when necessary
* PluginFactory: accept explicit id when vertex unavailable
* PluginFactory: make source optional, args required
* PluginFactory: threadsafe refactor of id duplicate tracking
* PluginFactory: make id extraction/geration more abstract/understandable
* PluginFactory: extract or generate ID when source not available
* PluginFactory: inject ExecutionContext before initializing plugins
* Codec: propagate execution_context and metric to clones
* Plugin: intercept string-specified codecs and propagate execution_context
* Plugin: implement `ecs_compatibility` for all plugins
* Plugin: deprecate use of `Config::Mixin::DSL::validate_value(String, :codec)`
2020-10-06 06:45:46 -07:00
Rob Bavey
c266470c2e
Add RedHat Univeral Base Image license information (#12287) 2020-09-30 11:13:50 -04:00
andsel
164a763d7e Fix to implement the blank? method that doesn't exists for String, is added by Rails framework 2020-09-04 07:29:04 -07:00
Colin Surprenant
e8d1073bdd ensure input plugin close is called upon termination or pipeline reload 2020-08-21 08:08:21 -07:00
Colin Surprenant
2afe60dbfc fix PipelineRegistry to avoid re-creating a pipeline in the process of being created
A pipeline in the process of being created was not marked as such in the pipeline registry resulting in a situation where a slow to initialize pipeline could be recreated on state convergence resulting in a PQ LockException because that pipeline was already existing and held the PQ lock. Replace native Java concurency with Ruby Mutex for simpler and straighforward implementation.
2020-07-13 14:48:44 -07:00
Colin Surprenant
62519acdef monitor worker threads exceptions to not crash logstash, just the failed pipeline
The worker threads were not correctly monitored for a worker loop exception resulting in a complete logstash crash upon any exception even when multiple pipelines are running. Now only the failed pipeline is terminated. If pipeline reloading is enabled, it is possible to edit the config and have that failed pipeline reloaded.
2020-07-13 14:48:44 -07:00
Joao Duarte
23efb8dde4 ensure 'starting logstash' log entry happens first 2020-07-06 07:02:13 -07:00
Joao Duarte
fd98f2e226 remove need for extra ShutdownWatcher thread
The creation of a Ruby thread from Java seems to be a trigger
for jruby/jruby#6207.

Pipeline#shutdown now blocks on the ShutdownWatcher#start, which will wait for
pipeline.finished_execution? to be true.
This removes the need for the pattern:
  `pipeline.shutdown { block } && pipeline.thread.join`
And can be replaced with just `pipeline.shutdown`

To avoid having `shutdown` blocked waiting for ready? when pipeline crashes too quickly,
this method returns immediately if finished_execution? is true.

Most uses of pipeline#run have also been replaced by pipeline#start
since the latter will block until the pipeline is ready, again avoiding
the pattern:
  `pipeline.run && sleep 0.1 until pipeline.ready?`

Pipeline tests have been changed according to these two changes.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2020-07-01 13:16:50 -07:00
Colin Surprenant
454a856df8 do not call agent.converge_state_and_update before agent.execute 2020-06-30 11:14:26 -07:00
Ry Biesemeyer
c70da3fb5c
plugin config: support space-deliminated URIs on list-type params (#12051)
* plugin config: support space-deliminated URIs on list-type params

Since whitespace is illegal in URIs, we can safely use it as a delimiter when
validating `list`-type `URI` params, enabling the expansion of an arbitrary
list of URIs from a single Environment- or Keystore-variable.

Resolves: https://github.com/elastic/logstash/issues/8157
Resolves: https://github.com/elastic/logstash/issues/6366

* Doc: Create section for cross-plugin functionality and add space delimiters

Co-authored-by: Karen Metts <karen.metts@elastic.co>
2020-06-26 14:44:46 -07:00
Joao Duarte
124e1e6abc remove explicit return from Mutex#synchronize in Plugin Registry
ruby produces a LocalJumpError: unexpected return
error if there's a return in a block so this changes just uses
the value of the last expression as the value of the block
2020-06-09 09:59:10 -07:00
Andrea Selva
1bba3adecf
Exposed again the pipelines queue.data and queue.capacity subdocuments for _node/stats (#11923)
Avoid to reassing the subdocument for queue metrics preferring a merge
With PR #10576 the PluginsStats.report(stats) overwrites the subsection related to queue instead of merge with newly created entries.
2020-06-04 15:21:51 +02:00
Colin Surprenant
0c38004bf3 display Java pipeline initialization time
Fixes #11749
2020-06-01 20:23:04 +00:00
Joao Duarte
d449fcf25a emit deprecation entry for netflow and azure modules
point users towards the beats modules instead
2020-05-29 15:26:23 +01:00
Joao Duarte
2ea7bd43ec RUNNER: print RUBY_DESCRIPTION at startup to facilitate debugging
Often when browsing logstash logs for debugging purposes we miss the
information about the Java version and platform being used.

Printing the global RUBY_PLATFORM gives us all of this information
plus the JRuby version as well.

Fixes #11852
2020-05-05 15:32:24 +00:00
Andrea Selva
832d597278
Refactor: move PipelineConfig from Ruby to Java (#11824)
Reimplement the Ruby class PipelinceConfig in Java trying to keep the method signatures to limit the changes in client code, this is a step of other that intend to move all the configuration code in Java language.
Having all that code in Java unlock some reasoning about how to better implement it and probably an improvement in performance during process startup.
Moved also the spec into a JUnit and fixed here and there the failing tests

Closes: #11824
2020-04-29 18:16:49 +02:00
Ry Biesemeyer
de5888ba18 API: avoid starting webserver when http.enabled=false
In some workflows such as simple file manipulation, starting a webserver is
unnecessary overhead, and we should be able to avoid it.

Here we introduce a new parameter `http.enabled`, which defaults to `true` to
maintain the existing functionality.

Resolves: elastic/logstash#9408
Closes: elastic/logstash#11525

Co-authored-by: Benoit Dupont <benoit.dupont@gmail.com>

Fixes #11533
2020-04-21 20:08:46 +00:00
Joao Duarte
3481b38228 dont use qualifier or snapshot in logstash core version
Fixes #11813
2020-04-21 16:50:58 +00:00
Ry Biesemeyer
f1e301e0d7 settings: deprecate unit-less TimeValue values
We have "required" units for a variety of `TimeValue` settings when they are
provided as a `String`, but unquoted values in YAML have been passed through as
Integers, where we long assumed nanosecond units. This frequently leads to
surprise (e.g., when `config.reload.interval` is set to `60`, we consume 100%
of CPU in a tight loop trying to reload and re-parse the configs every 60
nanoseconds).

By making the setting retain the TimeValue object for the entirety of its
lifecycle, we can issue a deprecation notice the first time an Integer value is
encountered. As a secondary benefit, our usage of the setting value in code
becomes more clear since we are empowered to ask `TimeValue` for a numeric
value in a specific scale.

Fixes #11803
2020-04-20 16:15:49 +00:00
Andrea Selva
6a74872d50
Moved code out of LogStash::Compiler to org.logstash.config.ir.ConfigCompiler 2020-04-15 12:21:39 +02:00
Ry Biesemeyer
0b22b00893
support Environment and Keystore substitutions in password-type plugin options (#11774)
Resolves: https://github.com/elastic/logstash/pull/10583
Co-authored-by: Tyler Gregory <td.g@icloud.com>
2020-04-13 17:28:18 -07:00
Rob Bavey
2899c9f379 Handle Boolean Edges
Fixes #11779
2020-04-13 20:09:27 +00:00
Rob Bavey
830b6ce64e Remove separator vertices and associated edges from serialized output
The separator vertices are an implementation detail of the serialized
output of the LIR, and are not meaningful to the pipeline viewer.

This commit removes the separator vertices, and reworks the edges to
account for this.

Fixes #11779
2020-04-13 20:09:27 +00:00
João Duarte
3a84beda3d
remove :cluster_uuids gauge (#11628) 2020-04-13 09:36:11 +01:00
Ry Biesemeyer
70f4c3294f performance: share a single secret store
Loading a Java Keystore can take anywhere from ~0.3s to upwards of 3s, so the
pattern of loading one per variable we need to replace adds a significant
amount of overhead on pipelines that use these variables, whether or not they
are provided by the keystore.

By providing a private, constant, lazy singleton, we ensure that we don't
incur the cost of repeatedly building the keystore.

Fixes #10794
2020-04-10 15:41:17 +00:00
Andrew Pan
8793fb3c49
Update local.rb for pipe file (#11109)
Load pipe file for process communication

Co-authored-by: Andrew Pan <px2557@foxmail.com>
2020-04-10 09:52:12 +02:00
Colin Surprenant
5a25c6f8e9 simplify batch classes, do not compute JE empty batches, refactor RE worker loop (#11737)
cleanup RubyArray "rawtypes"
remove all LinkedHashSet from batch and queue classes
avoid processing empty batches in Java worker loop
cleanup AckedReadBatch and MemoryReadBatch
refactor Ruby worker loop similar to Java Execution to not use batch merge
remove QueueBatch merge and replace LinkedHashSet with ArrayList
2020-04-02 16:26:54 -04:00
Colin Surprenant
dbca0b36a1
separate filter & output execution, rebatch after filter when ordered (#11710) 2020-03-27 15:36:23 -04:00
João Duarte
d522a7cb30
bring back unicode trimmer for LogStash::Util (#11712)
this is used by the SNS output:
5b796a0095/lib/logstash/outputs/sns.rb (L98)
2020-03-23 15:11:54 +00:00
andsel
70da647f54 Simplified if..else if in PluginFactory for Java plugins part, moved to template method pattern
Fixes #11457
2020-03-20 09:43:43 +00:00
Colin Surprenant
9126fdb7e0
support quoted plugin option key (#11688) 2020-03-16 16:58:01 -04:00
João Duarte
e9c9865f40
Add apache and elastic license headers to source code files (#11673)
* add license header to ruby and java files
* add license header to erb and rake files
* add license headers to gradle files
2020-03-11 11:53:38 +00:00
Karol Bucek
7b4808bd10 Fix: broken --help due sinatra 2.x upgrade
Fixes #11634
2020-03-03 21:00:10 +00:00