Commit graph

577 commits

Author SHA1 Message Date
Jake Landis
f1361de660 Test stabilization: add max retry and timeouts to pipeline spec
Fixes #7738

Fixes #7752
2017-07-20 17:58:05 +00:00
Jake Landis
78d0d5a364 Test stabilization: Add retry to have_running_pipeline matcher
Fixes #7737

Fixes #7753
2017-07-20 17:57:31 +00:00
Jake Landis
0c59550d65 Test stabilization: Ensure that logging is set back to 'info' after tests that may change it
Fixes #7739

Fixes #7743
2017-07-20 17:56:33 +00:00
Jake Landis
a25d329f64 Test Failure Fix: Retry pipeline metrics
Fixes #7724

Fixes #7728
2017-07-18 22:04:02 +00:00
Colin Surprenant
aedf397397 fix empty queue condition for queue shutdown drain, PR #7575
page test

queue test

move is_empty? at queue level

new wrapped acked queue spec
2017-07-18 16:32:22 -04:00
Andrew Cholakian
85fc814105 Fix SafeURI to maintain pre-5.5.0 escaping behavior
Prior to Logstash 5.5.0 the ::LogStash::Util::SafeURI class returned escaped values where applicable. As part of the refactor in https://github.com/elastic/logstash/pull/7236 this behavior was accidentally changed, breaking the ES output and resulting in bugs like: https://github.com/logstash-plugins/logstash-output-elasticsearch/issues/618 .

This PR maintains the java.net.URI refactor but fixes the behavior to align with pre-5.5.0 logstashes by correctly returning escaped values.

