【问题标题】:Multiple paths in http module - metricbeatshttp模块中的多个路径 - metricbeat
【发布时间】:2018-02-26 20:13:04
【问题描述】:

我正在使用 metricbeats 的 http 模块来监控 jmx。我正在使用 http 模块而不是 jolokia 模块,因为此时它缺乏通配符支持。文档中的示例配置如下。

- module: http
  metricsets: ["json"]
  period: 10s
  hosts: ["localhost:80"]
  namespace: "json_namespace"
  path: "/jolokia/"
  body: '{"type" : "read", "mbean" : "kafka.consumer:type=*,client-id=*", "attribute" : "count"}'
  method: "POST"

这工作正常,我能够将数据获取到 kibana。当我将其配置为调用多个路径时,我看到了错误。

- module: http
      metricsets: ["json"]
      enabled: true
      period: 10s
      hosts: ["localhost:80"]
      namespace: "metrics"
      method: POST
      paths:
        - path: "/jolokia/"
          body: '{"type" : "read", "mbean" : "kafka.consumer:type=*,client-id=*", "attribute" : "bytes-consumed-rate"}'
        - path: "/jolokia/"
          body: '{"type" : "read", "mbean" : "kafka.consumer:type=*,client-id=*", "attribute" : "commit-latency-avg"}'

这似乎不是正确的配置,我看到 http 事件发生了故障。

2018/02/26 19:53:18.315740 metrics.go:39: INFO Non-zero metrics in the last 30s: beat.info.uptime.ms=30000 beat.memstats.gc_next=4767600 beat.memstats.memory_alloc=4016168 beat.memstats.memory_total=47474256 libbeat.config.module.running=3 libbeat.output.read.bytes=4186 libbeat.output.write.bytes=16907 libbeat.pipeline.clients=7 libbeat.pipeline.events.active=0 libbeat.pipeline.events.published=18 libbeat.pipeline.events.total=18 libbeat.pipeline.queue.acked=18 metricbeat.http.json.events=3 metricbeat.http.json.failures=3

关于如何设置 http 模块的文档:Example configuration

【问题讨论】:

    标签: elasticsearch kibana metricbeat


    【解决方案1】:

    我必须查询我的 REST API 的多个 URL,我可以通过使用具有不同主机 URL 的多个“http”模块来实现这一点,示例如下:

    - module: http
      metricsets: ["json"]
      period: 3600s
      hosts: ["http://localhost/Projects/method1/"]
      namespace: "testmethods"
      method: "GET"
      enabled: true
    - module: http
      metricsets: ["json"]
      period: 3600s
      hosts: ["http://localhost/Projects/method2/"]
      namespace: "testmethods"
      method: "GET"
      enabled: true
    

    这让我实现了同一个模块有多个路径

    【讨论】:

    • 我最终也对多个模块做了类似的事情。在我的情况下,主机保持不变,我正在使用不同的机构进行 POST 调用。
    【解决方案2】:

    http 模块的 json 指标集不支持多路径。

    您在配置示例中找到的是 http 模块的 server 指标集。此指标集不查询 URL。相反,它会在指定端口上打开一个 http 服务器,并且可以接收多个路径上的输入,这些路径用于将数据分隔到不同的命名空间中。

    【讨论】:

    • 谢谢,我现在不得不配置多个模块。工作,但似乎不是很干净。
    猜你喜欢
    • 1970-01-01
    • 2023-03-13
    • 2017-01-06
    • 2019-06-04
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 2012-11-08
    • 1970-01-01
    相关资源
    最近更新 更多