Commit graph

35 commits

Author SHA1 Message Date
Pier-Hugues Pellerin
2fedad3c7d 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:50 -05:00
Suyog Rao
678ebd1efc 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
9c9b4a42bb 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:39 -05:00
Suyog Rao
26bf1e4f21 Add JVM uptime stats
Fixes #6236
2016-11-11 11:52:19 -05:00
Andrew Cholakian
efefe7f32a 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
Tal Levy
9c687a37c4 Set default log.level to INFO
sets default to INFO and updates some verbose logging to
more appropriate, less verbose log levels where it makes sense.

Closes #5735.
Closes #5893.

Fixes #5898
2016-09-13 16:43:20 -04:00
Pier-Hugues Pellerin
e6b744c80a Return 404 on non existant resources
This PR introduce a changes to make sure the API endpoint correctly
return 404 in every case. To make it work it uses an exception that get
pickup up in the base class by the `error` handler.

Using the exception template allow the code to be dry and make sure all
other errors can be returned with the same format.

Example or a 404.
```json
{
"error": { "message": "Not Found"},
"path": "/this-should-not-exist"
"status": 404
}
```

The code will also set the content-type and the right error code in the
header.

Fixes: #5874, #5622

Fixes #5897
2016-09-13 14:15:43 -04:00
Tal Levy
9c1b6add71 add logging api endpoint
PUT /_nodes/logging -- sets log levels
GET /_nodes/logging -- retrieves log levels of existing loggers

