【发布时间】:2015-05-22 17:07:47
【问题描述】:
我有这个日志文件:http://dpaste.com/3FE2VNY
我只想提取某些信息,例如日期时间和发布的事件数量。我将其放入弹性搜索的尝试导致logstash挂起。不知道我做错了什么,因为我是新手。
我试图做的是简单地抓取日志文件中的所有内容并将其传递给 elasticsearch。我知道grok 必须用于抓取特定部件,但我还没有达到那个水平。
我的目标是提取:
start: Mon Apr 27 13:35:25 2015
finish: Mon Apr 27 13:35:36 2015
number of events posted: 10
日志文件:
test_web_events.py: START: Mon Apr 27 13:35:25 2015
# TESTCASE TestWebPost ==================================================
# START TEST METHOD #################################: test_10_post_valid_json
[2015-04-27T13:35:25.657887] HTTP DELETE http://pppdc9prd3net:8080/rastplatz/v1/sink/db?k0=bradford4
{}
HTTP response: 200
0
POSTING event_id b29b6c7c-48cd-4cd9-b3c4-aa0a7edc1f35 to businessevent
Content-Type: text/plain
POSTING event_id 13678af1-3e3a-4a6e-a61c-404eb94b9768 to businessevent
Content-Type: text/plain
POSTING event_id 47b70306-2e7c-4cb2-9e75-5755d8d101d4 to businessevent
Content-Type: text/plain
POSTING event_id 6599cdb2-0630-470d-879d-1130cf70c605 to businessevent
Content-Type: text/plain
POSTING event_id d088ce29-fa0d-4f45-b628-045dba1fd045 to businessevent
Content-Type: text/plain
POSTING event_id 07d14813-b561-442c-9b86-dc40d1fcc721 to businessevent
Content-Type: text/plain
POSTING event_id b6aea24a-5424-4a0f-aac6-8cbaecc410db to businessevent
Content-Type: text/plain
POSTING event_id 016386bd-eac5-4f1c-8afc-a66326d37ddb to businessevent
Content-Type: text/plain
POSTING event_id 6610485d-71af-4dfa-9268-54be5408a793 to businessevent
Content-Type: text/plain
POSTING event_id 92786434-02f7-4248-a77b-bdd9d33b57be to businessevent
Content-Type: text/plain
Posted 10 events
# END TEST METHOD ###################################: test_10_post_valid_json
test_web_events.py: FINISH: Mon Apr 27 13:35:36 2015
配置文件:
input {
file {
path => "/home/bli1/logstash-1.5.0/tmp/bradfordli2_post.log"
codec => multiline {
pattern => "^."
negate => true
what => "previous"
}
}
}
output {
elasticsearch { protocol => http host => "127.0.0.1:9200"}
stdout { codec => rubydebug }
}
【问题讨论】:
-
您想将这 3 条信息提取为单独的日志事件吗?那么你根本不需要使用多行......
-
@markus 我想提取这3条信息,然后将其作为一个事件发送到弹性搜索