Commit graph

340 commits

Author SHA1 Message Date
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
Pier-Hugues Pellerin
9fe6c0cf43 Record the execution time for each output in the pipeline
Record the wall clock time for each output a new `duration_in_millis`
key will now be available for each output in the api located at http://localhost:9600/_node/stats

This commit also change some expectations in the output_delegator_spec
that were not working as intended with the `have_received` matcher.

Fixes #6458
2016-12-29 12:51:41 -05:00
Pier-Hugues Pellerin
55731eb936 Initialize the metric values in the batch to the correct type
When we were initilizing the `duration_in_millis` in the the batch we
were using a `Gauge` instead of a counter, since all the object have the
same signature when the were actually recording the time the value was
replaced instead of incremented.

Fixes #6465
2016-12-29 11:12:32 -05:00
Pier-Hugues Pellerin
7b4373789f Add a test to make sure the Collector#snapshot_metric returns a cloned metric store.
Fixes #6456
2016-12-29 08:59:52 -05:00
Pier-Hugues Pellerin
0fe94e779d Do not log a warning if a plugin is not from in #print_notice_version
When a plugin is loaded using the `plugins.path` option or is from a
universal plugin there no gemspec can be found for the specific plugin.

We should not print any warning on that case.

Fixes: #6444

Fixes #6448
2016-12-21 09:44:36 -05:00
Pier-Hugues Pellerin
13599ca64a Initialize with default values global events and pipeline events related metric
The metric store has no concept is a metric need to exist so as a rule
of thumb we need to defined them with 0 values and send them to the
store when we initialize something.

This PR make sure the batch object is recording the right default values

Fixes: #6449

Fixes #6450
2016-12-21 09:43:29 -05:00
Joao Duarte
08cebd5c16 ensure metric collection is disabled when metric.collect is false
Fixes #6445
2016-12-21 07:20:23 -05:00
Joao Duarte
128c660e0c add tests for webserver metric
Fixes #6385
2016-12-19 12:43:24 -05:00
Pier-Hugues Pellerin
fa18df3ec6 rename cgroup usage to usage_nanos to align with ES' api
Fixes #6428
2016-12-16 10:19:59 -05:00
Pier-Hugues Pellerin
9c8bf203e2 Add cgroup information to the api
When logstash is run under a linux container we will gather statistic about the cgroup and the
cpu usage. This information will should in the /_node/stats api and the result will look like this:

```
  "os" : {
    "cgroup" : {
      "cpuacct" : {
        "usage" : 789470280230,
        "control_group" : "/user.slice/user-1000.slice"
      },
      "cpu" : {
        "cfs_quota_micros" : -1,
        "control_group" : "/user.slice/user-1000.slice",
        "stat" : {
          "number_of_times_throttled" : 0,
          "time_throttled_nanos" : 0,
          "number_of_periods" : 0
        },
        "cfs_period_micros" : 100000
      }
    }
  }
```

Fixes: #6252

Fixes #6357
2016-12-15 15:46:38 -05:00
Suyog Rao
c8826b81ab Add reload stats at the instance level
Reload stats are currently reported at the pipeline level. The instance
level aggregates these stats across the pipelines

Fixes #6350

Fixes #6367
2016-12-13 00:59:24 -05:00
Pier-Hugues Pellerin
e3209a3033 Change the assertions in the config reloading spec
The assertions was using dummy outputs and kept received events into an
array in memory, but the test actually only needed to match the number
of events it received, this PR add a DroppingDummyOutput that wont
retain the events in memory.

The previous implementation was causing a OOM issue when running the
test on a very fast machine.

Fixes: #6335

