以下是原始日誌:花點時間從日誌文件
2017年9月17日8點34分54秒181409 10.110.82.122 200 TCP_TUNNELED 4440 1320 CONNECT TCP cdn.appdynamics.com 443/- ANILADE - 10.100 .134.6 - - 「Mozilla/5.0(Windows NT 10.0; Win64; x64)AppleWebKit/537.36(KHTML,如Gecko)Chrome/60.0.3112.113 Safari/537.36」OBSERVED「Technology/Internet」 - 10.100.134.6
This是我的logstash配置文件:
input {
beats {
port => "5044"
}
}
filter
#start of filter
{
grok
#start of grok filter
{
match =>
#start of match
{"message"=>"%{TIMESTAMP_ISO8601:@timestamp} (%{NUMBER:time_taken}|\-) (%{IP:sourceIP}|\-) (%{NUMBER:status}|\-) (%{WORD:action}|\-) (%{NUMBER:scBytes}|\-) (%{NUMBER:csBytes}|\-) (%{WORD:method}|\-) (%{WORD:uri_scheme}|\-) (%{URIHOST:url}|\-) (%{NUMBER:port}|\-) (?<uri_path>([a-zA-Z0-9\/\.\?\-\_]+)|(\/)) (?<uri_query>([a-zA-Z0-9\/\.\?\-\=\&\%]+)) (?<username>([a-zA-Z0-9\/\.\?\-]+)) (?<auth_group>([a-zA-Z0-9\/\.\?\-]+)) (?<destIP>([a-zA-Z0-9\.\-]+)) (?<content_type>([a-zA-Z0-9\-\/\;\%\=]+)) (?<referer>[a-zA-Z0-9\-\/\;\%\=\:\.]+) (%{QUOTEDSTRING:user_agent}|\-) (%{WORD:filter_result}|\-) (%{QUOTEDSTRING:category}|\-) (?<vir_id>([a-zA-Z0-9\-\/.])) (%{IP:proxyIP}|\-)"
}
#end of match
}
#end of grok
date
#start of date filter
{
match=>["@timestamp","ISO8601"]
}
#end of date filter
}
#end of filter
output
{
elasticsearch
{
hosts => ["localhost:9200"]
index => proxylog
}
}
我想從日誌中選擇時間,因此我使用日期篩選器s在Date Plugin文檔中建議。但是不管配置如何,我可以看到logstash elasticsearch在Kibana中查看時在@timestamp字段中顯示了索引時間。我找不到我錯過了什麼或者我錯在哪裏。我試圖不通過與
%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day} %{TIME:time}
替換它並和添加字段時間戳作爲使用在神交濾波器的TIMESTAMP_ISO8601:
add_field=>["timestamp","%{year}-%{month}-%{day} %{time}"]
然後改變日期過濾器配置爲
date{
match=>["timestamp","YYYY-MM-DD HH:mm:ss"]
remove_field=>["timestamp","year","month","day"]}
}
和發現沒有運氣。有人能指出一個解決方案,因爲在elasticsearch和stackoverflow的論壇上發現的任何鏈都沒有幫助。任何人都可以告訴我是否需要更改filebeat的任何配置,因爲我正在使用filebeat將日誌發送到logstash。
在你原來的配置,刪除@中'{「消息」 =>「%{TIMESTAMP_ISO8601:@timestamp}'和'match => [「@ timestamp」,「ISO8601」]'然後再試一次嗎?可能是因爲這個。 – baudsp
會試一試,讓你知道它是怎麼回事。@baudsp – Akash