Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logstash Filebeat module #5481

Merged
merged 2 commits into from
Nov 21, 2017
Merged

Conversation

ph
Copy link
Contributor

@ph ph commented Oct 30, 2017

This module add support for the differents logs files generated by
Logstash and add simple dashboard to display relevent information.

Depending on the configuration Logstash will generate two differents
log:

1.logstash-(plain|json).log: this log file will contains all the
normal log events generated by logstash.

  1. logstash-slowlog-(plain|json).log: This log will contains events
    generated when the slow log feature is enabled in logstash and will contains
    the name of the plugin and the execution time. The recording of theses
    events are based on configurable threshold.

Also Logstash will output by default plain text log events but user can
change that to export structured JSON logs.

TODO

  • Add screenshots for the dashboard.

@ph
Copy link
Contributor Author

ph commented Oct 30, 2017

If you want to use Logstash's slowlog you have to turn it on in the configuration with something like this.

slowlog.threshold.warn: 2s
slowlog.threshold.info: 1s
slowlog.threshold.debug: 500ms
slowlog.threshold.trace: 100ms

You can use a sleep filter to actually get something slow :)

input {
    generator {}
}

filter {
    sleep {
        time => 3
    }
}

output {
    file {
        path => "/tmp/slow_events.log"
    }
}

@ph ph added the module label Oct 30, 2017
@ph ph force-pushed the feature/logstash-filebeat-module branch from 6064413 to 08b7cd2 Compare October 30, 2017 19:54
@ph ph added Filebeat Filebeat in progress Pull request is currently in progress. labels Oct 30, 2017
{INSERT IMAGE AFTER REVIEW}

[float]
=== Log fileset settings
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part of the docs is being refactored in #5341. It might make sense to update it already to the new style of module documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the pointer! I will do that.

],
"processors": [
{
"json": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JSON decoding could also be done on the Filebeat side, but I'm not sure if there's any advantage to that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My reasoning was, It's easier to to all the transformation at the same place, easier to tests/debug.

- c:/programdata/logstash/logs/logstash-slowlog-plain*.log
- c:/programdata/logstash/logs/logstash-slowlogjson*.log

ingest_pipeline: ingest/pipeline-{{.format}}.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 👍

# Filebeat will choose the paths depending on your OS.
#var.paths:

# Slow logs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit strange that we call it slow logs in the comments but below it's error?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, typo good catch :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will do another complete run, are you volunteering to test it? 💃

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can do, but probably only get to it tomorrow.

@ph ph force-pushed the feature/logstash-filebeat-module branch 2 times, most recently from 62ed562 to b657b71 Compare November 17, 2017 15:28
@ph
Copy link
Contributor Author

ph commented Nov 17, 2017

I have updated the PR, generating a bit more dummy data to create a dash board.

@ph ph force-pushed the feature/logstash-filebeat-module branch from 410ed29 to 069addd Compare November 20, 2017 18:15
@ph ph added review and removed in progress Pull request is currently in progress. labels Nov 20, 2017
@ph
Copy link
Contributor Author

ph commented Nov 20, 2017

@tsg Can you take a look at it?

@tsg
Copy link
Contributor

tsg commented Nov 20, 2017

I didn't see in the PR a module.yml file like this one. It just lists the dashboards which makes it easier to export them (see the -yml option from the export_dashboards program).

@tsg
Copy link
Contributor

tsg commented Nov 20, 2017

@ph This looks great! There seem to be some errors in the tests, though.

@ph
Copy link
Contributor Author

ph commented Nov 20, 2017

re: modules.yml I might have followed an older doc, will add it easily, also checking for tests.

@ph ph force-pushed the feature/logstash-filebeat-module branch from 069addd to 3600ba4 Compare November 20, 2017 21:02
@ph
Copy link
Contributor Author

ph commented Nov 20, 2017

@tsg I have updated the module.yml and created #5656 for the tests followup.

@ph
Copy link
Contributor Author

ph commented Nov 20, 2017

fixing pep8.. ;)

@ph ph force-pushed the feature/logstash-filebeat-module branch 8 times, most recently from b77bc11 to 5966b9c Compare November 21, 2017 05:09
@ph ph force-pushed the feature/logstash-filebeat-module branch 4 times, most recently from 633054c to 456b0eb Compare November 21, 2017 06:33
@tsg
Copy link
Contributor

tsg commented Nov 21, 2017

@ph there seems to be still one more error:

06:46:41 ======================================================================
06:46:41 FAIL: Tests all filebeat modules
06:46:41 ----------------------------------------------------------------------
06:46:41 Traceback (most recent call last):
06:46:41   File "/go/src/github.com/elastic/beats/filebeat/tests/system/test_modules.py", line 71, in test_modules
06:46:41     cfgfile=cfgfile)
06:46:41   File "/go/src/github.com/elastic/beats/filebeat/tests/system/test_modules.py", line 133, in run_on_file
06:46:41     assert len(objects) > 0
06:46:41 AssertionError: 
06:46:41 -------------------- >> begin captured stdout << ---------------------

This module add support for the differents logs files generated by
Logstash and add simple dashboard to display relevent information.

Depending on the configuration Logstash will generate two differents
log:

1.`logstash-(plain|json).log`: this log file will contains all the
normal log events generated by logstash.

2. `logstash-slowlog-(plain|json).log`: This log will contains events
generated when the slow log feature is enabled in logstash and will contains
the name of the plugin and the execution time. The recording of theses
events are based on configurable threshold.

Also Logstash will output by default plain text log events but user can
change that to export structured JSON logs.
@ph ph force-pushed the feature/logstash-filebeat-module branch from b774d97 to 55252c6 Compare November 21, 2017 16:58
@tsg tsg merged commit bbc0aa6 into elastic:master Nov 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants