我正在試驗ELK來分析我們的日誌文件。在可用的文檔之後,設法在我的電腦中設置了堆棧。現在我正面臨着彈性搜索索引創建的問題。以前我是用filebeat - > logstash - > elasticsearch - > kibana組合,並使用以下logstash.conf文件能夠將數據發送到elasticsearchELK Stack - Elasticsearch索引創建(logstash)
input {
beats {
port => 5044
type => "log"
}
}
output {
elasticsearch {
hosts => "localhost:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
}
而在彈性搜索時,評價以
"filebeat-*"
從表達
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
現在我改變了logstash.conf根據我的實際日誌文件
input {
file
{
path => "C:\logs\application.log"
start_position => "beginning"
codec =>
multiline {
charset => "ISO-8859-1"
pattern => "^%{TIMESTAMP_ISO8601}"
max_lines => 1000
negate => true
what => "previous"
}
}
}
filter {
mutate {
gsub => [ "message", "\r", "" ]
}
grok {
patterns_dir => "./patterns"
match => {"message" => "%{TIMESTAMP_ISO8601:timestamp} %{LOGLEVEL1:loglevel} %{THREAD:thread} %{IP5:remoteipaddress} %{JAVA:logclass} %{GREEDYDATA:details}"}
add_field => [ "received_at", "%{@timestamp}" ]
add_field => [ "received_from", "%{host}" ]
}
date {
match => [ "timestamp", "yyyy-MM-dd HH:mm:ss,SSS" ]
remove_field => [ "timestamp" ]
}
}
output {
elasticsearch {
hosts => "localhost:9200"
manage_template => false
index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
document_type => "%{[@metadata][type]}"
}
file {
path => "C:\logs\output.txt"
}
}
在這種情況下,logstash對conf文件很滿意,但是我建議用於彈性搜索的索引沒有被正確評估。
如果我檢查用頭插件彈性搜索,
http://localhost:9200/_plugin/head/
該指數顯示爲
%{[@metadata][beat]}-
我不知道爲什麼索引表達式不被計算現在。任何解決此問題的指針都會有所幫助。
由於提前, 聖