Fixes #6346
2016-12-02 13:24:08 -05:00
Guy Boertje
eba128c968 Allow for exception instances to get serialized in JSON logging 2016-11-30 15:43:57 -08:00
Joao Duarte
bc3bcfde24 rename queueMaxSizeInBytes to queueMaxBytes and currentSize to currentByteSize
Fixes #6297
2016-11-29 05:10:42 -05:00
Joao Duarte
4a5aa90466 add ruby wiring to the queue.max_size setting
Fixes #6297
2016-11-29 05:10:42 -05:00
Colin Surprenant
f636a751f8 add support for queue.checkpoint.{acks|writes} settings
add queue.max_acked_checkpoint and queue.checkpoint_rate settings

now using checkpoint.max_acks, checkpoint.max_writes and checkpoint.max_interval

rename options

wip rework checkpointing

refactored full acked pages handling on acking and recovery

correclty close queue

proper queue open/recovery

checkpoint dump utility

checkpoint on writes

removed debug code and added missing newline

added better comment on contiguous checkpoints

fix spec for new pipeline setting
2016-11-22 14:48:58 -05:00
Andrew Cholakian
c03f30fedb Fix filter 'id' naming to be consistent with inputs / outputs
The filters were the only category prefixing IDs with their plugin names

Fixes #6259
2016-11-22 13:35:30 -05:00
Pier-Hugues Pellerin
12cfa69215 Feature: A way to install/remove a plugin pack
A pack in this context is a *bundle* of plugins that can be distributed outside of rubygems; it is similar to what ES and kibana are doing, and
the user interface is modeled after them. See https://www.elastic.co/downloads/x-pack

**Do not mix it with the `bin/logstash-plugin pack/unpack` command.**

- it contains one or more plugins that need to be installed
- it is self-contains with the gems and the needed jars
- it is distributed as a zip file
- the file structure needs to follow some rules.

- As a reserved name name on elastic.co download http server
    - `bin/plugin install logstash-mypack` will check on the download server if a pack for the current specific logstash version exist and it will be downloaded, if it doesn't exist we fallback on rubygems.
    - The file on the server will follow this convention `logstash-mypack-{LOGSTASH_VERSION}.zip`

- As a fully qualified url
    - `bin/plugin install http://test.abc/logstash-mypack.zip`, if it exists it will be downloaded and installed if it does not we raise an error.

- As a local file
    - `bin/plugin install file:///tmp/logstash-mypack.zip`, if it exists it will be installed

Fixes #6168
2016-11-17 14:00:02 -05:00
Pier-Hugues Pellerin
cd84576584 Theses core input are not currently used inside logstash so it make sense to remove them
Fixes #6268
2016-11-17 11:54:33 -05:00
Pier-Hugues Pellerin
169ba4636a move the loadAverage class into his own file and do the same for the specs
Fixes #6240
2016-11-14 08:59:39 -05:00
Pier-Hugues Pellerin
80c2019dcf Monitor the load average of the machine and display it in the api
This PR add new information in the /_node/stats api and will return the
load average of the machine in the following formats depending of the
platforms that logstash is running on:

**Linux**
```json
{
    "cpu" : {
      "percent" : 26,
      "load_average" : {
        "1m" : 2.826171875,
        "5m": 1.8261718,
        "15m": 1.56566
      }
    }
}
```

**MacOS and other platform that the OperatingMXBean understand**
```json
{
    "cpu" : {
      "percent" : 26,
      "load_average" : {
        "1m" : 2.826171875,
      }
    }
}
```

Load average is not available on Windows

Fixes: #6214

Fixes #6240
2016-11-14 08:59:38 -05:00
Suyog Rao
e78fce609b Add JVM uptime stats
Fixes #6236
2016-11-11 11:52:18 -05:00
Pier-Hugues Pellerin
a732d0cdea Add a transient_settings concept to the settings handling
When we load a yml file in logstash if a key isn't not found in the
settings, we move that key and the corresponding value to a
`transient_settings` hash. This give the time to the plugin to register
new settings. When we call #validate_all we merge the
`transient_settings` hash and do the validation, if a key is not found
at that stage an excepton will be throw.

