Commit graph

539 commits

Author SHA1 Message Date
Ry Biesemeyer
68f3cf3d90
ecs_compatibility: revert breaking change; keep disabled as default for 8.0.0 (#13080)
As we close in on the availability of 8.0.0 alphas, we are reassessing which
breaking changes are _necessary_, and which are merely _desired_. And while
we would love to be in a world where ECS was on by default, and have put
substantial effort into designing an upgrade path that would be as simple as
possible, we have determined that the time may not be right to change the
default value out of under our users.

This change restores the default value for `pipeline.ecs_compatibility` to
`disabled`, ensuring pipelines will continue running in Logstash 8 as they have
in Logstash 7 without modification. We will still encourage our users to be
explicit about which behaviour they desire, and will revisit making ECS on by
default at a later date.
2021-07-20 14:45:36 -07:00
Karol Bucek
68c753439d
Feat: event factory support (#13017)
Introduce a `new_event` (factory) interface for the Ruby plugin API.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>

+ Refactor: keep (useful) causes mapping to Ruby errors

+ Refactor: avoid trim-ing (large) json strings

+ Feat: a synchronize(object) {} helper for Ruby

+ Feat: a (thread-safe) lazy_init_attr {} helper
2021-06-28 10:53:56 +02:00
Ry Biesemeyer
1a4be956c4
ecs: on-by-default plus docs (#12830)
* noop: avoid declaring default value in config file

* docs: ecs compatibility from 7.x perspective

Co-authored-by: Karen Metts <karen.metts@elastic.co>

* ecs: on by default

We know that ECS version 8 will release along-side Logstash 8.0, but its scope
is still coming into focus. In this changeset, we change the default value
of `pipeline.ecs_compatibility` from `disabled` to `v1`, which is a
significantly closer approximation to what will eventually ship in Logstash
8.0.0.

* docs: ecs from 8.x perspective

Co-authored-by: Karen Metts <karen.metts@elastic.co>

Co-authored-by: Karen Metts <karen.metts@elastic.co>
2021-06-21 11:00:08 -07:00
João Duarte
0b08838d2a
bump devutils dependency to 2.x (#12857)
* update filter_spec to not use insist
* fix ruby tests adding rspec/wait require
2021-06-08 12:31:55 +01:00
Erwin Dondorp
d19d8c679b
Support for UTF-16 and other multi-byte-character logfiles (#9702)
* Added support for UTF-16 and other multi-byte-character logfiles

* added testcase for usage of \0
2021-05-05 10:22:02 -07:00
Andrea Selva
5e7759767a
Load a plugin by alias name. (#12796)
Introcuce the concept of alias for a plugin.

Creates an AliasRegistry to map plugin aliases to original plugins.
If a real plugin with same name of the an alias is present in the system, then the real plugin take precedence during the
instantiation of the pipeline.

Simplified the error handling in class lookup

Co-authored-by: Ry Biesemeyer <ry.biesemeyer@elastic.co>
2021-04-20 22:21:33 +02:00
João Duarte
9643a33b99
update jruby to 9.2.16.0 (#12699)
fix define_method+super calls due to jruby/jruby#6571
2021-03-04 09:32:50 +00:00
andsel
79d8f47437 Separate "not terminated" pipeline state into "running" and "loading".
This change fix the behavior of considering as "running" also pipelines that are still in "loading", both "loading" and "running" is considered as "not terminated".
Fixed a flakyness in tests due to different ways to looks at the same thing: pipeline status.
The pipeline status is determined by both `pipeline.running?` and by `agent.pipelines_running`.
The first checks for an atomic boolean in pipeline object, the second check for the status in PipelineRegistry.

Fixes #12190
2021-02-15 07:23:21 -08:00
andsel
8bdd601c1b Reintroduce the work done in PR #12614 erroneusly removed by PR #12582 2021-02-02 01:03:17 -08:00
andsel
fd446c9b70 [Doc] added instruction on how to update and when an existing LS installation is update to LS 7.12+ and use JDK15
co-authored-by: karenzone@users.noreply.github.com
2021-02-02 00:12:31 -08:00
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
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
andsel
09f995776e Fix an API break, a Ruby's ArgumentError should be raised.
Reestablished Ruby specs to test moved code.
2020-11-25 01:13:06 -08:00
andsel
14570d5d86 Fix an API break in CloudSettingsAuth, a Ruby's ArgumentError should be raised.
Bring back Ruby specs to double check the change also in Ruby context.
2020-11-25 00:39:22 -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
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
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
b6b85e1a1e Add test for ordered pipeline flushing fix 2020-08-26 12:07:01 -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
6ff20ad502 make PQ and DLQ tests use less disk space
Many DLQ and PQ tests were run with default settings for their size,
or otherwise set to values such as 1GB.
This meant that the container/machine the test ran on needed a lot of disk space
(i.e. 1GB for the test + 1GB for OS and Logstash + some more free space).

This commit drops the disk space requirement overall by a factor of 10 (e.g. 1GB to 100MB)
2020-07-02 09:43:01 -07:00
Joao Duarte
0e033f9aa8 fix pipeline spec that didn't wait for pipeline to terminate
this test only called "pipeline.start" and expected an output to receive
the "do_close" method call. Therefore it relies on a race condition that
the pipeline shuts down quickly enough, which could fail.
This change ensures the pipeline fully terminated before making the
assertion

This commit also removes an unused let from the time when logstash
output plugins had workers.
2020-07-02 03:13:57 -07:00
Joao Duarte
5e1a08bbfc ensure pipeline terminates execution before doing assertion
This test relies on the generator input sending 10 events and observing
the output. Calling shutdown immediately after start can cause the
plugin to abort earily.
This change waits for the execution to finish before performing the
test assertions.
2020-07-02 03:11:31 -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
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
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
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
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
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
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
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
andsel
fc1ae6f119 Fixes #11598 enabling the users to use completely commented config files
Fixes #11615
2020-02-27 09:43:05 +00:00
Colin Surprenant
0bc9fa5665
add support for pipeline.ordered setting for java execution (#11524)
reuse rubyArray for single element batches

rename preserveBatchOrder to preserveEventOrder

allow boolean and string values for the pipeline.ordered setting, reorg validation

update docs

yml typo

Update docs/static/running-logstash-command-line.asciidoc

Co-Authored-By: Karen Metts <35154725+karenzone@users.noreply.github.com>

Update docs/static/running-logstash-command-line.asciidoc

Co-Authored-By: Karen Metts <35154725+karenzone@users.noreply.github.com>

java execution specs and spec support

docs corrections per review

typo

close not shutdown

Ruby pipeline spec
2020-01-29 14:01:38 -05:00
Mike Place
020e87efc4 Add cluster_uuid setting to default config file, displaying it in Node stats HTTP API
Fixes #11106
2020-01-27 08:12:39 +00:00
andsel
6eb25173e0 Added plugin.id to fish tag log lines related to plugins
Fixes #11078
2020-01-23 15:33:31 +00:00
Karol Bucek
1bc0aeab34 Test: try to deal with (potentially) flaky spec
Fixes #11483
2020-01-13 10:22:01 +00:00
andsel
8ccb24bf99 Changed plugin factory creation to use SourceWithMedata and not destructured line and column
Fixes #11456
2020-01-10 16:23:43 +00:00
Karol Bucek
abd4253708 Fix: SafeURI normalize and eql? to work as expected
normalize wasn't doing what was expected (URI.normalize)
also make sure SafeURI can be stored in Hash (proper eql?)

Fixes #11443
2019-12-31 10:06:40 +00:00
Karol Bucek
18af2d2c67 Test: get_thread_id (native thread being gc-d)
Fixes #11458
2019-12-30 13:04:16 +00:00