3

I am using http module of metricbeats to monitor jmx. I am using http module instead of the jolokia module because it lacks wildcard support at this point. The example configuration in the documents is as follows.

- 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"

This works fine and I am able to get data to kibana. I see errors when I configure it as follows to call multiple paths.

- 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"}'

This does not seem to be the right config and I see that the http events have had failures.

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

Documentation on how to setup http module: Example configuration

Kumaran Senapathy
  • 1,233
  • 4
  • 18
  • 30

2 Answers2

2

I had to query multiple URL's of my REST API and I could achieve that by having multiple modules of "http" with different host URL's following is the example:

- 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

This made me achieve have multiple paths for the same module

Ikbel
  • 1,817
  • 1
  • 17
  • 30
Poonam
  • 81
  • 1
  • 2
  • I ended up doing something similar with multiple modules too. In my case, the host remained the same and I was making a POST call with different bodies. – Kumaran Senapathy Mar 29 '18 at 17:40
1

Multiple paths are not supported by the http module's json metricset.

What you found in the config example is for the http module's server metricset. This metricset does not query URLs. Instead it opens an http server on the specified port, and can receive input on multiple paths which are used to separate data into different namespaces.

BennyInc
  • 193
  • 1
  • 5