【问题标题】:telegraf output to Elasticsearch: "health check timeout: no Elasticsearch node available"电报输出到 Elasticsearch:“健康检查超时:没有可用的 Elasticsearch 节点”
【发布时间】:2019-10-19 18:25:56
【问题描述】:

我无法使用 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] 连接[outputs.elasticsearch]失败,15s后重试,错误为'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 节点”遇到第一个恐慌。

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

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

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

【问题讨论】:

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


    【解决方案1】:

    为了回答我自己的问题,这里的问题原来是角色权限。 Elasticsearch 的 Telegraf 输出插件需要同时启用 monitorma​​nage_index_templates 权限,否则它将无法连接到 Elasticsearch 服务器而不打印任何有关原因的信息.

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-11-18
      • 1970-01-01
      • 1970-01-01
      • 2018-07-11
      • 1970-01-01
      • 2020-12-03
      • 2020-11-16
      • 2014-06-24
      相关资源
      最近更新 更多