elasticsearch - 电报输出到 Elasticsearch : "health check timeout: no Elasticsearch node available"

标签 elasticsearch telegraf telegraf-plugins telegraf-output-plugins

我无法使用 Telegraf 输出插件连接到 Elasticsearch 实例。

我通过 Elasticsearch 服务创建了一个 Elasticsearch 设置。我在 Kibana 中为它创建了一个用户和密码(连接到一个角色)。

然后我为它设置了一个 Telegraf 输出:

  [[outputs.elasticsearch]]
  urls = [ "https://hostname:port" ] # required.

  timeout = "5s"

  enable_sniffer = false

  health_check_interval = "10s"

  ## HTTP basic authentication details.
  username = "my_username"
  password = "my_password"

  index_name = "device_logs" # required.

  insecure_skip_verify = true

  manage_template = true

  template_name = "telegraf"

  overwrite_template = false

但是当我尝试以此启动 Telegraf 时,它只会给出错误,

[agent] Failed to connect to [outputs.elasticsearch], retrying in 15s, error was 'health check timeout: no Elasticsearch node available'



连接失败似乎起源于 golang 的 net/http 库的深处,此时我不知道如何获得一些更有用的输出。

我尝试过的事情:

事情#1 :我测试了 curl :
curl -u my_username:my_password -X POST "https://hostname:port/device_logs/_doc" -H 'Content-Type: application/json' -d'
    {
        "name": "John Doe"
    }'

这工作正常。

事情 #2 :我创建了一个简单的 Go 程序来从 Go 连接到 elasticsearch:
package main

import (
    "log"
    "time"
    "gopkg.in/olivere/elastic.v3"
)

func main() {
    // configure connection to ES
    client, err := elastic.NewClient(elastic.SetURL("https://hostname:port"))
    if err != nil {
      panic(err)
    }
    log.Printf("client.running? %v",client.IsRunning())
    if ! client.IsRunning() {
      panic("Could not make connection, not running")
    }
}

.. 它以相同的“没有可用的 Elasticsearch 节点”触发了第一次 panic 。

事情#3 : 我试着在那个 Go 程序上运行 gdb 来调试它。
一旦我调用 NewClient,它就会跳到汇编,所以我无法真正了解 net/http 内部发生了什么。

我以前从未使用过 Go,所以我希望避免花费数小时学习 Go、探索和调试来解决这里希望是一个简单的问题。

关于如何在此处获取更多信息或为什么失败的任何想法?我可以使用 Go 的构建或运行时标志吗? gdb-with-Go 调试提示,以便我可以进入 Go 库代码? Elasticsearch 客户端诀窍?

最佳答案

为了回答我自己的问题,这里的问题原来是角色权限。 Elasticsearch 的 Telegraf 输出插件需要 监控 管理索引模板 要启用权限,否则它将无法连接到 Elasticsearch 服务器而不打印任何有关原因的信息。

顺便说一句:构建 golang 代码并能够调试到它调用的库:go build -gcflags=all="-N -l"

关于elasticsearch - 电报输出到 Elasticsearch : "health check timeout: no Elasticsearch node available",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58466777/

相关文章:

arrays - 在elasticsearch中只返回字符串数组中的一个元素

python - 如何解决 Telegraf 中的此错误?

linux - 如何使用 telegraf procstat 插件获取进程名称和进程状态(运行或停止)

python - 类型错误 : search() got an unexpected keyword argument 'doc_type' for elastic search version 5. 6

elasticsearch - Elasticsearch映射空字符串

elasticsearch - Elastic Search 5.1 将使用哪个版本的 Kibana?

influxdb - 如何舍入 telegraf 中的输出值?

telegraf - Telegraf 能否在网络中断期间将指标数据存储在本地系统上并稍后转发?

javascript - Try/Catch 不能防止崩溃

influxdb - 如何替换 Telegraf 的默认时间戳?