Commit graph

90 commits

Author SHA1 Message Date
github-actions[bot]
a58abbb5a4
CPM handle 404 response gracefully with user-friendly log (#17052) (#17097)
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:25 +00:00
Andrea Selva
03b11e9827
Reimplement LogStash::String setting in Java (#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.
2025-01-24 16:56:53 +01:00
kaisecheng
05789744d2
Remove the Arcsight module and the modules framework (#16794)
Remove all module related code
- remove arcsight module
- remove module framework
- remove module tests
- remove module configs
2024-12-19 14:28:54 +00:00
Andrea Selva
d4fb06e498
Introduce a new flag to explicitly permit legacy monitoring (#16586)
Introduce a new flag setting `xpack.monitoring.allow_legacy_collection` which eventually enable the legacy monitoring collector.

Update the method to test if monitoring is enabled so that consider also `xpack.monitoring.allow_legacy_collection` to determine if `monitoring.*` settings are valid or not.
By default it's false, the user has to intentionally enable it to continue to use the legacy monitoring settings.


---------

Co-authored-by: kaisecheng <69120390+kaisecheng@users.noreply.github.com>
Co-authored-by: Karen Metts <35154725+karenzone@users.noreply.github.com>
2024-11-19 08:52:28 +01:00
kaisecheng
b571e8f3e3
remove deprecated modules netflow, fb_apache and azure (#16514)
This commit removes files related to netflow, fb_apache and azure modules
Fix: #16357
2024-10-15 14:03:53 +01:00
Andrea Selva
6064587bc4
Keeps global settings aligned across entities used in the test for StatsEventFactory
Fixes a potential flaky test, due to shared (LogStash:SETTINGS) fixture across the test base.


Forward port the commit 609155a61b used to fix the non clean backport PR #16531 of #16525 to 8.x.

LogStash:SETTINGS is used in the constructor of LogStash::Inputs::Metrics::StatsEventFactory to query the value of api.enabled. This PR keeps updated the value for the setting provided to the Agent constructor and to the StatsEventFactory.
2024-10-11 15:26:53 +02:00
Andrea Selva
648472106f
[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.
2024-10-10 18:57:34 +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
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
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
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
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
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
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
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
kaisecheng
827bbd9270
fix geoip external DB shutdown nil exception (#13224)
Fixed: #13208
2021-09-15 14:42:28 +01:00
kaisecheng
5a209ba830
Add geoip database metrics to /node/stats API (#13004)
This PR adds geoip database status, last update timestamp, download stats counter to Node Stats API
2021-06-23 17:35:15 +02:00
Ry Biesemeyer
49e6b0e010
Allow per-pipeline config of ECS Compatibility mode via Central Management (#12861)
* spec: noop refactor of xpack central management

* spec: validate central management settings loading

* central management: allow pipeline.ordered and pipeline.ecs_compatibility settings
2021-06-17 13:59:53 -07:00
kaisecheng
42c4bbab9f
fix database manager with multiple pipelines (#12862)
This PR adds support to geoip multiple pipelines which have a single instance
to manage database download to avoid individual download per pipeline
2021-06-17 00:19:24 +02:00
kaisecheng
e60340ad08
Geoip disable database manager (#12905) 2021-05-12 19:47:22 +02:00
kaisecheng
03fb24bd54
Geoip use cc indefinitely (#12888)
This PR allows using CC database indefinitely if Logstash hasn't used EULA database ever
Fixed: #12859
2021-05-11 17:30:18 +02:00
kaisecheng
76bff0aa91
change download path for geoip plugin (#12863)
The database was downloaded in plugin/vendor
This PR changes the working directory to `path.data`
2021-05-04 11:03:31 +02:00
kaisecheng
08f758c028
GeoIP database copy all files from .tgz alongside database (#12824)
This PR changes the behavior of copying license files from .tgz
Originally, only two files, MaxMind LICENSE.txt and COPYRIGHT.txt, are required
Now more files, README.txt and Elastic ToC, are potentially required
Instead of targeting the files, this change copies all content in .tgz
2021-04-15 14:35:18 +02:00
kaisecheng
ca76c0c484
GeoIP database add license files (#12756)
GeoIP database service provides LICENSE.txt and COPYRIGHT.txt 
along with the database in .tgz

Fixed: #12560
2021-03-25 19:34:19 +01:00
Ry Biesemeyer
d5becc0082
internal-monitoring: use configured ssl verification mode (#12749)
Upstream `ElasticsearchOptions#es_options_from_settings` already uses the
setting `elasticsearch.ssl.verification_mode` to produce an appropriate
boolean-valued `ssl_certificate_verification` in our `es_settings` hash, so
we can rely on it instead of re-checking equality with a string.
2021-03-16 10:02:05 -07:00