Commit graph

164 commits

Author SHA1 Message Date
github-actions[bot]
d10aeef875
Fix empty node stats pipelines (#17185) (#17202)
Fixed an issue where the `/_node/stats` API displayed empty pipeline metrics
when X-Pack monitoring was enabled

(cherry picked from commit 86785815bd)

Co-authored-by: kaisecheng <69120390+kaisecheng@users.noreply.github.com>
2025-02-28 22:52:17 +00:00
github-actions[bot]
bb6c2fe468
CPM handle 404 response gracefully with user-friendly log (#17052) (#17098)
Starting from es-output 12.0.2, a 404 response is treated as an error. Previously, central pipeline management considered 404 as an empty pipeline, not an error.

This commit restores the expected behavior by handling 404 gracefully and logs a user-friendly message.
It also removes the redundant cache of pipeline in CPM

Fixes: #17035
(cherry picked from commit e896cd727d)

Co-authored-by: kaisecheng <69120390+kaisecheng@users.noreply.github.com>
2025-02-17 13:50:43 +00:00
Andrea Selva
a0378c05cb
[Backport 8.x] Reimplement LogStash::String setting in Java (#16576) (#16959)
Non clean backport of #16576 

----

Reimplements `LogStash::Setting::String` Ruby setting class into the `org.logstash.settings.SettingString` and exposes it through `java_import` as `LogStash::Setting::SettingString`.
Updates the rspec tests in two ways:
- logging mock is now converted to real Log4J appender that spy log line that are later verified
- verifies `java.lang.IllegalArgumentException` instead of `ArgumentError` is thrown because the kind of exception thrown by Java code, during verification.

* Fixed the rename of NullableString to SettingNullableString

* Fixed runner test to use real spy logger from Java Settings instead of mock test double
2025-01-27 16:08:51 +01:00
Andrea Selva
4201628f9e
Update depreacation warning to provide the version the ArcSight module is removed. (#16648) 2024-11-06 12:30:45 +01:00
Andrea Selva
396b3fef40
Deprecate for removal ArcSight module (#16551)
Logs a deprecation when Logstash 8.x is started with ArsSight module.

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2024-10-15 19:50:19 +02:00
kaisecheng
4677cb22ed
add modules deprecation log for netflow, fb_apache and azure (#16548)
relates: #16357
2024-10-14 12:40:45 +01:00
github-actions[bot]
a1f4633b55
Backport PR #16525 to 8.x: [test] Fix xpack test to check for http_address stats only if the webserver is enabled (#16531)
* [test] Fix xpack test to check for http_address stats only if the webserver is enabled (#16525)

Set the 'api.enabled' setting to reflect the flag webserver_enabled and consequently test for http_address presence in settings iff the web server is enabled.

(cherry picked from commit 648472106f)

* Update also the global LogStash::SETTINGS's 'api.enabled' setting value becuase used in the constructor of StatsEventFactory and needs to be in synch with the settings provided to the Agent constructor

---------

Co-authored-by: Andrea Selva <selva.andre@gmail.com>
2024-10-11 15:24:11 +02:00
João Duarte
90f303e401
fix line used to determine ES is up (#16349) 2024-07-24 16:48:42 +02:00
Ry Biesemeyer
801f0f441e
Geoip database management cache invalidation (#16222)
* geoip: failing specs demonstrating elastic/logstash#16221

* geoip: invalidate cached db state when receiving updates/expiries
2024-06-18 15:11:25 -07:00
Ry Biesemeyer
9e452d2e54
Update junit 4 13 (#16138)
* test-deps: update junit to latest 4.13

* test-deps: address deprecation of ExpectedException

* test-deps: use org.junit.Assert.assertThrows
2024-05-03 13:49:16 -07:00
Ry Biesemeyer
483059e378
geoip: avoid crash cleaning non-existing managed dbs (#15986)
* geoip: avoid crash cleaning non-existing managed dbs

* Update x-pack/spec/geoip_database_management/manager_spec.rb

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>

---------

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2024-03-11 11:56:51 -07:00
Mashhur
19637143e6
Fix the Bootstrap check test failure on Windows. (#15975) 2024-03-06 10:10:35 -08:00
Dimitrios Liappis
be3f75e346
Clean up left over scripts after CI migration (#15926)
Following the CI migration from Jenkins to Buildkite, this commit
removes a number of left over helper scripts that aren't needed
anymore.

Closes https://github.com/elastic/ingest-dev/issues/2850
2024-02-12 11:26:28 +02:00
Ry Biesemeyer
51886b9102
geoip: extract database manager to stand-alone feature (#15348)
* geoip: extract database manager to stand-alone feature

Introduces an Elastic-licensed GeoipDatabaseManagement tool that can be used
by ANY plugin running on Elastic-licensed Logstash to retrieve a subscription
to a GeoIP database that ensures EULA-compliance and frequent updates, and
migrates the previous Elastic-licensed code-in-Logstash-core extension to
the Geoip Filter to use this new tool, requiring ZERO changes to in-the-wild
versions of the plugin.

The implementation of the new tool follows the previous implementation as
closely as possible, but presents a new interface that ensures that a
consumer can ATOMICALLY subscribe to a database path without risk that the
subscriber will receive an update or expiry before it is finished applying
the initial value:

~~~ ruby
geoip_manager = LogStash::GeoipDatabaseManagement::Manager.instance
subscription = geoip_manager.subscribe('City')

subscription.observe(construct: ->(initial_dbinfo){ },
                     on_update: ->(updated_dbinfo){ },
                     on_expire: ->(       _      ){ })

subscription.release!
~~~

* docs: link in geoip database manager docs

* docs: reorganize pending 'geoip database management' feature

* docs: link to geoip pages from feature index

* geoip: add SubscriptionObserver "interface"

simplifies using Subscription#observe from Java

* geoip: fixup SubscriptionObserver after rename

* geoip: quacking like a SubscriptionObserver is enough

* geoip: simplify constants of legacy geoip filter extension

* geoip: bump logging level to debug for non-actionable log

* geoip: refine log message to omit non-actionable info

* re-enable invokedynamic (was disabled to avoid upstream bug)

* geoip: resolve testing fall-out from filter extension's "private" constants removal

* geoip: consistently use `DataPath#resolve` internally, too
2023-11-06 09:22:23 -08:00
Andres Rodriguez
64ddec5c9d
Fix a few lint format issues
Fix lint issues found by 'rake lint:format'
2023-10-10 09:00:54 -04:00
kaisecheng
6b2fa20622
disable xpack API and monitoring pipeline for serverless (#15277)
This commit adds a call to identify serverless cluster before fetching `/_xpack` to verify the license and supported features.
When it is serverless, the license checker uses hardcoded xpack info instead of calling xpack API. The internal pipeline of monitoring is disabled and logs error when configured to use legacy monitoring.

Fixes: 
ingest-dev#2303
ingest-dev#2284

Co-authored-by: Rob Bavey <rob.bavey@elastic.co>
2023-08-31 17:00:13 +01:00
Andres Rodriguez
cf67cb1377
Rubocop: Enable most SpaceInside cops (#15201)
Enabled:
* SpaceInsideArrayLiteralBrackets
* SpaceInsideParens
* SpaceInsidePercentLiteralDelimiters
* SpaceInsideStringInterpolation
* Add enforced style for SpaceInsideStringInterpolation

Enabled without offenses:
* SpaceInsideArrayPercentLiteral
* Layout/SpaceInsideRangeLiteral
* Layout/SpaceInsideReferenceBrackets
2023-07-20 09:49:46 -04:00
Andres Rodriguez
2165d43e1a
Rubocop: Enable SpaceBefore cops (#15197)
Enables the following cops:

 * Layout/SpaceBeforeBlockBraces
 * Layout/SpaceBeforeBrackets
 * Layout/SpaceBeforeComma
 * Layout/SpaceBeforeComment
 * Layout/SpaceBeforeFirstArg
 * Layout/SpaceBeforeSemicolon
2023-07-18 22:32:17 -04:00
Andres Rodriguez
4255a8fd1c
Rubocop: Enable SpaceAround cops (#15196)
* Enable SpaceARoundBlockParameters
* Enable SpaceAroundEqualsInParameterDefault
* Enable SpaceAroundKeyword
* Enable SpaceAroundOperators
* Enable SpaceBeforeBlockBraces, which yields no changes
2023-07-18 21:11:57 -04:00
Andres Rodriguez
acd87a69e7
Rubocop: Enable various EmptyLine cops (#15194)
Disabled:
 * EmptyLineAfterGuardClause
 * EmptyLineAfterMultilineCondition
 * EmptyLinesAroundAccessModifier

Enabled:
 * Layout/EmptyLineAfterMagicComment
 * Layout/EmptyLineBetweenDefs
 * Layout/EmptyLines
 * Layout/EmptyLinesAroundArguments
 * Layout/EmptyLinesAroundAttributeAccessor
 * Layout/EmptyLinesAroundBeginBody
 * Layout/EmptyLinesAroundBlockBody
 * Layout/EmptyLinesAroundExceptionHandlingKeywords
 * Layout/EmptyLinesAroundMethodBody
 * Layout/EmptyLinesAroundModuleBody
2023-07-18 16:49:16 -04:00
Andres Rodriguez
d95a0bba74
Fix deprecated ERB and BigDecimal instances (#15189) 2023-07-18 08:48:01 -04:00
Andres Rodriguez
1d558c35d0
Fix instances of deprecated class methods (#15183)
Replace ::File.exists? for ::File.exist?
2023-07-17 11:32:46 -04:00
Andres Rodriguez
b63ffea472
Enable SpaceAfterColon, SpaceAfterComma, SpaceAfterSemicolon (#15180)
Enable SpaceAfterColon, SpaceAfterComma, SpaceAfterSemicolon and fix occurrences.
2023-07-14 16:46:35 -04:00
Andres Rodriguez
26ff2f7db9
Enable Style/TrailingEmptyLines and fix ocurrences (#15179) 2023-07-14 14:46:33 -04:00
Andres Rodriguez
5e34aacc6e
Enable trailing whitespace formating (#15174)
* Enable Layout/TrailingWhitespace cop formation
* Remove Trailing Whitespaces
2023-07-14 13:22:02 -04:00
Andrea Selva
26d1c7ccdb
Update to JRuby 9.4 (#14861)
Set of changes to make Logstash compatible to JRuby 9.4.
Bundle JRuby 9.4.3.0

- Redefine space token in `LSCL`  and `grammar` treetop from `_` which would generated methods in the form `def _0` (deprecated since `2.7`) to `sc`.
- `I18n.t` method doesn't accept hash as second argument
- `URI.encode` has been replaced with same functionality with `URI::Parser.new.escape`
- `YAML.load` needs explicit `fallback: false` to return false when the yaml string is empty (or contains only comments)
- JRuby's  `JavaClass` has been removed, now it can use `java.lang.Class` directly
- explicitly require gem `thwait` to satisfy `require "thwait"` (In `Gemfile.template` and `logstash-core/logstash-core.gemspec`)
- fix not args `clone` to be `def clone(*args)`
- fix `Enumeration.each_slice` which from `Ruby 3.1` is [chainable](https://rubyreferences.github.io/rubychanges/3.1.html#enumerableeach_cons-and-each_slice-return-a-receiver) and doesn't return `nil`. JRuby fixed in https://github.com/jruby/jruby/issues/7015
- Expanded `Down.download` arguments map ca16bbed3c302006967413eb9d3862f2da81f7ae
- Avoid to pass `nil` in the list of couples used in `Hash[ <list of couples> ]` which from Ruby `3.0` generates an `ArgumentError`
- Removed space not allowed between method name and parentheses `initialize (` is forbidden. 29b607dcdef98f81a73ad171639fd13aaa65e243
- With [Ruby 2.7 the `Kernel#open`](https://rubyreferences.github.io/rubychanges/2.7.html#network-and-web) doesn't fallback to `URI#open`, fixed test code that used that to verify open port. e5b70de54c5301f51a767da67294092af0cfafdc
- Avoid to drop `rdoc/` folder from vendored JRuby else `bin/logstash -i irb` would crash, commit b71f73e9c6edb81a7b7ae1305047e506f61c6e8c

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2023-06-28 13:05:43 +02:00
Edmo Vamerlatti Costa
e76e582086
Add missing Elasticsearch SSL settings and replace deprecated options (xpack.monitoring and xpack.management) (#15045)
This commit adds missing Elasticsearch SSL settings and replaces deprecated options being used on `xpack.monitoring.*` and `xpack.management.*` settings:

Changes:
- Updated deprecated monitoring and management Elasticsearch's SSL settings so no warnings are logged.
- Added monitoring settings support for file-based certificates and for the cipher suites: `xpack.monitoring.elasticsearch.ssl.certificate`, `xpack.monitoring.elasticsearch.ssl.key`, and `xpack.monitoring.elasticsearch.ssl.cipher_suites`.
- Added management settings support for file-based certificates and for the cipher suites: `xpack.management.elasticsearch.ssl.certificate`, `xpack.management.elasticsearch.ssl.key`, and `xpack.management.elasticsearch.ssl.cipher_suites`.
2023-05-15 11:54:38 +02:00
Edmo Vamerlatti Costa
e4dc82a9b3
Add setting to disable the GeoIP database downloader (#14823)
This commit adds a new logstash.yml setting "xpack.geoip.downloader.enabled" to disable the GeoIP databases auto-update feature. When disabled, Logstash will fall back to the CC database license indefinitely and delete any previously downloaded EULA databases.

Closes #14724
2023-01-05 15:46:35 +01:00
João Duarte
90872fb6ff
ArcSight Module Broken (Invalid Type), Fixed (#13874)
The Module is broken with the current version. The Type needs to be changed from syslog to _doc to fix the issue.

* remove dangling setting and add arcsight index suffixes
* add tests for new suffix in arcsight module

Co-authored-by: Tobias Schröer <tobias@schroeer.ch>
2022-07-18 16:56:24 +01:00
kaisecheng
eea655b8c9
Fix flaky geoip test (#14329)
* Fix flaky geoip tests
* update ruby version

Fixed: #14325
2022-07-06 10:57:33 +01:00
Ry Biesemeyer
7757908c34
Add ca_trusted_fingerprint to core features (monitoring/central-management) (#14155)
* add `ca_trusted_fingerprint` to core features (monitoring/central-management)

* Rely on released ES output

* fix: ensure commented-out examples in logstash.yml are functionally correct

* add admonition for how to get a trusted CA's fingerprint
2022-06-28 17:07:59 -07:00
Karol Bucek
989f9e7937
Deps: un-pin (and avoid) rufus-scheduler (#14260)
+ Refactor: specific require + scope java_import
+ Refactor: redundant requires
+ Refactor: avoid rufus - hook up a timer task
2022-06-21 12:26:03 +02:00
Karol Bucek
433b341f0f
Refactor: avoid loading polyglot (#14175)
* Refactor: require treetop/runtime - avoids loading polyglot
* Build: instruct Bundler not to auto-load polyglot/treetop

+ Build: these deps are properly required as needed
all of them only used in one place (outside of normal bootstrap)
2022-06-07 08:28:56 +02: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
Mashhur
33328955c4
[CPM] Fetch pipelines with wildcard IDs from ES and apply. (#14076)
* [Central Pipeline Management] Fetch pipelines with wildcard IDs from ES and apply. #14076

* URL encoding applied, code review feedbacks taken: unit test case for getting es version API and separate method for ES wildcard support.
2022-05-17 16:08:53 -07:00
kaisecheng
1c851bb15c
Fix geoip database download does not respect http_proxy setting (#14048)
This commit adds `http_proxy` to geoip database download option to respect proxy setting

Fixed: #14047
2022-04-29 15:25:28 +01:00
Andrea Selva
916ddf2c8d
Fix/flaky error tests in missed retries to central management (#13941)
This commit is a forward port of #13925.
Covered all calls to ES with retryable when accessing the central management to query the pipelines configurations.
2022-03-28 16:30:31 +02:00
Andrea Selva
c544ecb380
Update failing policy in Central Management fetcher and license checker if hit ES down node (#13689)
Wraps the calls to the central management Elasticsearch cluster with the utility class Stud::Try to handle the remote host error when the client used to connect hit a not available node.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2022-03-23 14:37:03 +01:00
Ry Biesemeyer
022072c437
geoip-db: support http_proxy environment variable (#13410) 2022-03-04 08:32:17 -08: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
Ry Biesemeyer
2892964ba1
Product origin headers to Logstash-controlled Elasticsearch clients (#13563)
* add product origin header to license checks

* add origin header to Central Management config fetcher

* add origin header to ES output for Monitoring pipeline
2022-01-14 06:31:42 -08:00
kaisecheng
7d5c5f09d3
Fix unknown type warning of geoip metrics (#13382)
This commit changes the value of the geoip metric from Symbol to String to remove warning and refactors metrics part

Fixed: #13197
2022-01-11 11:16:43 +00:00
Andrea Selva
88c80ebb19
Fixes a usage of deprecated 'http.enabled' to the new 'api.enabled' (#13380)
With #13308 configuration namespace that started with `http.` was renamed to `api.`, this commit fix a usage left behind.
Use the new `api.enabled` setting in one place instead of the deprecated `http.enable`.

Co-authored-by: Ry Biesemeyer <yaauie@users.noreply.github.com>
2021-11-15 09:49:15 +01:00
João Duarte
4919286e42
rename references of master branch to main branch (#13301) 2021-11-08 10:23:46 +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
kaisecheng
6b9d2169d1
Replace Faraday to Manticore to get rid of jruby-openssl verification error of Let's Encrypt cross-signed DST Root CA X3 (#13273)
Fixed: #13278
2021-10-06 10:09:49 +02:00
kaisecheng
1913de1bf7
update golang image to 1.17.1(#13260)
update golang image to 1.17.1 to get rid of expired DST Root CA X3
disable download manager test cases to silent Faraday::SSLError

Fixed: #13261

Co-authored-by: João Duarte <jsvd@users.noreply.github.com>
2021-10-01 18:51:09 +02:00
kaisecheng
8c83282bae
geoip integrate air-gapped bootstrap script (#13104)
This PR integrates Elasticsearch bootstrap script to help users keep Logstah geoip plugin run without online update check.
Add `xpack.geoip.download.endpoint` option to config geoip database service endpoint.
Users can point to `http://localhost:8080/overview.json` when using the script to bootstrap nginx docker
2021-09-27 18:56:22 +02:00