Fixes #6109
2016-11-11 09:43:44 -05:00
Pier-Hugues Pellerin
413dc350d2 Chagne PluginRegistry -> PLUGIN_REGISTRY
Fixes #6109
2016-11-11 09:43:44 -05:00
Pier-Hugues Pellerin
02f15c8b41 rescope the mock classes
Fixes #6109
2016-11-11 09:43:44 -05:00
Pier-Hugues Pellerin
3a652a3076 adjust the specs
Fixes #6109
2016-11-11 09:43:43 -05:00
Pier-Hugues Pellerin
58ccca7028 fixing the tests
Fixes #6109
2016-11-11 09:43:43 -05:00
Pier-Hugues Pellerin
6626fa897c This PR changes two things:
- Allow plugins author to decide how their plugins are structured
- Allow a new kind of plugin that allow plugins author to add hooks into logstash core.

Fixes #6109
2016-11-11 09:43:43 -05:00
Joao Duarte
a0f70777bc mark reload as failure if pipeline.run aborts
currently a reload is only marked as a failured if it fails the classic
config test check, where we check for parameter names, existing plugins, etc.

This change waits for the pipeline to transition to running before
marking the reload as success, otherwise it is a failure.

fixes #6195

Fixes #6196
2016-11-10 05:27:01 -05:00
Pier-Hugues Pellerin
c8bf755f7b Enable back the WritableDirectory spec
A few days ago I've created this PR[1] to to enable the writable directory
spec to pass on macos X. When the PQ got merged in the master branch the
test was disabled again[2].

[1] https://github.com/elastic/logstash/pull/6110
[2] 761f9f1bc9

Fixes #6218
2016-11-09 09:00:07 -05:00
Andrew Cholakian
80d21712c6 Add Persistent UUID for Agent
This adds two new fields 'id', and 'name' to the base metadata for API requests.
These fields are now returned at all API endpoints by default.

The `id` field is the persisted UUID, the name field is the custom name
the user has passed in (defaulted to the hostname).

I renamed `node_uuid` and `node_name` to just `id` and `name` to be
inline with Elasticsearch.

This also fixed a broken test double in `webserver_spec.rb` that was
using doubles across threads which created hidden errors.

Fixes #6224
2016-11-09 07:40:47 -05:00
Colin Surprenant
cb8d80a46f fix tagging edge cases
add comment and use Arrays.asList()

brain fart between camelCase and snake_case
2016-11-04 14:03:50 -04:00
Tal Levy
19d3232873 slowlog
Fixes #6128
2016-11-02 18:48:40 -04:00
Suyog Rao
0b457996d0 Fix unit tests
Fixes #6172
2016-11-02 15:51:59 -04:00
Pier-Hugues Pellerin
1d21530c56 Change how PeriodicPollers log their exception
In a busy logstash install and the way we interact with core stats from
the jvm or the os, the poller can timeout. This exception is logged as
an error. but this shouldn't impact normal operation.

This PR changes the following:

- Change the interval for 5s instead of 1s
- Make the timeout bigger 160s instead of 60
- Concurrent::TimeoutError will be logged using debug instead of error
- Any other exception will use the error level.
- add tests

Fixes: #6160
Fixes: #6158

Fixes #6169
2016-11-02 14:08:26 -04:00
Colin Surprenant
761f9f1bc9 merge feature/java_persistence into master 2016-11-01 17:13:23 -04:00
Pier-Hugues Pellerin
d1dc80c64f oops whitespace
Fixes #6110
2016-10-26 19:26:20 -04:00
Pier-Hugues Pellerin
cbc91f7050 Fix test for LogStash::Setting::WritableDirectory#set
path for unix domain socket have a hard limit of 104 on macos and 108 on
linux, using `Stud::Temporary.pathname` to generate the path will exceed
that limit. So we will use a custom generation of using the tmpdir +
Time.now.to_f which should be good enough for this test.

Fixes: #6108

Fixes #6110
2016-10-26 19:26:20 -04:00