在不使用 kibana 的情况下在 kibana 中创建索引
Create index in kibana without using kibana
我是 elasticsearch-kibana-logstash 的新手,似乎找不到解决方案。
我正在尝试创建我将在 kibana 中看到的索引,而无需使用 Dev Tools 部分中的 POST 命令。
我设置了test.conf-
input {
file {
path => "/home/user/logs/server.log"
type => "test-type"
start_position => "beginning"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "new-index"
}
}
然后
bin/logstash -f test.conf
来自 logstash 目录
我得到的是我在 kibana(索引模式部分)中找不到新索引,当我使用 elasticsearch - http://localhost:9200/new-index/
它出现错误,当我转到 http://localhost:9600/
(它显示的端口)它似乎没有任何错误
非常感谢您的帮助!!
很明显,您将无法在 Kibana 中找到使用 logstash
创建的索引,除非您在 Managemen
部分中手动创建它 Kibana
.
确保您使用 logstash
创建的索引名称相同。看看 doc,它表示:
When you define an index pattern, indices that match that pattern must
exist in Elasticsearch. Those indices must contain data.
这几乎说明了索引应该存在,以便您在 Kibana
中创建索引。希望对您有所帮助!
即使没有先在 Kibana 中创建索引,我实际上已经成功创建了它
我使用了以下配置文件 -
input {
file {
path => "/home/hadar/tmp/logs/server.log"
type => "test-type"
id => "NEWTRY"
start_position => "beginning"
}
}
filter {
grok {
match => { "message" => "%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day} %{HOUR:hour}:%{MINUTE:minute}:%{SECOND:second} - %{LOGLEVEL:level} - %{WORD:scriptName}.%{WORD:scriptEND} - " }
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "new-index"
codec => line { format => "%{year}-%{month}-%{day} %{hour}:%{minute}:%{second} - %{level} - %{scriptName}.%{scriptEND} - \"%{message}\"" }
}
}
我确保该索引不在 Kibana 中(我也尝试使用其他索引名称以确保......)并且最终我确实在两个 Kibana 中都看到了带有日志信息的索引(我添加了它在索引模式部分)和 Elasticsearch 当我去 http://localhost:9200/new-index
我唯一应该做的就是在每个 Logstash 运行
之后删除在 data/plugins/inputs/file/
下创建的 .sincedb_XXX
文件
或
另一种解决方案(仅适用于测试环境)是将 sincedb_path=>"/dev/null"
添加到输入文件插件,这表明不创建 .sincedb_XXX
文件
您可以使用 https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html 在弹性搜索中直接创建索引
这些索引可以在 Kibana 中使用。
我是 elasticsearch-kibana-logstash 的新手,似乎找不到解决方案。
我正在尝试创建我将在 kibana 中看到的索引,而无需使用 Dev Tools 部分中的 POST 命令。
我设置了test.conf-
input {
file {
path => "/home/user/logs/server.log"
type => "test-type"
start_position => "beginning"
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "new-index"
}
}
然后
bin/logstash -f test.conf
来自 logstash 目录
我得到的是我在 kibana(索引模式部分)中找不到新索引,当我使用 elasticsearch - http://localhost:9200/new-index/
它出现错误,当我转到 http://localhost:9600/
(它显示的端口)它似乎没有任何错误
非常感谢您的帮助!!
很明显,您将无法在 Kibana 中找到使用 logstash
创建的索引,除非您在 Managemen
部分中手动创建它 Kibana
.
确保您使用 logstash
创建的索引名称相同。看看 doc,它表示:
When you define an index pattern, indices that match that pattern must exist in Elasticsearch. Those indices must contain data.
这几乎说明了索引应该存在,以便您在 Kibana
中创建索引。希望对您有所帮助!
即使没有先在 Kibana 中创建索引,我实际上已经成功创建了它
我使用了以下配置文件 -
input {
file {
path => "/home/hadar/tmp/logs/server.log"
type => "test-type"
id => "NEWTRY"
start_position => "beginning"
}
}
filter {
grok {
match => { "message" => "%{YEAR:year}-%{MONTHNUM:month}-%{MONTHDAY:day} %{HOUR:hour}:%{MINUTE:minute}:%{SECOND:second} - %{LOGLEVEL:level} - %{WORD:scriptName}.%{WORD:scriptEND} - " }
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "new-index"
codec => line { format => "%{year}-%{month}-%{day} %{hour}:%{minute}:%{second} - %{level} - %{scriptName}.%{scriptEND} - \"%{message}\"" }
}
}
我确保该索引不在 Kibana 中(我也尝试使用其他索引名称以确保......)并且最终我确实在两个 Kibana 中都看到了带有日志信息的索引(我添加了它在索引模式部分)和 Elasticsearch 当我去 http://localhost:9200/new-index
我唯一应该做的就是在每个 Logstash 运行
之后删除在data/plugins/inputs/file/
下创建的 .sincedb_XXX
文件
或
另一种解决方案(仅适用于测试环境)是将 sincedb_path=>"/dev/null"
添加到输入文件插件,这表明不创建 .sincedb_XXX
文件
您可以使用 https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html 在弹性搜索中直接创建索引 这些索引可以在 Kibana 中使用。