我正在努力获得Logstash,Elasticsearch&的组合。 Kibana在我的Windows 7环境中工作。
我已经设置了所有3个,它们似乎都运行良好,Logstash和Elasticsearch作为Windows服务运行,Kibana作为IIS中的网站运行。
Logstash正在http://localhost:9200
我有一个Web应用程序在.txt中创建日志文件,格式为:
日期时间= [日期时间],值= [xxx]
在此目录中创建日志文件:
d:\ wwwroot的\日志\错误\
我的logstash.conf文件如下所示:
input {
file {
format => ["plain"]
path => ["D:\wwwroot\Logs\Errors\*.txt"]
type => "testlog"
}
}
output {
elasticsearch {
embedded => true
}
}
我的Kibana config.js文件如下所示:
define(['settings'],
function (Settings) {
return new Settings({
elasticsearch: "http://localhost:9200",
kibana_index: "kibana-int",
panel_names: [
'histogram',
'map',
'pie',
'table',
'filtering',
'timepicker',
'text',
'fields',
'hits',
'dashcontrol',
'column',
'derivequeries',
'trends',
'bettermap',
'query',
'terms'
]
});
});
当我查看Kibana时,我看到错误:
在
http://localhost:9200/_all/_mapping
找不到索引。请创建至少一个索引。如果您使用代理,请确保正确配置。
我不知道如何创建索引,所以如果有人能说明我做错了什么就会很好。
答案 0 :(得分:3)
目前似乎没有任何东西可以用于弹性搜索。
对于当前版本的es(0.90.5),我不得不使用elasticsearch_http输出。弹性搜索输出似乎与0.90.3密切相关。
例如:这是我的配置是如何将log4j格式转换为弹性搜索
input {
file {
path => "/srv/wso2/wso2am-1.4.0/repository/logs/wso2carbon.log"
path => "/srv/wso2/wso2as-5.1.0/repository/logs/wso2carbon.log"
path => "/srv/wso2/wso2is-4.1.0/repository/logs/wso2carbon.log"
type => "log4j"
}
}
output {
stdout { debug => true debug_format => "ruby"}
elasticsearch_http {
host => "localhost"
port => 9200
}
}
对于我的文件格式,我也有一个grok过滤器 - 正确解析它。
filter {
if [message] !~ "^[ \t\n]+$" {
# if the line is a log4j type
if [type] == "log4j" {
# parse out fields from log4j line
grok {
match => [ "message", "TID:%{SPACE}\[%{BASE10NUM:thread_name}\]%{SPACE}\[%{WORD:component}\]%{SPACE}\[%{TIMESTAMP_ISO8601:timestamp}\]%{SPACE}%{LOGLEVEL:level}%{SPACE}{%{JAVACLASS:java_file}}%{SPACE}-%{SPACE}%{GREEDYDATA:log_message}" ]
add_tag => ["test"]
}
if "_grokparsefailure" not in [tags] {
mutate {
replace => ["message", " "]
}
}
multiline {
pattern => "^TID|^ $"
negate => true
what => "previous"
add_field => {"additional_log" => "%{message}"}
remove_field => ["message"]
remove_tag => ["_grokparsefailure"]
}
mutate {
strip => ["additional_log"]
remove_tag => ["test"]
remove_field => ["message"]
}
}
} else {
drop {}
}
}
另外,我会获得elasticsearch head插件来监控elasticsearch中的内容 - 轻松验证数据和状态。