einführung logstash markus rodi karlsruhe, 20.12 · 2 1. was ist ein log? 2. was ist logstash? 3....

15
Einführung Logstash Markus Rodi Karlsruhe, 20.12.2013

Upload: vodiep

Post on 29-Aug-2019

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

Einführung Logstash

Markus Rodi

Karlsruhe, 20.12.2013

Page 2: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

2

1. Was ist ein log?

2. Was ist logstash?

3. Beispiel Konfiguration

4. Was sind Patterns?

5. Elasticsearch + Kibana

6. Beispielsetup bei DreamHost

Agenda

Page 3: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

3 Was ist ein Log?

Auszug aus einem Apache2 access Log

Timestamp : Data

88.152.217.132 - - [29/Aug/2011:00:01:28 -0700] "GET /style2.css HTTP/1.1" 200

Page 4: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

4 Was ist logstash?

Die Logstash Konfigdatei besteht aus:

- Input: Liest das Log ein- Filter: Anwenden von Filterungsregeln- Output: Versendet die Logs

Page 5: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

5 Was ist logstash?

Installationsmodelle

Standalone: ● Alle Dienste laufen auf einem Server

Zentralisiert:● Shipper: Logstashinstanz auf Clientseite● Indexer, Elasticsearch, Redis auf Serverseite

Page 6: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

6 Was ist logstash?Plugins

inputs:● files● standard input● external programs● redis● syslog● websockets

filters:● grok (Textparser und Strukturierer)● grep● multiline

outputs:● graphite● elasticsearch● redis● file● zabbix/nagios

Page 7: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

7 Beispiel KonfigurationKonfigurationsdatei ohne Filter

input { file { path => "/home/markus/Downloads/apache.log" start_position => "beginning" } }

output { stdout { debug => true } }

Page 8: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

8 Beispiel KonfigurationOutput ohne Filter

{ "message" => "129.92.249.70 - - [18/Aug/2011:06:00:14 -0700] \"GET

/style2.css HTTP/1.1\" 200 1820 \"http://www.semicomplete.com/blog/geekery/bypassing-captive-

portals.html\" \"Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1

Safari/6533.18.5\"", "@timestamp" => "2013-12-16T08:01:50.115Z",

"@version" => "1", "host" => "crunchbang",

"path" => "/home/markus/Downloads/apache.log"}

Page 9: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

9 Beispiel KonfigurationKonfigurationsdatei mit Filter

input { file { path => "/home/markus/Downaloads/apache.log" start_position => "beginning" type => "apache" } }filter { if [type] == "apache" { grok { match => { "message" => "%{COMBINEDAPACHELOG}" } } }}output { stdout { debug => true }}

Page 10: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

10Beispiel KonfigurationOutput mit Filter

{ "message" => "129.92.249.70 - - [18/Aug/2011:06:00:14 -0700] \"GET /style2.css HTTP/1.1\" 200 1820 \"http://www.semicomplete.com/blog/geekery/bypassing-captive-portals.html\" \"Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5\"", "@timestamp" => "2013-12-16T08:21:33.806Z", "@version" => "1", "type" => "apache", "host" => "127.0.0.1:41520", "clientip" => "129.92.249.70", "ident" => "-", "auth" => "-", "timestamp" => "18/Aug/2011:06:00:14 -0700", "verb" => "GET", "request" => "/style2.css", "httpversion" => "1.1", "response" => "200", "bytes" => "1820", "referrer" => "\"http://www.semicomplete.com/blog/geekery/bypassing-captive-portals.html\"", "agent" => "\"Mozilla/5.0 (iPad; U; CPU OS 4_3_5 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8L1 Safari/6533.18.5\""}

Page 11: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

11Was sind Patterns?

Verzeichnis und Textdatei erstellen z.B.: /patterns/error Inhalt von error: ERRORFIND (error|ERROR)

Beispielpatterns:https://github.com/logstash/logstash/blob/v1.3.1/patterns/grok-patterns

In grok: filter { grok { patterns_dir => ''./patterns''

match=>[''message'',''{ERRORFIND:all_errors_in_this_log}'' ] }}

Page 12: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

12elasticsearch + KibanaBeispielkonfiguration ohne Filter

input { file { path => "/home/markus/Downloads/testlog.log" start_position => "beginning" type => "log" }}output { elasticsearch { embedded => true }}

Page 13: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

13Beispielkonfiguration

Logstash@DreamHost

● 7 logstash/elasticsearch Nodes● Jede Node hat 8 Kerne, 4TB HDD, 16GB RAM● ca. 600 Server „shippen“ Logs● 10.000 events/sekunde● 500 Millionen events/Tag

Page 14: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

14Quellen

logstash.netgoogle.desemicomplete.comFolien by Jordan Sissel

Page 15: Einführung Logstash Markus Rodi Karlsruhe, 20.12 · 2 1. Was ist ein log? 2. Was ist logstash? 3. Beispiel Konfiguration 4. Was sind Patterns? 5. Elasticsearch + Kibana 6. Beispielsetup

15Vielen Dank für Ihre Aufmerksamkeit

Kontakt

Markus RodiAuszubildender Fachinformatiker für Systemintegration

inovex GmbHOffice KarlsruheLudwig-Erhardt-Allee 676131 Karlsruhe

+49 173 3181 [email protected]