【问题标题】:Create index in kibana without using kibana不使用 kibana 在 kibana 中创建索引
【发布时间】:2017-05-17 06:30:24
【问题描述】:

我对 elasticsearch-kibana-logstash 非常陌生,似乎找不到解决方案。

我正在尝试创建将在 kibana 中看到的索引,而无需使用开发工具部分中的 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/(它显示的端口) 它似乎没有任何错误

非常感谢您的帮助!

【问题讨论】:

  • 您的意思是,您在http://localhost:9200 的索引列表中找不到您尝试使用logstash 创建的new-index
  • 在 kibana 中找不到.. 不应该到达那里吗...?
  • 我也尝试设置hosts => ["http://localhost:5601/"](kibana的端口)也没有成功
  • 不,它不会自动出现在 Kibana 中,您必须在 Management > Add New 中创建它,使用与您使用 logstash 创建的索引相同的名称。

标签: elasticsearch indexing configuration logstash kibana


【解决方案1】:

很明显,您将无法在 Kibana 中找到您使用 logstash 创建的索引,除非您在 KibanaManagemen 部分手动创建它。

确保您与使用logstash 创建的索引具有相同的名称。看看doc,它传达了:

定义索引模式时,与该模式匹配的索引必须 存在于 Elasticsearch 中。这些索引必须包含数据。

这几乎是说应该存在索引供您在Kibana 中创建索引。希望对您有所帮助!

【讨论】:

  • 谢谢,我想我错过了理解这些工具的概念......我认为这是一个连接的工具,但我想它不是
  • 是的,没错。它基本上是一堆产品,有自己的处理方式。但随后 ES 充当堆栈周围的核心。
【解决方案2】:

我实际上已经成功创建了索引,即使没有先在 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 文件

【讨论】:

    【解决方案3】:

    您可以使用https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html 在弹性搜索中直接创建索引 这些索引可以在 Kibana 中使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 1970-01-01
      • 2017-05-25
      • 2021-01-16
      • 2018-07-28
      • 2017-07-31
      相关资源
      最近更新 更多