Post on 29-Aug-2019
Einführung Logstash
Markus Rodi
Karlsruhe, 20.12.2013
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
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
4 Was ist logstash?
Die Logstash Konfigdatei besteht aus:
- Input: Liest das Log ein- Filter: Anwenden von Filterungsregeln- Output: Versendet die Logs
5 Was ist logstash?
Installationsmodelle
Standalone: ● Alle Dienste laufen auf einem Server
Zentralisiert:● Shipper: Logstashinstanz auf Clientseite● Indexer, Elasticsearch, Redis auf Serverseite
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
7 Beispiel KonfigurationKonfigurationsdatei ohne Filter
input { file { path => "/home/markus/Downloads/apache.log" start_position => "beginning" } }
output { stdout { debug => true } }
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"}
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 }}
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\""}
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}'' ] }}
12elasticsearch + KibanaBeispielkonfiguration ohne Filter
input { file { path => "/home/markus/Downloads/testlog.log" start_position => "beginning" type => "log" }}output { elasticsearch { embedded => true }}
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
14Quellen
logstash.netgoogle.desemicomplete.comFolien by Jordan Sissel
15Vielen Dank für Ihre Aufmerksamkeit
Kontakt
Markus RodiAuszubildender Fachinformatiker für Systemintegration
inovex GmbHOffice KarlsruheLudwig-Erhardt-Allee 676131 Karlsruhe
+49 173 3181 063markus.rodi@inovex.de