Slide 1

Slide 1 text

Optimizing Logstash Performance There's more than one way to parse a log...

Slide 2

Slide 2 text

Define the problem • Logstash is perceived as slow • No insight into performance bottlenecks • No idea how to gain insight

Slide 3

Slide 3 text

Logstash? Data In Data Out

Slide 4

Slide 4 text

Have no fear! Let's shine a light in there

Slide 5

Slide 5 text

Rule #1

Slide 6

Slide 6 text

–Jordan Sissel, creator of Logstash...and grok. “If you have to use grok, you've already lost.”

Slide 7

Slide 7 text

Toolset 1 • generator input plugin • dots codec • pipe viewer (pv)

Slide 8

Slide 8 text

Generator input { generator { lines => [ 'line1', 'line2', ... 'lineN', ] count => 123456 } }

Slide 9

Slide 9 text

dots codec output { stdout { codec => dots } }

Slide 10

Slide 10 text

pv -r, --rate show data transfer rate counter -W, --wait display nothing until first byte transferred $ bin/logstash -f mytest.conf | pv -Wr > /dev/null [42.0KiB/s]

Slide 11

Slide 11 text

–No one, Ever “I like waiting!”

Slide 12

Slide 12 text

Toolset 2 • Elasticsearch, Logstash, & Kibana (+ X-Pack) • Configure Logstash to send monitoring data • View in Kibana

Slide 13

Slide 13 text

X-Pack $ bin/elasticsearch-plugin install x-pack $ bin/kibana-plugin install x-pack $ bin/logstash-plugin install x-pack

Slide 14

Slide 14 text

Configure Kibana vi config/kibana.yml # If your Elasticsearch is protected with basic authentication, # these settings provide the username and password that the # Kibana server uses to perform maintenance on the Kibana # index at startup. Your Kibana users still need to # authenticate with Elasticsearch, which # is proxied through the Kibana server. elasticsearch.username: "elastic" elasticsearch.password: "changeme"

Slide 15

Slide 15 text

Configure Logstash vi config/logstash.yml # Periodically check if the configuration has changed and # reload the pipeline # This can also be triggered manually through the SIGHUP signal # config.reload.automatic: true xpack.monitoring.elasticsearch.url: "http://localhost:9200" xpack.monitoring.elasticsearch.username: elastic xpack.monitoring.elasticsearch.password: changeme

Slide 16

Slide 16 text

Ready for Launch • Start Elasticsearch • Start Kibana • Navigate to Monitoring page

Slide 17

Slide 17 text

Logstash is a Pipeline In case I neglected to mention it

Slide 18

Slide 18 text

Pipeline Truths • At most, Logstash can only move data as fast as it comes in • Unless dropped or eliminated by conditional, each event will exit each output. • If a filter or output plugin is slow or blocked, the entire pipeline will back up • Filters will slow the pipeline–Some a little, some a lot. • Logstash can only ship data as fast as the slowest output. • No, really. Not kidding.

Slide 19

Slide 19 text

Consider the following... output { plugin1 {...} plugin2 {...} plugin3 {...} }

Slide 20

Slide 20 text

Improving performance • Use brokers • Parallel pipelines • Staged pipelines

Slide 21

Slide 21 text

Parallel pipeline example input {...} filter {# NONE} output { redis {...} } redis input { redis {...} } filter { # all } output { plugin1 {...} } input { redis {...} } filter { # all } output { plugin1 {...} } input { redis {...} } filter { # all } output { plugin1 {...} }

Slide 22

Slide 22 text

Staged pipeline example output { elasticsearch {...} redis {...} } ES redis input { redis {...} } output { slow_output {...} }

Slide 23

Slide 23 text

Other potential bottlenecks • Persistent Queues • Conditionals • Especially if you're doing regular expressions in them

Slide 24

Slide 24 text

Future methods • Multiple pipelines from 1 JVM • Definable in logstash.yml • Each with auto-reload • Pipeline viewer (may be only in X-Pack at release) • See throughput not just as a sum of input/output, but at each plugin and conditional.

Slide 25

Slide 25 text

Conclusion • If you can't measure it, you can't improve it, so monitor it. A lot. • Use grok and regular expressions... • ...as sparingly as possible • Don't put all of your pipeline eggs in one basket... • ...unless you've measured it and it meets your expectations • Parallelize and stage your pipeline with brokers FTW

Slide 26

Slide 26 text

Resources • https://www.elastic.co/guide/en/logstash/current/performance- troubleshooting.html • https://www.elastic.co/guide/en/logstash/current/tuning-logstash.html