Commit graph

577 commits

Author SHA1 Message Date
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
Pier-Hugues Pellerin
b709eb5c68 Fix when settings set in the pipeline_pq_file_spec bleed into other examples
make sure we clone the LogStash::Settings before mutating it.

Fixes: #6868

Fixes #6981
2017-05-04 17:21:43 +00:00
Pier-Hugues Pellerin
2b3d494bbe Make the Logstash metric check for the timestamp on reload success more robust
The current implementation of the test was using a mock and an expect
on the internal classes to determine when to start testing on the
metrics. I've rewrote the setup of the test to use the file output instead of using a
instance. I believe the previous code was not completely threadsafe and was causing this error
in the spec. We should really remove any mock of the form expect_any_instance_of`.

Ref: #6935

Fixes #6956
2017-05-04 14:21:06 +00:00
Pier-Hugues Pellerin
a758412499 Replace the class declaration with let statements
Instead of using a concrete class use let statement instead, this make
sure they are reset between run and make the variable available at the
context level.

Fixes #7017
2017-05-04 13:05:24 +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
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
Pier-Hugues Pellerin
3dfdbee515 Fix the lock errors in the LogStash::Runner test
The test was actually starting an agent with pipeline and the runner has
currently no was to stop the agent. This commit make sure we use an
agent mock instead.

Fix: #6931

Fixes #6957
2017-04-27 12:45:29 +00:00
Pier-Hugues Pellerin
251ae7fe0e Make the periodic test converge a bit more robust
This test has been a bit flaky since it relies on an external thread to
trigger, this commit add a bit more time for the trigger to happen and
also add a retry.

Fixes: #6929

Fixes #6945
2017-04-27 12:44:39 +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
5379065249 adjust the agent and the converge spec for the system pipeline
Fixes #6885
2017-04-26 21:07:59 +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
Colin Surprenant
e732255edc add acked_queue concurrent stress spec
introduce rake test:core-fast and rake test:core-slow

remove custom rspec config
2017-04-21 14:37:49 -06:00
Pier-Hugues Pellerin
6e180b025d Make the relative path more obvious
I've changed the relative path used in the test, I am using a relative
path that I can more easily control and doesn't have 10 level of nested
directories, I think it was confusing when ran in on our linux ci.

I also added an assert in the `before` to make sure we generate the
right number of configuration in the example.

Ref: #6935

Fixes #6946
2017-04-21 13:32:48 +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
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
Pier-Hugues Pellerin
918f2bae21 Adding tests for the heap calculation, also changed the visibility
In retrospect, it just easier to expose the methods in the jvm spec
monitoring to be able to test them in isolation.

Fixes #6827
2017-03-26 20:43:12 -04:00
Andrew Cholakian
b1d2b8a39b Move input metrics to be nested under 'events' for consistency
Filters/outputs nest their 'out' metric under 'events'.
Inputs should not be different.

Fixes #6835
2017-03-23 19:32:57 -04:00
Pier-Hugues Pellerin
2fd1b377c3 Implements #has_metric?(*path)
Add a new method that uses the `fast_lookup` has to find if a specific
metric exist instead of relying on exceptions.

Usage:

```ruby
metric_store.has_metric?(:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch", :event_in) # true
metric_store.has_metric?(:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch", :do_not_exist) # false
```
Fixes: #6533

Fixes #6759
2017-03-14 20:32:01 -04:00
Pier-Hugues Pellerin
aa2a97f6f6 Record the events.in related statistic in the right place
This PR changes where the `events.in` are calculated, previously the
values were calculated in the `ReadClient` which was fine before the
addition of the PQ, but this make the stats not accurate when the PQ was
enabled and the producer are a lot faster than the consumer.

These commits change the collection of the metric inside an
instrumented `WriteClient` so both implementation of the client queues will use
the same code.

This also make possible to record `events.out` for every inputs and the
time waiting to push to the queue.

The API is now exposing theses values for each plugins, the events level
and and the pipeline.

Using a pipeline with a sleep filter and PQ we will see this kind of
response from the API.

```json
{
  "duration_in_millis": 438624,
  "in": 3011436,
  "filtered": 2189,
  "out": 2189,
  "queue_push_duration_in_millis": 49845
}
```

Fixes: #6512

Fixes #6532
2017-03-02 16:31:49 -05:00
Tal Levy
9974df427d remove old legacy logstash-core-event (#6783)
and migrate spec tests to core
2017-03-02 10:55:30 -08:00
Tal Levy
6fb8096a54 migrate logstash-core-event-java to logstash-core (#6760) 2017-03-01 15:31:17 -08:00
Colin Surprenant
568666c777 add queue drain option support
wip queue drain option

metrics on empty batches

reenabled spec

cosmetic fixes

stats collection, mutex, specs, empty batch handling

start_metrics
2017-03-01 14:12:27 -05:00
Suyog Rao
e2ffcf9dca Add tests for deep nested env variables 2017-02-21 14:13:12 -08:00
Andrew Cholakian
2239068512 Setting --path.data on CLI should also change path.queue
This change was harder than it first appeared! Due to the complicated
interactions between our Setting class and our monkey-patched Clamp
classes this required adding some new hooks into various places to
properly intercept the settings at the right point and set this
dynamically.

Crucially, this only changes path.queue when the user has *not*
overriden it explicitly in the settings.yml file.

Fixes #6378 and #6387

Fixes #6731
2017-02-17 16:43:07 -05:00
Colin Surprenant
c6710cdbae support exclusive locking of PQ dir access
fix agent and pipeline and specs for queue exclusive access

added comments and swapped all sleep 0.01 to 0.1

revert explicit pipeline close in specs using sample helper

fix multiple pipelines specs

use BasePipeline for config validation which does not instantiate a new queue

review modifications

improve queue exception message
2017-02-10 17:36:03 -05:00
Joao Duarte
6a5290e139 add setting class that coerces value to array
Fixes #6630
2017-02-07 06:42:56 -05:00
Joao Duarte
c10f55054b make SafeURI class clone deeper
Fixes #6645
2017-02-06 17:29:26 -05:00
Colin Surprenant
e503fcf60b refactor agent pipeline reloading to avoid double live pipelines with same settings
extracted BasePipeline class to support complete config validation

minor review changes

added comment
2017-02-03 18:15:34 -05:00
Joao Duarte
a2158e5608 ensure pipeline.id is correctly propagated
Fixes #6530
2017-01-26 11:15:36 -05:00
Joao Duarte
903cdd6331 include pipeline id in queue path
create queue sub directory based on pipeline id

Fixes #6540
2017-01-26 10:27:04 -05:00
Pier-Hugues Pellerin
db13b08d26 missing specs for the refactoring
Fixes #6499
2017-01-25 08:55:46 -05:00
Joao Duarte
c3a8fb09d4 use running instead of read in some agent specs
the pipeline class two state predicates: ready? and running?

ready? becomes true after `start_workers` terminates (succesfuly or not)
running? becomes true before calling `start_flusher`, which means that
`start_workers` is guaranteed to have terminated successfuly

Whenever possible, we should use `running?` instead of `ready?` in the
spec setup blocks. The only place where this may be bad is when the
pipeline execution is short lived (e.g. generator w/small count) and the
spec may never observe pipeline.running? == true

Fixes #6574
2017-01-24 05:29:35 -05:00
Pier-Hugues Pellerin
84063ed74d Extract the creation of the queue into a factory
I've move the initialization code into a factory for future work on the
pipeline.

Fixes #6498
2017-01-16 12:28:36 -05:00
Suyog Rao
df2ff69a0e Renamed cgroups metric to number_of_elapsed_periods
Renamed number_of_periods to number_of_elapsed_periods to be consistent with ES.

Fixes #6536
2017-01-16 12:20:16 -05:00
Colin Surprenant
eb00b0da4c avoid resetting inexisting tags field back to empty array plus specs
Fixes #6477
2017-01-03 22:31:31 -05:00