我已经设置了一个ELK堆栈来索引我的Akamai日志。我在Logstash中创建了一个conf文件,并在加载Logstash时加载它。我的日志文件只是读取
管道主要开始
但是,我无法在Kibana中创建索引。我看到了消息
无法获取映射
我通过调试器运行了我的grok语句,似乎我捕获了所有内容。这是我的配置:
input {
file {
path => "C:\Akamai_Logs\US\*"
start_position => "beginning"
}
}
filter {
grok {
match => ["message", "%{DATE:date} %{TIME:time} %{IP:client} %{WORD:method} %{URIPATH:URI} %{NUMBER:status} %{NUMBER:bytes} %{NUMBER:time_taken} %{NOTSPACE:refererr} %{QS:user_agent} %{GREEDYDATA:cookie}"]
}
}
output {
stdout {codec => rubydebug}
elasticsearch {
hosts => ["localhost:9200"]
}
}
以下是其中一个日志的示例行
2016-06-14 14:03:42 1.1.1.1 GET / origin-uri 200 26222 0“referrer”“user agent”“cookie string”
日志文件中的间距是否会导致任何问题索引?我只是错过了其他的东西吗?
编辑:忘记添加我的Logstash模板
{
"template": "logstash-*",
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"index" : {
"query" : { "default_field" : "@message" },
"store" : { "compress" : { "stored" : true, "tv": true } }
}
},
"mappings": {
"_default_": {
"_all": { "enabled": false },
"_source": { "compress": true },
"dynamic_templates": [
{
"string_template" : {
"match" : "*",
"mapping": { "type": "string", "index": "not_analyzed" },
"match_mapping_type" : "string"
}
}
],
"properties" : {
"@date": { "type": "date", "format": "yyyy-MM-dd" },
"@time": { "type": "time", "format": "hh:mm:ss" },
"@hostip": {"type": "string","index" : "not_analyzed"},
"@method": {"type": "string","index" : "not_analyzed"},
"@page": {"type": "string","index" : "not_analyzed"},
"@status": {"type": "integer"},
"@bytes": {"type": "integer"},
"@timetaken": {"type": "integer"},
"@referrer": {"type": "string","index" : "not_analyzed"},
"@useragent": {"type": "string","index" : "not_analyzed"},
"@cookie": {"type": "string","index" : "not_analyzed"}
}
}
}
}
答案 0 :(得分:1)
用这个替换你的file
输入(使用正斜杠而不是反斜杠),然后它应该有用。
input {
file {
path => "C:/Akamai_Logs/US/*.*"
start_position => "beginning"
}
}
<强>更新强>
由于您拥有自己的索引模板文件,请务必修改elasticsearch
输出,如下所示:
output {
elasticsearch {
hosts => ["localhost:9200"]
template => "/path/to/logstash-template.json"
template_overwrite => true
}
}
也可以确保删除logstash模板(如果ES中已存在
)curl -XDELETE localhost:9200/_template/logstash