jmx

package
v0.0.0-...-be347a3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 6, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(base mb.BaseMetricSet) (mb.MetricSet, error)

New create a new instance of the MetricSet

Types

type Attribute

type Attribute struct {
	Attr  string
	Field string
	Event string
}

type AttributeMapping

type AttributeMapping map[attributeMappingKey]Attribute

AttributeMapping contains the mapping information between attributes in Jolokia responses and fields in metricbeat events

func (AttributeMapping) Get

func (m AttributeMapping) Get(mbean, attr string) (Attribute, bool)

Get the mapping options for the attribute of an mbean

type Entry

type Entry struct {
	Request struct {
		Mbean     string      `json:"mbean"`
		Attribute interface{} `json:"attribute"`
	}
	Value interface{}
}

type JMXMapping

type JMXMapping struct {
	MBean      string
	Attributes []Attribute
	Target     Target
}

type JolokiaHTTPGetFetcher

type JolokiaHTTPGetFetcher struct {
}

JolokiaHTTPGetFetcher constructs and executes an HTTP GET request which will read MBean information from Jolokia

func (*JolokiaHTTPGetFetcher) BuildRequestsAndMappings

func (pc *JolokiaHTTPGetFetcher) BuildRequestsAndMappings(configMappings []JMXMapping) ([]*JolokiaHTTPRequest, AttributeMapping, error)

BuildRequestsAndMappings generates HTTP GET request such as URI,Body.

func (*JolokiaHTTPGetFetcher) EventMapping

func (pc *JolokiaHTTPGetFetcher) EventMapping(content []byte, mapping AttributeMapping) ([]common.MapStr, error)

EventMapping maps a Jolokia response from a GET request is to one or more Metricbeat events

func (*JolokiaHTTPGetFetcher) Fetch

func (pc *JolokiaHTTPGetFetcher) Fetch(m *MetricSet) ([]common.MapStr, error)

Fetch perfrorms one or more GET requests to Jolokia server and gets information about MBeans.

type JolokiaHTTPPostFetcher

type JolokiaHTTPPostFetcher struct {
}

JolokiaHTTPPostFetcher constructs and executes an HTTP GET request which will read MBean information from Jolokia

func (*JolokiaHTTPPostFetcher) BuildRequestsAndMappings

func (pc *JolokiaHTTPPostFetcher) BuildRequestsAndMappings(configMappings []JMXMapping) ([]*JolokiaHTTPRequest, AttributeMapping, error)

BuildRequestsAndMappings generates HTTP POST request such as URI,Body.

func (*JolokiaHTTPPostFetcher) EventMapping

func (pc *JolokiaHTTPPostFetcher) EventMapping(content []byte, mapping AttributeMapping) ([]common.MapStr, error)

EventMapping maps a Jolokia response from a POST request is to one or more Metricbeat events

func (*JolokiaHTTPPostFetcher) Fetch

func (pc *JolokiaHTTPPostFetcher) Fetch(m *MetricSet) ([]common.MapStr, error)

Fetch perfrorms a POST request to Jolokia server and gets information about MBeans.

type JolokiaHTTPRequest

type JolokiaHTTPRequest struct {
	// HttpMethod can be either "GET" or "POST"
	HTTPMethod string
	// URI which will be used to query Jolokia
	URI string
	// Request body which is only filled if the http method is "POST"
	Body []byte
}

JolokiaHTTPRequest is a small struct which contains all request information needed to construct a reqest helper.HTTP object which will be sent to Jolokia. It is just an intermediary structure which can be easily tested as helper.HTTP fields are all private.

type JolokiaHTTPRequestFetcher

type JolokiaHTTPRequestFetcher interface {
	// BuildRequestsAndMappings builds the request information and mappings needed to fetch information from Jolokia server
	BuildRequestsAndMappings(configMappings []JMXMapping) ([]*JolokiaHTTPRequest, AttributeMapping, error)
	// Fetches the information from Jolokia server regarding MBeans
	Fetch(m *MetricSet) ([]common.MapStr, error)
	EventMapping(content []byte, mapping AttributeMapping) ([]common.MapStr, error)
}

JolokiaHTTPRequestFetcher is an interface which describes the behaviour of the builder which generates,fetches the HTTP request, which is sent to Jolokia and then parses and maps the response to Metricbeat events.

func NewJolokiaHTTPRequestFetcher

func NewJolokiaHTTPRequestFetcher(httpMethod string) JolokiaHTTPRequestFetcher

NewJolokiaHTTPRequestFetcher is a factory method which creates and returns an implementation class of JolokiaHTTPRequestFetcher interface. HTTP GET and POST are currently supported.

type MBeanName

type MBeanName struct {
	Domain     string
	Properties map[string]string
}

MBeanName is an internal struct used to store the information by the parsed `mbean` (bean name) configuration field in `jmx.mappings`.

func ParseMBeanName

func ParseMBeanName(mBeanName string) (*MBeanName, error)

ParseMBeanName is a factory function which parses a Managed Bean name string identified by mBeanName and returns a new MBean object which contains all the information, i.e. domain and properties of the MBean.

The Mbean string has to abide by the rules which are imposed by Java. For more info: https://docs.oracle.com/javase/8/docs/api/javax/management/ObjectName.html#getCanonicalName--

func (*MBeanName) Canonicalize

func (m *MBeanName) Canonicalize(escape bool) string

Canonicalize Returns the canonical form of the name; that is, a string representation where the properties are sorted in lexical order. The canonical form of the name is a String consisting of the domain part, a colon (:), the canonical key property list, and a pattern indication.

For more information refer to Java 8 [getCanonicalName()](https://docs.oracle.com/javase/8/docs/api/javax/management/ObjectName.html#getCanonicalName--) method.

Set "escape" parameter to true if you want to use the canonicalized name for a Jolokia HTTP GET request, false otherwise.

type MetricSet

type MetricSet struct {
	mb.BaseMetricSet
	// contains filtered or unexported fields
}

MetricSet type defines all fields of the MetricSet

func (*MetricSet) Fetch

func (m *MetricSet) Fetch(reporter mb.ReporterV2) error

Fetch methods implements the data gathering and data conversion to the right format. It publishes the event which is then forwarded to the output. In case of an error set the Error field of mb.Event or simply call report.Error().

type RequestBlock

type RequestBlock struct {
	Type      string                 `json:"type"`
	MBean     string                 `json:"mbean"`
	Attribute []string               `json:"attribute"`
	Config    map[string]interface{} `json:"config"`
	Target    *TargetBlock           `json:"target,omitempty"`
}

RequestBlock is used to build the request blocks of the following format:

[

{
   "type":"read",
   "mbean":"java.lang:type=Runtime",
   "attribute":[
      "Uptime"
   ]
},
{
   "type":"read",
   "mbean":"java.lang:type=GarbageCollector,name=ConcurrentMarkSweep",
   "attribute":[
      "CollectionTime",
      "CollectionCount"
   ],
   "target":{
      "url":"service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi",
      "user":"jolokia",
      "password":"s!cr!t"
   }
}

]

type Target

type Target struct {
	URL      string
	User     string
	Password string
}

Target inputs the value you want to set for jolokia target block

type TargetBlock

type TargetBlock struct {
	URL      string `json:"url"`
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`
}

TargetBlock is used to build the target blocks of the following format into RequestBlock.

"target":{
   "url":"service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi",
   "user":"jolokia",
   "password":"s!cr!t"
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL