From 3bbaf6ca989731b9dcc8224b1b1de3fb1db50b8d Mon Sep 17 00:00:00 2001 From: ryone Date: Mon, 22 Jan 2018 01:49:01 +0900 Subject: [PATCH] Fix for Support Jolokia agent in proxy mode (#4421) --- .../module/jolokia/jmx/_meta/docs.asciidoc | 4 ++++ metricbeat/module/jolokia/jmx/config.go | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/metricbeat/module/jolokia/jmx/_meta/docs.asciidoc b/metricbeat/module/jolokia/jmx/_meta/docs.asciidoc index 3956b4cc45d..5cf11848d6c 100644 --- a/metricbeat/module/jolokia/jmx/_meta/docs.asciidoc +++ b/metricbeat/module/jolokia/jmx/_meta/docs.asciidoc @@ -22,6 +22,10 @@ mapping: attributes: - attr: Uptime field: uptime + target: + url: "service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi" + user: "jolokia" + password: "s!cr!t" --- In case the underlying attribute is an object (e.g. see HeapMemoryUsage attribute in java.lang:type=Memory) its diff --git a/metricbeat/module/jolokia/jmx/config.go b/metricbeat/module/jolokia/jmx/config.go index a711f3059d6..33f1e95db64 100644 --- a/metricbeat/module/jolokia/jmx/config.go +++ b/metricbeat/module/jolokia/jmx/config.go @@ -5,6 +5,7 @@ import "encoding/json" type JMXMapping struct { MBean string Attributes []Attribute + Target Target } type Attribute struct { @@ -12,6 +13,12 @@ type Attribute struct { Field string } +type Target struct { + Url string + User string + Password string +} + // RequestBlock is used to build the request blocks of the following format: // // [ @@ -35,6 +42,13 @@ type RequestBlock struct { Type string `json:"type"` MBean string `json:"mbean"` Attribute []string `json:"attribute"` + Target TargetBlock `json:"target"` +} + +type TargetBlock struct { + Url string `json:"url"` + User string `json:"user"` + Password string `json:"password"` } func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]string, error) { @@ -45,6 +59,11 @@ func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]strin rb := RequestBlock{ Type: "read", MBean: mapping.MBean, + Target: TargetBlock { + Url: mapping.Target.Url, + User: mapping.Target.User, + Password: mapping.Target.Password, + }, } for _, attribute := range mapping.Attributes {