Fixes #7687
2017-07-17 18:15:36 +00:00
Armin
1ebb0e350f #7662 Make StringBiValue safe against mutations to the underlying RubyString
Fixes #7663
2017-07-17 14:13:20 +00:00
Armin
deaa90e405 #6964 migrate setting config.reload.interval to TimeValue
Fixes #7678
2017-07-13 16:13:17 +00:00
João Duarte
50d6aff798 implement ssl in modules (#7667)
* implement ssl in modules

* rearrange some setting names in logstash-modules

* removed dashboards.kibana_index setting from modules
2017-07-13 10:47:34 +01:00
Jake Landis
17be8b09c3 Metrics: Move counters and gauges to Java with stricter types.
This change moves the definition of the counters and gauges from Ruby to Java, providing a Ruby bridge that allows support for Ruby duck typing to Java strict typing.
This change also moves the serialzation from JRuby (Jackson) to Java (Jackson).
This change also removes the decrement from counter api and requires counters start at zero. This helps to allowing for reliable aggregrations over time.
This change removes the base Ruby class for metrics, and replaces with base Java class.
This change removes the to_hash method (no known usages).
This change also has minor changes to the Ruby type() and inspect() methods.

Fixes #7509

Fixes #7595
2017-07-12 22:41:20 +00:00
Colin Surprenant
bf2a15bda7 broken Event.toString() when missing @timestamp, PR #7604
test to repro #6756

extra test

fix toString

cosmetic

remove irrelevant spec

reworked host and message string generation
2017-07-10 15:14:06 -04:00
Guy Boertje
84cd0f96f8 Add support for using kibana dashboard import api (#7591)
* Add support for using kibana dashboard import api
- Add support for versioned folders below 'module'/configuration/kibana
- Rename cef to module_test_files/tester and simplify it.
- Remove skips on tests using above modules test files.
- In pipeline.rb, moved method default_logging_keys to the base class,
  it was being called from BasePipeline during a config-test.
- In modules_common, added a backtrace to LogStash::ConfigLoadingError
  for better debugging
- Improve layout when user_lines et al were empty in logstash_config

* Change specificity of maj/min/patch folder search

* Use logger to surface manticore error

* Add suppor for Kibana auth

* improve error message

* support es and kibana authentication in the logstash modules
2017-07-08 09:55:41 +02:00
Pier-Hugues Pellerin
6e92939505 Add more options for the modules templates (#7582)
* Add more options for the modules templates

This commits add the following new features:

Allow users to use the internal settings classes to have better handling
over the primitives values that a user can use in the modules templates,
by default we are using a `NullableString` which is the more flexible
type.

This change open the way to have more strict validation on the module
templates and will allow us to preprocess configuration to retrieve the
list of the settings and their settings types.

We also add a new type of settings called `SplittableStringArray`, this
class is a subclass or `ArrayCoercible` but target module CLI
configuration. It will take the following form `-M
"arcsight.var.input.hosts=127.0.0.1:3333,192.168.1.23:9999"` and
transform it into a ruby array of string.

We can also add alias of settings values in the configuration by using the
`alias_settings_keys!()`, this is usefull when the language domain is
different from the logstash domain.

* adjust test
2017-07-03 17:08:29 +01:00
Armin
10007948c8 bck
Fixes #7524
2017-06-29 17:48:36 +00:00
Armin
c307b18ff0 #7476 fix syntax of queue fully_acked method
Fixes #7524
2017-06-29 17:48:36 +00:00
Armin
a10a7eb8c6 #6828 port some tests to json-schema instead of self-made json matching
Fixes #7419
2017-06-29 00:05:16 +00:00
Guy Boertje
b06767b71e Clone LogStash::SETTINGS in logstash-core/spec/logstash/pipeline_dlq_commit_spec.rb
Explained in the issue 7551 (#7552)

Fixes #7551
2017-06-28 14:30:05 +01:00
Guy Boertje
7696c6c397 Fix for: Unreliable logstash-core/spec/logstash/timestamp_spec under JRuby 9000 (#7474)
* Fix Timestamp.new(now) != now, out by 0.999999 milliseconds

* add comment

* add for failing legacy_ruby_timestamp_spec too
2017-06-21 13:09:11 +01:00
Jordan Sissel
35c1cff164 Feature flag for string escape sequences (#7442)
New boolean setting `config.support_escapes` which defaults to false
(the historical behavior). When set to true, the following escapes are
handled:

* backslash doublequote -> doublequote
* backslash quote -> quote
* backslash n -> newline (ascii 10)
* backslash r -> carriage return (ascii 13)
* backslash backslash -> backslash
* backslash t -> tab (ascii 9)

This will solve #1645.
2017-06-20 14:34:10 -07:00
Guy Boertje
d13d54c377 MODULES: Fix broken multi-pipelines because, you know, modules (#7466)
* Update runner, source/local, source/modules, source/multi_local
improve startup config problem detection across all sources.

* fix multi_local spec to use not `empty` values.
2017-06-16 09:47:15 +01:00
Andrew Cholakian
6b5379026e Properly hash when no original source is present.
This corrects a mistake where the digest of the string source should be
used when present, and the hash of the graph should be used when not.

Fixes #7467
2017-06-15 17:53:18 +00:00
Guy Boertje
1c47ab0f9b MODULES: Add maxbuckets to the kibana config json (#7451)
* Add maxbuckets to the kibana config json

* change METRICS_MAX_BUCKETS to 86400 and fix specs
2017-06-15 17:56:02 +01:00
Armin
448bda167f #7460 ignore failing tests caused by #e939c6a removing CEF module
Fixes #7462
2017-06-15 15:30:21 +00:00
Pier-Hugues Pellerin
d4183aa043 Add ephemeral_id on the Logstash instance and for the pipelines.
Theses id wont be persisted between restart of logstash or between
creation of pipeline. When we reload pipelines the ephemeral_id will be
generated again.

Fixes #7423
2017-06-14 13:37:02 +00:00
Andrew Cholakian
f5c6c5a4b1 Use file hashing where possible in LIR
This commit further improves hashing performance, using SourceWithMetadata
objects where present to determine Vertex IDs and the hash of the source
file. If those objects are not present LIR will revert to graph hashing,
which is slower, but always works. This is still useful for things like
testing, so it makes sense to leave that code in.

In the future it might be nice to extract the hashing code using the
strategy pattern to clean things up.

This commit also improves the Hashable interface, moving hashSource into
its own interface, letting classes that do their own hashing simply
implement uniqueHash instead of requiring them to also implement
hashSource.

A requirement of these changes was also that SourceWithMetadata no
longer accept null or empty arguments. This patch now enforces that
requirement. This also is nicer from an API standpoint, as you now know
that if a SourceWithMetadata object exists, it will actually have all
its fields in use.

Fixes #7408
2017-06-13 14:09:17 +00:00
Armin
26a8163f19 #6696 validate evaluation result
Fixes #7411
2017-06-13 07:57:12 +00:00
Pier-Hugues Pellerin
76286b4f0e use jruby 9.1.9.0
Work done by @guyboertje and @ph

Since JRuby 1.7.25 is now EOL we are migrating Logstash to use JRuby 9k and JDK8 only,
Not much needed updating to make this work, its was mostly a drop in replacement from the previous version.

The major point was the change in the implementation of Time in JRuby, JRuby now use `java.time`
instead of joda time, this allow JRuby to have nanoseconds precision on time object.
2017-06-12 12:35:10 -04:00
Rob Bavey
2d2cee4d2e Add Metrics for dead letter queue
Add an initial set of metrics for the dead letter queue.

Metrics are supplied under the pipeline in the following format:

"dead_letter_queue": {
        "queue_size_in_bytes": ...,
      }

Metrics are populated via a PeriodicPoller

Also fixed up calculation of currentQueueSize to take account
of version headers, which was previously being skipped.

Additionally, whether the dlq is enabled, and if so, the path
of the dlq is supplied under the pipelines API endpoint

Resolves #7287

Fixes #7338
2017-06-09 17:14:18 +00:00
Armin
edad14c6d0 MINOR: Removed Redundant Java Wrapper
Fixes #7394
2017-06-09 05:55:20 +00:00
Guy Boertje
2793d780bd MODULES: Fixes for bad module specified and elasticsearch client logging silence (#7367)
* Fixes for bad module specified and elasticsearch client logging silence & iterate over the intersection of specified and available modules
2017-06-07 19:57:56 +01:00
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
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
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
Pier-Hugues Pellerin
8e43ecaf46 Removed a flaky test in agent_spec in favor a refactored one in converge_spec
We remove a flaky test "LogStash::Agent#execute when auto_reload is true if state is clean should periodically reload_state"
in favor of the refactored test in `converge_spec`, since it doesn't use
rspec mock but instead use a threadsafe spies to make sure we do
multiple call on the source loader.

Fixes: #7196

Fixes #7200
2017-05-24 23:50:59 +00: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
78f70634ed Refactor API specs to play well with others
This is a big chang, it:

1. Moves API specs out of their special hierarchy
2. Removes the API spec spec_helper
3. Reactivates that stats command spec (that was accidentally not being
run before due to it not having _spec as a suffix

This was required to fix the preceeding commit, where we added a
before(:each) hook to the spec_helper that wasn't being picked up in
some cases due to the existence of two spec helpers and a $LOAD_PATH
that could change.

Fixes #7132
2017-05-18 13:45:27 +00:00
Andrew Cholakian
ff222b668b Clean settings before *and* after spec runs for the runner just in case.
This is a bit belt and suspenders, but I'm out of ideas for #6737 .
Its a bit worrying that the test cleanup may not be working correctly

Fixes #7132
2017-05-18 13:45:27 +00:00
Andrew Cholakian
7e9529fe47 Make test for pipeline flushing more resilient.
Instead of depending on the now deprecated multiline filter we use a
dummy filter that just emits events. This simplifies the test and
dramatically reduces timing issues.

I also increased the max-wait for the timer just in case

Fixes #7024

Fixes #7131
2017-05-17 13:57:13 +00:00
Armin
0c282105eb #7087 Fixed unstable test from premature exit of user defined pipeline
Fixes #7133
2017-05-17 13:09:35 +00:00
Pier-Hugues Pellerin
c9700220bd consistency in naming
Fixes #7103
2017-05-16 14:20:34 +00:00
Pier-Hugues Pellerin
23d0b34b53 Make the test for the write WrappedWriteClient more robust
Instead of using sleep we start two threads and we join them to do the
expectation.

Fixes: #7031 #7032

Fixes #7103
2017-05-16 14:20:33 +00:00
Armin
0020c4beab #6785 spec for nested case added
Fixes #7072
2017-05-11 18:40:14 +00:00
Armin
83a8603284 6785 interpolate settings after flattening settings hash
Fixes #7072
2017-05-11 18:40:13 +00:00
Armin
6bf4eddaff 6785 test windows style interpolation
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
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
Jordan Sissel
e838cc7abf Skip a flakey test failing since November 2016
The failure:

    Failures:

      1) LogStash::Pipeline defaulting the pipeline workers based on thread safety when there are threadsafe filters only starts multiple filter threads
         Failure/Error: expect(pipeline.worker_threads.size).to eq(worker_thread_count)

           expected: 5
                got: 8

Related issues: #6855, #6245, #6355

Fixes #7071
2017-05-11 09:45:19 +00:00
Joao Duarte
cad59d9304 fix a few racing conditions in the agent_spec
Fixes #7066
2017-05-11 09:17:32 +00:00