Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Jolokia agent in proxy mode #6475

Merged
merged 17 commits into from
May 14, 2018
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
27 changes: 24 additions & 3 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 {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type Target should have comment or be unexported

Url string

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct field Url should be URL

User string
Password string
}

// RequestBlock is used to build the request blocks of the following format:
//
// [
Expand All @@ -32,9 +39,16 @@ type Attribute struct {
// }
// ]
type RequestBlock struct {
Type string `json:"type"`
MBean string `json:"mbean"`
Attribute []string `json:"attribute"`
Type string `json:"type"`
MBean string `json:"mbean"`
Attribute []string `json:"attribute"`
Target *TargetBlock `json:"target,omitempty"`
}

type TargetBlock struct {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exported type TargetBlock should have comment or be unexported

Url string `json:"url"`

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

struct field Url should be URL

User string `json:"user,omitempty"`
Password string `json:"password,omitempty"`
}

func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]string, error) {
Expand All @@ -47,6 +61,13 @@ func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]strin
MBean: mapping.MBean,
}

if len(mapping.Target.Url) != 0 {
rb.Target = new(TargetBlock)
rb.Target.Url = mapping.Target.Url
rb.Target.User = mapping.Target.User
rb.Target.Password = mapping.Target.Password
}

for _, attribute := range mapping.Attributes {
rb.Attribute = append(rb.Attribute, attribute.Attr)
responseMapping[mapping.MBean+"_"+attribute.Attr] = attribute.Field
Expand Down