Commit graph

440 commits

Author SHA1 Message Date
Aaron Mildenstein
f443dae5fe Merge feature/modules into master (#7284)
* My changes (#7218)

* First upstream PR commit (#7172)

No tests yet.  Just for code review for now

* move all inner classes to their own folder + client and importer

* Fixes and tests (#7228)

Add tests for the `LogStash::Modules:CLIParser` class in `cli_parser.rb`
Fix a typo in `cli_parser.rb` (`uparsed` vs `unparsed`)
Fix a bad variable name found by testing in `cli_parser.rb` and update the error message accordingly in `en.yml`

* Remove fb_modules (#7280)

* fixes to import index-pattern & var updates & savedsearch capability (#7283)

* fixes to import index-pattern & var updates & savedsearch capability

fixes to import index-pattern & var updates

add savedsearch capability

* minimise merge conflicts with PR End-to-End test with filebeat apache2

* End-to-End test with filebeat apache2 (#7279)

This is a first run, but data flows from filebeat through Elasticsearch.

Template uploads from `$LS_HOME/modules/MODULENAME/configuration/elasticsearch/MODULENAME.json`

Specifying `--modules filebeat` from the command-line, with `-M "filebeat.var.elasticsearch.output.host=localhost:9200"`

Some of the saved searches don't get uploaded. @guyboertje is on this already.

The logstash configuration needs tweaking to allow receiving both access logs _and_ error logs.  The dashboards and visualizations all seem to expect the presence of both.

Set default to `localhost` in `elasticsearch_client.rb`

Changed command-line variable parsing to allow for a variable with only `modulename.key.subkey=value`, and updated the error message accordingly.

First draft of the filebeat module, as extracted from filebeat 5.4.0

* Add documentation for Modules

This is specific to the Master branch.  Multiple modules will not be supported in 5.5.

* Add READMEs and prune post-code comments

* Add comment regarding the variable name `modul`

Also, fix the default username for the Elasticsearch output in Logstash.  The default x-pack credentials are `elastic:changeme` rather than `elasticsearch:changeme`

* add cef module files (#7292)

* fixes from reviews of PR #7284
2017-06-05 18:49:35 +01:00
Armin
1ba335e329 MINOR: Cleanup imports on compiler.rb and pipeline.rb
Fixes #7297
2017-06-03 07:08:04 +00:00
Armin
01b812b5cf MINOR: Fix missing static identifiers and save some memory
Fixes #7261
2017-06-02 22:07:53 +00:00
Andrew Cholakian
280722ea70 Make SafeURI 9k compatible by using java.net.URI internally
Ruby 2.0's stdlib no longer allows relative IPv6 URLs like: //[::1]
This is a key feature of the Elasticsearch output. See more in
https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/604

The only way to fix this is to use a better URI class which means
introducing a slight incompatibility here. I don't believe that anyone
is using the URI class other than the ES output, and I don't that there
is anyone using any portions of the API here that are no longer
compatible.

Normally we would only make such a change in a major version, but our
hands are tied here. If we are to go with JRuby 9k, which is critical
for support we must use a different, better, library.

java.net.URI is stable and works well, so its probably superior in the
long run anyway.

Fixes #7236
2017-06-02 20:52:27 +00:00
Suyog Rao
e01d247d5e revert to alpha2 until we release 2017-05-31 08:41:12 -07:00
Suyog Rao
23604c13c1 bump version to 6.0.0-beta1 (#7278) 2017-05-31 08:39:13 -07:00
Armin
b65f737bfd MINOR: Remove duplicate hash keys
Fixes #7263
2017-05-30 09:33:53 +00:00
Joao Duarte
bed8b8a084 support multiple pipelines in one logstash instance
* add multi_local source for multi pipelines
* introduce pipelines.yml
* introduce PipelineSettings class
* support reloading of pipeline parameters
* fix pipeline api call for _node/pipelines
* inform user pipelines.yml is ignored if -e or -f is enabled
2017-05-30 09:47:53 +01:00
Andrew Cholakian
9ce6963094 Further improve pipeline thread safety
Fixes #7230

Further improves on the threadsafety improvements in #7206

This commit fixes various tests to access the Agent#pipelines property
in a fully threadsafe way.

Fixes #7233
2017-05-26 16:33:48 +00:00
Andrew Cholakian
b103e3fc97 Make access of Agent#pipelines threadsafe
Universal plugins may access the #pipelines property of the agent.
This PR makes accessing it in a threadsafe way possible with a
`with_pipelines` helper function in Agent.

This uses a reentrant lock since its anticipated that users may want to
nest calls here. A ruby Mutex is not reentrant, so that won't work.

Fixes #7206
2017-05-25 13:52:02 +00:00
Rob Bavey
7537b62c8d Fix NoMethodError when Stack Trace is empty
Adds :traces to hash even if traces are empty.

Fixes #7174

Fixes #7175
2017-05-22 13:02:17 +00:00
Rob Bavey
3e13b33e44 Move code from JRmonitor into logstash-core #6337
Java code is mostly the same as that from the JRMonitor gem with some general tidying and DRYing up
Report classes are now straight Java
Added junit tests for the Java monitor classes
Ruby code basically stays the same, other than calling out to pure Java report classes

Fixes #7167
2017-05-19 21:09:52 +00:00
Suyog Rao
cfecf81091 Only glob *.conf by default in conf.d folder (#7130)
* Only glob *.conf by default in conf.d folder

Fixes #6979, Fixes #1831
2017-05-19 11:26:10 -07:00
Pier-Hugues Pellerin
b00b7f9656 Prevent variable leak between test
When running this test with a newer version of rspec we got the warning
that some values where leaking between example:

```
 1) LogStash::ShutdownWatcher when pipeline is not stalled .unsafe_shutdown = false shouldn't force the shutdown
     Failure/Error: m.call(*args)
       The use of doubles or partial doubles from rspec-mocks outside of the per-test lifecycle is not supported.
     # ./logstash-core/lib/logstash/shutdown_watcher.rb:67:in `pipeline_report_snapshot'
     # ./logstash-core/spec/logstash/shutdown_watcher_spec.rb:22:in `block in /Users/ph/es/second/logstash/logstash-core/spec/logstash/shutdown_watcher_spec.rb'
     # ./logstash-core/lib/logstash/shutdown_watcher.rb:44:in `block in start'
     # ./vendor/bundle/jruby/2.3.0/gems/stud-0.0.22/lib/stud/interval.rb:20:in `interval'
     # ./logstash-core/lib/logstash/shutdown_watcher.rb:42:in `start'
     # ./logstash-core/spec/logstash/shutdown_watcher_spec.rb:93:in `block in (root)'
```

We have added a few helpers method in the class that allowed us to
simplify the expectation and removed any usage of `Thread#kill`

Fixes #7152
2017-05-18 17:07:23 +00:00
Andrew Cholakian
879451c964 Remove `mean' metric type.
The central problem with recording a mean stat is that on a non-realtime
system you can't guarantee that samples were evenly spaced out. A series
of timestamped gauges does a better job. This is what we can do in our
x-pack monitoring extension, but not something we should do in core. The
central difference is that x-pack has Elasticsearch, which can act as a
time series database. I'd prefer not to build a tsdb into logstash. That
would obviously involve a lot of complexity.

Fixes #7094.

Fixes #7105
2017-05-16 17:45:10 +00:00
Armin
83a8603284 6785 interpolate settings after flattening settings hash
Fixes #7072
2017-05-11 18:40:13 +00:00
Armin
9f1d889c27 #6785 Interpolate ENV into settings read from logstash.yml
Fixes #7072
2017-05-11 18:40:13 +00:00
Joao Duarte
d17a77e76d bump version to 6.0.0-alpha2 2017-05-11 18:18:29 +01:00
Andrew Cholakian
623fe51474 Rename Pipeline -> PipelineIR + Fix PipelineIR concatenation
This PR helps enable https://github.com/elastic/logstash/issues/7076

This also fixes a bug where when concatenating pipelines for PipelineIR
the to_s versions of the SourceWithMetadata objects were conjoined
instead of just the `text`.

Fixes #7079
2017-05-11 17:11:47 +00:00
Joao Duarte
cad59d9304 fix a few racing conditions in the agent_spec
Fixes #7066
2017-05-11 09:17:32 +00:00
Andrew Cholakian
2b4afea696 Add original source metadata to LIR pipeline
This is a temporary change until we have LIR execution. This allows the
LIR Pipeline object to be the only object passed into the ruby Pipeline.
The ruby Pipeline needs the source to parse the file into the legacy AST
format.

Fixes #7055
2017-05-10 17:58:26 +00:00
Andrew Cholakian
804788c7fe Compile multiple sources together into one LIR pipeline
This sets us up to correctly set the protocol / metadata fields for LIR
pipelines and work on the refactor mentioned in https://github.com/elastic/logstash/issues/7054

Fixes #7055
2017-05-10 17:58:25 +00:00
Tal Levy
458910bcb9 Introduce DeadLetterQueue to the Execution Context (#6894)
* Introduce a DeadLetterQueueFactory

DeadLetterQueueFactory is a static class that keeps
a static collection of DeadLetterQueueWriteManagers per
pipeline that has plugins requesting to use it.

* DeadLetterQueue was added as a first-class field in the execution context that input/filter/output plugins can leverage
2017-05-09 14:40:59 -07:00
João Duarte
db2c85c5e9 only auto complete config.string (#6974)
this means the configuration read from path.config (-f) is no longer auto completed with stdin/stdout if the input/output sections are missing. This behaviour will only occur with config.string (-e).
2017-05-09 17:30:16 +01:00
João Duarte
07194b830f make e and f flags mutually exclusive (#6976) 2017-05-09 16:42:32 +01:00
Andrew Cholakian
3658c94e9b Refactor SourceLoader to no longer be a singleton.
This cleans up the code from a design patterns standpoint and makes testing plugins easier since you can just create/destroy agents at will.

Without this change the SOURCE_LOADER singleton's state will become dirty as agents are created/destroyed and be problematic.

Fixes #7048
2017-05-09 00:00:02 +00:00
Armin Braun
9f2ce5d164 #6518 rebased and adjusted naming
Fixes #7010
2017-05-04 09:03:26 +00:00
Pier-Hugues Pellerin
7bc91b7ceb Adding guards on the SourceLoader#fetch
When the fetch is call we are aggregating all the pipeline_config from
the different sources, if we encounter duplicates ids we will return a
failure, making the pipeline skip that fetch.

Fixes #6866
2017-05-03 21:45:57 +00:00
Pier-Hugues Pellerin
17b2218565 Allow to ask the registry to get a list of plugin klass of a specific type
This expose some of the internal of the registry to the outside world to
allow other part of the system to retrieves plugins.

This change was motivated by #6851 to retrieve the installed list of
modules.

Fixes #7011
2017-05-03 21:43:57 +00:00
TAC
f5fb4b3f9f Fix missing log4j2.properties file on Windows
fix Issue #6352

On Windows, Logstash can't find log4j2.properties file with above message at startup.
```
Could not find log4j2 configuration at path /LS_HOME/config/log4j2.properties.
```

Fixes #6903
2017-05-03 19:30:42 +00:00
Andrew Cholakian
28e51f5c6a Unify ConfigPart and SourceMeta into SourceWithMetadata
This unifies the two different config classes that represented mainly
the same data. While this does expose a plain java class into ruby
this works fine because ruby only needs to access and set values, not
work with ruby return types.

Fixes #7003

Fixes #7004
2017-05-02 13:31:06 +00:00
Armin Braun
01b4144dfe #4324 streamline behaviour of Timestamp.== and Timestamp.eql?
Fixes #7002
2017-05-02 10:45:27 +00:00
Josh Soref
3344b00404 spelling: successfully
Fixes #6969
2017-04-28 17:38:44 +00:00
Josh Soref
0b8ed01dd1 spelling: implicitly
Fixes #6969
2017-04-28 17:38:44 +00:00
Pier-Hugues Pellerin
926e6b9e59 Keep track of the original response of the pipeline_action's execute
This commit is to provide more information when an action fails and will
allow us hopefully to debug a random failure in the test suite for the
environment variable.

ref: #6978

Fixes #6982
2017-04-27 13:05:59 +00:00
Pier-Hugues Pellerin
ab4794375e rename the method to running_user_defined_pipelines instead of user_defined_pipelines
Fixes #6885
2017-04-26 21:07:59 +00:00
Pier-Hugues Pellerin
8ecbdf22b3 expose #user_defined_pipelines so we can use it from an input plugin
Fixes #6885
2017-04-26 21:07:59 +00:00
Pier-Hugues Pellerin
3eaf208c1d fix the execute steps
Fixes #6885
2017-04-26 21:07:58 +00:00
Pier-Hugues Pellerin
a2bfcd85d3 Make sure we start system pipeline before normal pipeline
PipelineAction now have an `execution_priority`, we use this method to change the priority of a create action when we are creating a system pipeline

Fixes #6885
2017-04-26 21:07:58 +00:00
Pier-Hugues Pellerin
094fe10c6a Allow Finite pipeline to shutdown internal pipelines
With the creation of the x-pack we have added our first internal
pipeline, but if you were running the monitoring pipeline with a
*finite* pipeline (LIKE generator count => X) when the finite has
completed processing all the events logstash would refuse to stop.

This PR fixes the problem by adding a new pipeline settings called
`system` in the shutdown loop we will check if all the user defined
pipeline are completed if its the case we will shutdown any internal
pipeline and logtash will stop gracefully.

Fixes #6885
2017-04-26 21:07:58 +00:00
Pier-Hugues Pellerin
e4eb28bd66 Make the load_average linux more robust by allow to inject the content of the load_average file
Fixes: #6867

Fixes #6886
2017-04-19 19:45:11 +00:00
Andrew Cholakian
ab1cfe8cf7 Make pipeline and agent available through execution context
Fixes #6920
2017-04-18 20:04:38 +00:00
Pier-Hugues Pellerin
645fcec234 Refactor of the Agent class and the loading of the configuration
This PR introduces majors changes inside Logstash, to help build future
features like supporting multiple pipeline or java execution.

The previous implementation of the agent made the class hard to refactor or add new feature to it, because it needed to
know about too much internal of the pipeline and how the configuration existed.

The changes includes:
- Externalize the loading of the configuration file using a `SourceLoader`
- The source loader can support multiple sources and will aggregate them.
- We keep some metadata about the original file so the LIR can give better feedback.
- The Agent now ask the `SourceLoader` to know which configuration need to be run
- The Agent now uses a converge state strategy to handle: start, reload, stop
- Each actions executed on the pipeline are now extracted into their own classes to help with migration to a new pipeline execution.
- The pipeline now has a start method that handle the tread
- Better out of the box support for multiple pipeline (monitoring)
- Refactor of the spec of the agent

Fixes #6632
2017-04-14 11:42:00 +00:00
Pier-Hugues Pellerin
81cb825b89 Replace the internal list of listeners with a set
Because we sync listeners with emitters when adding or creating hook
this could lead to duplicates of listeners, this PR fixes the problem by using a set
instead of a list. Making sure we can only have one instance of a specific
listener at any time.

Fixes #6916
2017-04-13 20:09:20 +00:00
Joao Duarte
3494f1e68c pass namespaced metric to output plugin instance 2017-04-10 17:35:26 +01:00
Pier-Hugues Pellerin
0d1011980e ExecutionContext for the plugins
This PR add the initial building block to pass some `ExecutionContext`
from the pipeline to the plugin, currently we only pass the `pipeline_id`.

We use the accessor `execution_context=` to set the context, in a future
refactor we will pass the object to the constructor.

Fixes #6890
2017-04-07 15:59:57 +00:00
Andrew Cholakian
76711a4785 LIR UI (Read Only) (#6241)
* Read-only Java IR
* Consistent ID generation as opposed to UUIDs

Fixes #6708
2017-04-03 08:49:00 -04:00
Andrew Cholakian
096391b434 Input#clone should also clone that input's codec
Some codecs are context-specific and not threadsafe. If, for instance,
you want to use `generator { threads => 3 }` you will run into buggy
behavior with the line and multiline codecs which are not threadsafe.

This patch is a quick workaround for this behavior. This does not fix
this issue for inputs that do their own multithreading. Those inputs
should handle codec cloning / lifecycle internally according to their
specific requirements.

Fixes #6865
2017-03-31 17:26:04 -04:00
Josh Soref
a06dc211ff Spelling fixes (#6806)
Spelling fixes across the board.
2017-03-29 19:33:26 -07:00
DeDe Morton
910a60d925 Fix typo
Fixes #6845
2017-03-27 14:27:21 -04:00