Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - Grok là một cách để khớp một dòng với biểu thức chính quy,ánh xạ các phần cụ thể của dòng vào các trường chuyên dụng và thực hiện hành động dựa trên anh xạ này.
- - Pattern dựng sẵn:
- https://github.com/logstash-plugins/logstash-patterns-core/blob/master/patterns/grok-patterns
- - Viết mẫu tùy chỉnh:
- => Format cơ bản cho 1 Logstash grok filter:
- %{PATTERN:FieldName}
- - List thao tác, cùng với loại giá trị đầu vào và giá trị mặc định:
- https://www.elastic.co/guide/en/logstash/current/plugins-filters-grok.html#_synopsis_125
- - grok debug tool: https://grokdebug.herokuapp.com/
- https://cuongquach.com/kiem-tra-cau-hinh-khuon-mau-logstash-grok-bang-cong-cu-online.html
- - Example:
- -> httpd/access_log
- [Format log]
- 103.53.170.84 - - [26/Jun/2019:10:36:04 +0700] "GET /resource_providers/56643342-6252-432f-82bd-d206429b8602/inventories HTTP/1.1" 200 400 "-" "nova-compute keystoneauth1/3.10.0 python-requests/2.19.1 CPython/2.7.5"
- [Grok pattern]
- %{IPORHOT:clientip} %{USER:ident} %{USER:auth} %{HTTPDATE:timestamp} "%{WORD:verb} %{DATA:request} HTTP/%{NUMBER:httpversion}" %{NUMBER:response:int} (?:-|%{NUMBER:bytes:int}) %{QS:referrer} %{QS:agent}
- {
- "message" => "103.53.170.84 - - [26/Jun/2019:10:36:04 +0700] "GET /resource_providers/56643342-6252-432f-82bd-d206429b8602/inventories HTTP/1.1" 200 400 "-" "nova-compute keystoneauth1/3.10.0 python-requests/2.19.1 CPython/2.7.5"",
- "@timestamp" => "2019-6-26T17:36:04.000Z",
- "@version" => "1",
- "host" => "-",
- "clientip" => "103.53.170.84",
- "ident" => "-",
- "auth" => "-",
- "timestamp" => "",
- "verb" => "GET",
- "request" => "/resource_providers/56643342-6252-432f-82bd-d206429b8602/inventories",
- "httpversion" => "1.1",
- "response" => "200",
- "bytes" => "400",
- "referrer" => ""-"",
- "agent" => ""nova-compute keystoneauth1/3.10.0 python-requests/2.19.1 CPython/2.7.5""
- }
- -> /var/log/nova/nova-manage.log
- [format log]
- 2019-06-24 14:55:52.352 9871 INFO migrate.versioning.api [req-a48666be-120b-4452-88ed-0473d1573d5b - - - - -] done
- [grok pattern]
- %{URIHOST} %{HAPROXYTIME} 9871 INFO %{JAVACLASS} %{SYSLOG5424SD} done
- %{TIMESTAMP_ISO8601:timetamp} %{JAVACLASS} %{LOGLEVE:loglevel} %{NOTSPACE:requestid}
- -> /var/log/glance/registry.log
- [format log]
- 2019-06-27 11:00:34.127 9225 INFO eventlet.wsgi.server [-] 106.75.85.117 - - [27/Jun/2019 11:00:34] "GET / HTTP/1.1" 401 309 0.003525
- [grok pattern]
- %{URIHOST} %{HAPROXYTIME} 9225 INFO %{JAVACLASS} [-] %{IP} - - [27%{URIPATHPARAM} %{HAPROXYTIME}] %{QS} 401 309 %{JAVACLASS}
- -> /var/log/glance/api.log
- [format log]
- 2019-06-24 18:04:30.772 9229 INFO eventlet.wsgi.server [req-0ad053d6-f4b2-43eb-bbb8-d087ef300500 e27b211bfcea4e05ab36e2d967e37d05 e45a672c9a634fdb9650d4483e276936 - default default] 103.53.170.82 - - [24/Jun/2019 18:04:30] "GET /v2/images/11a2d0cd-d4c9-43d2-9a88-dac794374194 HTTP/1.1" 200 988 0.013480
- [grok pattern]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement