Commit graph

253 commits

Author SHA1 Message Date
Rob Bavey
02c2aec710
Fix debug output for bin/logstash-plugin (#14132)
When run in debug mode, #invoke was returning an instance of UI::Shell rather
than a string, causing the plugin to crash when `<<` was called on.
This commit ensures that a string is returned regardless of whether debug is set

Fixes: #14131
2022-05-20 09:13:08 -04:00
Rob Bavey
4a2268a43f
Update jruby version to 9.3.4.0 (#14114)
This commit updates the version of jruby used in Logstash to `9.3.4.0`.

* Updates the references of `jruby` from `9.2.20.1` to `9.3.4.0`
* Updates references/locations of ruby from `2.5.0` to `2.6.0`
* Updates java imports including `org.logstash.util` to be quoted
  * Without quoting the name of the import, the following error is observed in tests:
  * `java.lang.NoClassDefFoundError: org/logstash/Util (wrong name: org/logstash/util)`
  * Maybe an instance of https://github.com/jruby/jruby/issues/4861
* Adds a monkey patch to `require` to resolve compatibility issue between latest `jruby` and `polyglot` gem 
  * The addition of https://github.com/jruby/jruby/pull/7145 to disallow circular
causes, will throw when `polyglot` is thrown into the mix, and stop logstash from
starting and building - any gems that use an exception to determine whether or not
to load the native gem, will trigger the code added in that commit.
  * This commit adds a monkey patch of `require` to rollback the circular cause exception
back to the original cause.
* Removes the use of the deprecated `JavaClass`
* Adds additional `require time` in `generate_build_metadata`
* Rewrites a test helper to avoid potentially calling `~>` on `FalseClass`


Co-authored-by: Joao Duarte <jsvduarte@gmail.com>
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2022-05-19 10:29:59 -04:00
kaisecheng
7641b076f4
fix monitoring api integration test with draining queue (#14106)
This commit ends the integration test with teardown instead of sending a signal to kill
Related: #13935
2022-05-16 23:26:24 +01:00
kaisecheng
0af9fb0d5f
Allow metrics update when PQ draining (#13935)
This commit moves the stop of metrics collection after pipelines shutdown to allow metrics update during PQ draining
Fixed: #13832
2022-05-16 15:36:56 +01:00
Rob Bavey
e02a9e00c7
Fix plugin classloading (#14060)
Prior to this commit, attempting to use a custom java plugin installed from rubygems would
fail as the `files` field used to find jar files in the gem is not populated for such gems

This commit uses the `full_require_path` to find the jar file for a native jar plugin,
which should work regardless of where the gem was installed from, locally or via rubygems

Additionally, this commit will only attempt to locate the jar file inside the gem when it
is required (only when the experimental separate plugin class loader is used)

This commit builds on the work done in #13888

Relates: #13888, #11305

Co-authored-by: twosom <two_somang@icloud.com>
Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2022-05-03 17:49:21 -04:00
Andrea Selva
776b57f15b
Fix/avoid leak secrects in debug log of ifs (#13997)
Updates the `ConfigVariableExpander.expand` to selectively create `SecretVariable` instances for SecretStore resolved environment variables.
`SecretVariable` instances in if statements are decrypted during `eq` `EventCondition` compilation; bringing the secret value and using in the comparator.
2022-04-21 09:57:14 +02:00
Andrea Selva
d2739a875c
Updates the LogstashService launcher to use the JDK specified (#13946)
Sets the LS_JAVA_HOME environment variable for the environments used to spawn Logstash process in integration tests.
The JDK matrix testing is based on selecting the desired JDK to run the tests, through the BUILD_JAVA_HOME.
However, when the integration tests spawn a Logstash process this setting was missed.
2022-03-29 17:17:36 +02:00
Rob Bavey
00e28b1d91
[Test] Adds explicit unexpected JVM messages test, and simplifies regex in offline_spec (#13892)
* Simplify regex in prepare_offline_spec.rb
* Add test to check for unexpected warnings

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
2022-03-29 09:46:26 -04:00
Karen Metts
90a85e1cd4
Doc:Update qa readme with BUILD_JAVA_HOME setting info (#11985)
Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2022-02-15 18:44:58 -05:00
Karol Bucek
3637a30e8f
Refactor: drop redundant (jruby-complete.jar) dependency (#13159)
Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2022-02-02 06:55:26 +01:00
kaisecheng
057c24ab30
Support env variable in condition (#13608)
This PR substitutes ${VAR} in Expression, except RegexValueExpression, with the value in secret store, env.
The substitution happens after syntax parsing and before graph execution.

Fixed: #5115
2022-01-25 22:46:13 +00:00
Andrea Selva
7bb56e46dd
Test fix, switch to plugin with less dependencies (#13672)
Fixes an integration test that verifies the capabilities of CLI tool to install a not bundled plugin.
Move away from logstash-input-google_cloud_storage which depends indirectly to OS's package named shared-mime-info, which is not always available.
2022-01-25 14:38:15 +01:00
Rob Bavey
57c16e1300
Add integration test for Elasticsearch using defaults (#13353)
* Add integration test for Elasticsearch using defaults

Currently, the elasticsearch integration test turns off `data_streams`
and `ecs_compatibility`, hiding the out of the box experience for
ingesting into elasticsearch

* Removed debugging statement
2022-01-20 11:19:08 -05:00
Andrea Selva
640ba8489f
Fix/gems not found in integration test after plugin install (#13641)
Cleanly teardown an integration test that made fall other integration tests.
In some cases the CI integration tests fails because the launched Logstash can't find a gem named `mimemagic`. This gem is installed during a CLI plugin test (install of  `logstash-input-google_cloud_storage` plugins kicks in that `mimemagic`).
2022-01-19 18:45:17 +01:00
Andrea Selva
93f37b9609
Fix Ruby port check execution in kafka_setup.sh (#13631)
When the Bash script executes the vendored Ruby it has to use proper `GEM_HOME` to avoid the overwrite that happens inside the logstash.lib.sh
3064f7d0c3/bin/logstash.lib.sh (L161-L165)
2022-01-19 14:06:39 +01:00
Ry Biesemeyer
2a248b2ea0
fix: respect LS_JAVA_OPTS environment even when optionsfile missing (#13525)
* fix: respect LS_JAVA_OPTS environment even when optionsfile missing

* Fixed integration tests

* Added unit test to cover the fix

* Wipe commented code

* Removed redundant log in a path that could never be reached

* Moved jvm.options checks into only one place

* javaopts: provide injection point for environment string

Co-authored-by: andsel <selva.andre@gmail.com>
2022-01-18 08:02:08 -08:00
Andrea Selva
b6da829f4f
Avoid to increment event.out conter for dropped events (#13593)
Fixes the issue #8752 in event.out counter. When a pipeline contains a drop filter the total out events counter should count only the events that reached the out stage.

This PR changes CompiledExecution.compute() interface to return the number of events that effectively reached the end of the pipeline. This change is used in WorkerLoop to update correctly the event.out metric, instead of relying on the batch's size.
2022-01-14 15:52:06 +01:00
kaisecheng
b0c08b809a
Fix logstash-plugin install command to install non default plugin (#13405)
After the fix of unlocking ecs_compatibility_support version in plugin update (#13218), `logstash-plugin install` has a problem of installing non default plugin.
This commit removes `Bundler.setup` in install path to avoid Gemfile froze by bundler
Fixed: #13404

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2022-01-06 09:41:14 +00:00
Ry Biesemeyer
15930ccd3e
Secure API (#13308)
* settings: add "deprecated alias" support

A deprecated alias provides a path for renaming a setting.

 - When a deprecated alias is set on its own, a deprecation notice is emitted
   but fetching the canonical setting value will reflect the value set with the
   deprecated alias.
 - When both the canonical setting (new name) and the deprecated alias (old
   name) are specified, it is an error condition.
 - When the value of the deprecated alias is queried, a warning is emitted to
   the logger and only the value explicitly set to the deprecated alias is
   returned.

Additionally, some relevant cleanup is also included:

 - Starting Logstash with invalid settings no longer results in the obtuse "An
   unexpected error occurred" with backtrace and exception data obscuring the
   issue. Instead, a simple message is emitted indicating that the settings are
   invalid along with the originating exception's message.
 - The various settings implementations share a common logger, instead of each
   implementation class providing its own. This is aimed to reduce noise from
   the logs and to ensure specs validating logging do not need to tie so
   closely to implementation details.

* settings: add password-wrapped setting

* settings: make any setting type capable of being nullable

* settings: add `Settings#names` to power programatic iteration

* cli: route CLI-flag deprecations in to deprecation logger

* settings: group API-related settings under `api.*`

retains deprecated aliases, and is fully backward-compatible.

* webserver: cleanup orphaned attr accessors for never-set ivars

* api: pull settings extraction down from agent

This net-no-change refactor introduces a new method `WebServer#from_settings`
that bridges the gap between Logstash settings and Puma-related options, so
that future additions to the API settings don't add complexity to the Agent.

It also has the benefit of initializing the API Rack App and just ONCE, instead
of once per attempted HTTP port.

* api: add optional TLS/SSL

* docs: reference API security settings

* api: when configured securely, bind to all available interfaces by default

* cleanup: remove unused cert artifacts

* tests: generate fresh webserver certificates

* certs: actually add the binary keystores 🤦
2021-10-19 14:13:20 -07:00
Andrea Selva
7395641a43
Fixes to build and run Logstah on JDK 17 (#13306)
This commit applies all the changes needed to run Logstash on JDK 17:
- opens access to module java.base for packages sun.nio.ch and java.io to run the application and to execute the tests
- removes SecurityManager classes used during Logstash startup
- fix exception type catched in JavaKeyStore tampering test

Related to meta issue #13306
2021-10-18 11:13:26 +02:00
Rob Bavey
7178890f41
Fix Elasticsearch integration test to use specified JDK (#13316)
Sets `LS_JAVA_HOME` of the spawned logstash to use the same `java.home`
that the test is running under, rather than default to the system JDK, which
would result in the spawned logstash running under a different JDK to that
intended in the test
2021-10-15 08:48:00 -04:00
João Duarte
f70350ba12
don't require mutate filter on remove_spec (#13292) 2021-10-13 11:08:20 +01:00
Rob Bavey
aa1aa8e37c
Fix kafka download link for integration tests (#13248) 2021-09-27 10:40:03 -04:00
Andrea Selva
d51afe54d5
Removed JAVA_HOME using only LS_JAVA_HOME (#13214)
Removes the usage of JAVA_HOME completely which is not anymore used for JDK path resolution.

Updated all the Logstash launching scripts to use only LS_JAVA_HOME as environment variable to
determine the JDK to use to launch Logstash. JAVA_HOME is abandoned for this job.
2021-09-15 09:29:07 +02:00
Andrea Selva
728289e862
Switched to Gradle 7 (#13184)
This commit:
- Updates the Gradle wrapper to version 7.2
- Remove the deprecated jcenter and where it was used to retrieve Gradle's plugins it switches to gradlePluginPortal
- Insert an explicit dependency from test task to the log4j.properties manipulation task ("copyProductionLog4jConfiguration") used in integration
2021-09-08 10:42:13 +02:00
Andrea Selva
979ea21c5e
Introduce LS_JAVA_HOME environment variable (#13204)
This commit modifies the launch scripts to take care of the LS_JAVA_HOME giving precedence over the JAVA_HOME, which is still used it the first is not found.
2021-09-06 10:22:51 +02:00
Karol Bucek
51fad3f56b
Test: improve monitoring api logging asserts (#13164) 2021-08-25 17:16:52 +02:00
Andrea Selva
7d8a716cf0
Update releases list (#13149)
Update releases list, aligning with 7.14.0 and 6.8.18. With ES 7.14.0 and security on by default, this PR alsoswithed off security on ES in integration tests
2021-08-20 08:24:58 +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
Ry Biesemeyer
6032e5ff64
ispec: fix cross-spec leak from fatal error integration specs (#13002)
Because the "Fatal Error" specs specifically inject fatal errors during
execution, and do so by reacting to a "poison" event, the fatal error prevents
the poison event from being ACK'd in the underlying queue.

By specifying a one-off temporary data directory in these specs and cleaning up
after ourselves, we ensure that a PQ containing un-ACK'd events isn't leaked to
the next spec to run.
2021-06-21 08:14:25 -07:00
João Duarte
7390b64a93
update fpm to allow pkg creation on jdk11+jruby 9.2 (#13005)
* fpm to 1.13.0 which allows building packages with java 11 + jruby 9.2
* childprocess to 4.x + remove monkey patches
* clamp to 1.x to unlock fpm 1.13.0
2021-06-21 14:39:27 +01:00
Andrea Selva
1d6a3e4bb3
Fix/log4j routing to avoid create spurious file (#12965)
Avoid the creation of log4j routing appender for log events without the `pipeline.id` fishtag. 
In this way no spurious log file named "pipeline_${ctx:pipeline.id}.log" and logs are not duplicated with main Logstash log file.
2021-06-16 09:41:30 +02:00
Andrea Selva
a0774c4e76
Explicitate the type of log format in appender's names (#12964)
Remove an useful dynamic creation of appender's log file which leverages the `log.format` property 
also when it's explicit by the appender itself.

Log4j configuration leverages the placeholder `${sys:ls.log.format}` to compose the name of the log file.
This generates some not evident conflicts in log4j internals, these conflicts became evident when enabling the `pipeline.separate_logs` feature is enabled and the log4j appender definitions contains both json and plain format.
The problem is that under those circumstances the rollover of the log file doesn't happen.

This commit also add a test against the production log4j configuration, to avoid future regressions.
2021-06-15 11:25:08 +02:00
Andrea Selva
fa9adb4b86
Use the JVM specified in the CI matrix environment also to run spawned proccesses (#12945)
logstash-keystore integration tests spawn a Java process, which by default uses the system JDK generally exposed with JAVA_HOME environment variable. It could be that this JDK is not the one selected with the build system variable BUILD_JAVA_HOME.
This commit uses the JDK defined in BUILD_JAVA_HOME if present.

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2021-06-01 12:32:47 +02:00
João Duarte
3e0c61a4fc
fix DLQ integration tests (#12871)
* do not rely on default index and template in dlq integration test
* ensure ES is started in single node mode
2021-05-06 13:56:35 +01:00
Andrea Selva
90a4f55a10
Fix ES HOW integration tests on master (#12872)
Disable datastreams and provide explicit index name to avoid automatically creation of datastreams in ES > 8.0.
Same as in PR #12871
2021-05-06 14:23:39 +02:00
Karol Bucek
c698aa224b
Test: let's do the cleanup for every test (#12805) 2021-04-08 18:03:55 +02:00
Karol Bucek
e8e393bdc7
Fix: logstash-keystore failing with an error (#12784)
* Fix: missing password dependency require

which causes `bin/logstash-keystore` to fail with an error:
```
ERROR: Failed to load settings file from "path.settings". Aborting...
path.setting=/logstash-7.12.0/config, exception=NameError,
message=>uninitialized constant LogStash::Util::Password

```

* Fix: review all LS parts depending on Password

* Test: bin/logstash-keystore create/list
2021-04-08 08:10:36 +02:00
Rob Bavey
0873ed6649
Fix Elasticsearch/DLQ integration test flakiness (#12685)
This commit fixes up some IT flakiness which has been presenting mostly
in recent DLQ test failures, it includes the following improvements:

 * A recent change to Elasticsearch has required the cluster setting
`action.destructive_requires_name` to be set to `false` to enable the use
of destruction actions with wildcards. This commit sets this before
tests on Elasticsearch and DLQ tests
 * Adds some extra safety to the `have_hits` rspec matcher
2021-02-22 10:44:59 -05:00
andsel
042d0d466b Make integration test fail if 'offline' tool can't be compiled 2021-02-18 01:36:18 -08:00
João Duarte
0337835f67
fix url for kafka and bump to 2.7.0 (#12617)
Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2021-01-29 17:34:18 +00:00
João Duarte
023e11a8e2
replace with_clean_env with with_unbundled_env (#12615) 2021-01-29 17:31:35 +00: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
Karol Bucek
3faa83f5b3
Fix: make sure LS exits when running into fatal errors (#12470)
Currently, LS does not respect fatal errors such as java.lang.OutOfMemoryError and continues executing.

This is dangerous since JVM errors are a legitimate reason to halt the process and not continue processing.

Additionally:

-   make sure we log the full stack-trace on fatal errors
-   halt the JVM wout executing finalizers/hook (scissors on how ES handles uncaught exceptions)
-   also, we should now be aware of a potentially unexpectedly dying thread
2021-01-11 10:14:58 +01: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
Karol Bucek
4649a55a84
Build: properly isolate integration (test) env setup (#12361)
to avoid gems being resolved from the usual LS GEM_HOME

this is problematic for gems such as jruby-openssl which are loaded
during boot (by RGs/Bundler) and thus activated in Bundler from a
different GEM_HOME. if such gem is updated it won't end up being
install-ed in the --path location as it's found on the GEM_HOME!

+ Fix: gem conflict 1.3.6 required by core
this is due now isolating GEM_HOME on `bundle install --path`

+ Refactor: we do not need LS_GEM_HOME/PATH

+ avoid pinning jruby-openssl to 0.10.4

resolves GH-12299 (reverting GH-12300)
2020-10-19 17:32:01 +02: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
Rob Bavey
5c7d5ac8c0 Bundle JDK (AdoptOpenJDK 11) in Logstash artifacts (x86_64)
Create new artifacts with bundled JDK for the supported platforms on x86_64. Download JDK packages from AdoptOpenJDK site, the selected version is loaded from `versions.yml`.
Changed also the launch scripts to give precedence to JAVA_HOME, then fallback on bundled JDK if present, as last resource go to the system Java.

New artifacts produced with bundled JDK are:
- tar.gz with JDK for Linux and Darwin
- zip file for Windows
- dep and rpm
- Docker image

All artifacts without JDK are now postfixed with '-no-jdk' while the ones with JDK included has the architecture extension.

Covered with tests the touched parts

Co-authored-by: Rob Bavey <robbavey@users.noreply.github.com>
2020-09-23 08:18:31 -07: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
Rob Bavey
1c864b9974 Fix kafka setup scripts
This commit updates the kafka setup scripts to ensure that the kafka setup is clean between builds, by
setting an explicit zookeeper data directory to be cleaned each time, and correctly overriding `log.dirs`
instead of `log.dir` to ensure that the kafka logs are written and wiped in a consistent place each time,
which helps when using the non-immutable images used in arm64 tests.
2020-07-13 10:49:23 -07:00