3

我正在使用 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 模块的文档:示例配置

4

2 回答 2

2

我必须查询我的 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

这使我实现了同一模块的多个路径

于 2018-03-29T08:50:46.537 回答
1

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

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

于 2018-03-16T12:36:47.817 回答