Skip to content

Commit

Permalink
Fix for Support Jolokia agent in proxy mode (elastic#4421)
Browse files Browse the repository at this point in the history
  • Loading branch information
whale-shark committed Jan 21, 2018
1 parent 7dd17a3 commit 3bbaf6c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions metricbeat/module/jolokia/jmx/_meta/docs.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions metricbeat/module/jolokia/jmx/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,20 @@ import "encoding/json"
type JMXMapping struct {
MBean string
Attributes []Attribute
Target Target
}

type Attribute struct {
Attr string
Field string
}

type Target struct {
Url string
User string
Password string
}

// RequestBlock is used to build the request blocks of the following format:
//
// [
Expand All @@ -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) {
Expand All @@ -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 {
Expand Down

0 comments on commit 3bbaf6c

Please sign in to comment.