Fixes #5871
2016-09-13 03:46:28 -04:00
Tal Levy
b545b83390 Migrate Logstash to Log4j2 Logging (#5651)
Migrate to use Log4j2 for Logstash logging
2016-08-26 18:11:22 +00:00
Pier-Hugues Pellerin
6aad5b9939 Add GC stats to the api
This PR introduce GC stats in the form of `collection_time` and `collection_count`, it takes the configured gc and categorize them
into old and young.

Example output:

```
gc: {
  collectors: {
    young: {
      collection_time_in_millis: 22101,
      collection_count: 5452
    },
    old: {
      collection_time_in_millis: 57,
      collection_count: 1
    }
  }
}
```

Fixes: #5730

Fixes #5788
2016-08-22 13:17:25 -04:00
Pier-Hugues Pellerin
da0199fe7d Expose duration of the Filter+Output part of the pipeline
This PR will expose the time spend of a batch in the filter + output

Ouput:
http://localhost:9600/_node/stats/pipeline
```
events: {
	duration_in_millis: 18364,
	in: 309325,
	filtered: 309325,
	out: 309325
},

	```

	Fixes: #5731

Fixes #5792
2016-08-22 13:16:39 -04:00
Pier-Hugues Pellerin
7312a12f36 Adding the values for the automatic reloading to the API
```
config_reload_automatic: true,
config_reload_interval: 3
```

Fixes: #5681

Fixes #5780
2016-08-22 12:03:27 -04:00
Pier-Hugues Pellerin
c7f6cba5c8 --http.port Now accept a port range
This PR does a few modifications for our webserver:
 - Add a PortRange setting type.
 - allow the --http.port option to accept a port range or a single port, when a range is provided Logstash will incrementally try this list to find a free port for the webserver.
 - Logstash will report in the log which port it is using. (INFO LEVEL)
 - It refactors a few methods of the webserver.
 - It adds test for the binding of the ports.

Notes:

Port range can be defined in the logstash.yml or pass via the command line like this.

 `bin/logstash -e 'input { generator {}} output { null {}}' --log.level verbose --http.port 2000-2005`

Fixes #5774
2016-08-19 08:04:01 -04:00
Pier-Hugues Pellerin
2355db583f make the thread count more reliable
Fixes #5766
2016-08-18 09:17:00 -04:00
Pier-Hugues Pellerin
aa5c5518cd adding test for the human hot_threads call
Fixes #5766
2016-08-18 09:17:00 -04:00
Pier-Hugues Pellerin
8fe0b05ba6 Add GC Strategy under /note/jvm
Fixes: #5755

Fixes #5775
2016-08-18 08:55:01 -04:00
Pere Urbon-Bayes
7d7270c066 reorg specs to fit the new schema
Fixes #5623
2016-07-19 08:50:42 -04:00
Andrew Cholakian
2ce01fc92f Add stats default fields (hostname, http_address, version) 2016-06-20 16:20:33 -05:00
Andrew Cholakian
2f4a1e6c39 Remove hot_threads from default _node API endpoint results
Fixes #5381
2016-06-15 14:34:15 -04:00
Andrew Cholakian
d68ac5d2d6 Move _plugin api to _node/plugin + add tests
Fixes #5381
2016-06-15 14:34:15 -04:00
Andrew Cholakian
2d64792d91 Add more node stats + refactor stats internals
Add node stats mem endpoint

Fixes #5381
2016-06-15 14:34:15 -04:00
Pier-Hugues Pellerin
420abaef0b Fix the ApiTest and the Metric inputs tests
Fixes #5446
2016-06-10 09:51:37 -04:00
Andrew Cholakian
ef18693115 Improve error handling in API / Rack App.
Setting error handling conditions in sinatra dynamically is not possible.
The values such as :show_exceptions get set, but have no effect.
This is esp. important in testing where we want failures to raise exceptions.
Otherwise, debugging is a matter of parsing instructable HTML responses containing
the debug info.

We do not want this behavior by default however, as doing so would mean a single API
bug would take down a production app.

This change adds a new agent setting (not CLI setting) 'http.environment' that is defaulted to 'production'.
If set to 'test' exceptions get raised.

This change also removes sinatra error handlers that previously did nothing, and injects
custom rack middleware to properly log and handle errors.

Fixes #5411
2016-06-01 20:20:13 +00:00
Andrew Cholakian
bd98b52214 Fix rake test:core path loading in API specs
Fixes #5384
2016-05-27 22:47:47 +00:00
Andrew Cholakian
b2ec0cffbc Refactor API + Add node_stats
Fixes #5307
2016-05-27 20:01:24 +00:00
Pere Urbon-Bayes
bfd35a6e5c remove hot_threads ignore_idle_threads test
Fixes #4853
2016-03-21 15:37:58 +00:00
Pere Urbon-Bayes
c233059d74 change JIT threads for pool threads in the idle threads check, due to the JIT threads not showing up randominly in some tests
Fixes #4833
2016-03-18 20:54:05 +00:00
Pere Urbon-Bayes
a860e5bc97 initial version for the _plugins api root resource
Fixes #4794
2016-03-17 11:00:04 +00:00
Pere Urbon-Bayes
42710a4ffd add expectations for json and plain text responses for the hot threads api tests
format test properly for the node_spec api

Introduce a more proper organization of the dummy/mock runner to avoid
having wrong state propagaged across the different tests. This was
discovered by the unnecessary need to have the rubydebug codec as it was
due to wrong pipeline startup.

make the node stats test sync with last changes in data formats

improve web api service logic from reviews

remove the requirement of using output-null as only with output {} you get the same effect

Fixes #4782
2016-03-14 14:07:25 +00:00
Pere Urbon-Bayes
79e2d0040f Make sure all web api test are actually going through the hole pipe and getting data out of a real logstash execution.
Test improvements:

* Cleanup non used fixture.
* Improve node_stats tests by adding omre context and format checks.
* Add a new node_specs endpoint test that checks the expected data is
  returned for the hot_threads resource.

Fixes #4782
2016-03-14 14:07:25 +00:00
Pere Urbon-Bayes
ee690ac3ee make sure _stats and _node/stats data format is the same
Fixes #4780
2016-03-11 19:31:14 +00:00
Pier-Hugues Pellerin
82dde31afe Fix an issue with the expectation on the agent#uptime
Fixes #4687

Fixes #4653
2016-02-12 19:00:11 +00:00
Pere Urbon-Bayes
459fad4738 cleanup non used expectation inside the jvm specs
Fixes #4683

Fixes #4653
2016-02-12 19:00:11 +00:00
Pere Urbon-Bayes
23dcf467e4 This make all designed resources for the metrics api available, this follows the initial sketches created in #4446.
As discussed in this adds:

/
/_node/hot_threads
/_node/stats/
/_node/stats/events
/_node/stats/jvm
/_stats/jvm

introduces also small refactors and cleanup necessary to improve the
webapi code quality.

adds also a way to handle references from the webapi to the internals of
logstash by passing the agent refrences to the collector, this is not
perfect, but for now it solve the communication situation until furder
refactor.

Fixes #4652

Fixes #4653
2016-02-12 19:00:10 +00:00
Pier-Hugues Pellerin
a04da0f76d Collecting Logstash metrics at runtime
This commit introduce the collection of the main metrics inside the
logstash pipeline and records it to the metric store. This code is also
the initial stone to define an internal metric api.

Collected metrics from the pipeline and system will be exposed by the web
api.

This work was done in collaboration by @ph and @purbon, commits were
squashed to simplify the merging process.

Fixes #4653
2016-02-12 19:00:09 +00:00