From 7dd17a321eacec15c6a7c3dcbc8f286f281d4bfd Mon Sep 17 00:00:00 2001 From: ryone Date: Mon, 22 Jan 2018 01:48:22 +0900 Subject: [PATCH 01/11] Fix typo in jolokia.yml Correct mapping to mappings --- metricbeat/metricbeat.reference.yml | 2 +- metricbeat/modules.d/jolokia.yml.disabled | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/metricbeat/metricbeat.reference.yml b/metricbeat/metricbeat.reference.yml index 0f4bc352701e..dba5d2e368e6 100644 --- a/metricbeat/metricbeat.reference.yml +++ b/metricbeat/metricbeat.reference.yml @@ -239,7 +239,7 @@ metricbeat.modules: hosts: ["localhost"] namespace: "metrics" path: "/jolokia/?ignoreErrors=true&canonicalNaming=false" - jmx.mapping: + jmx.mappings: jmx.application: jmx.instance: diff --git a/metricbeat/modules.d/jolokia.yml.disabled b/metricbeat/modules.d/jolokia.yml.disabled index de331606b85e..90cd03ce91fb 100644 --- a/metricbeat/modules.d/jolokia.yml.disabled +++ b/metricbeat/modules.d/jolokia.yml.disabled @@ -4,6 +4,6 @@ hosts: ["localhost"] namespace: "metrics" path: "/jolokia/?ignoreErrors=true&canonicalNaming=false" - jmx.mapping: + jmx.mappings: jmx.application: jmx.instance: From 3bbaf6ca989731b9dcc8224b1b1de3fb1db50b8d Mon Sep 17 00:00:00 2001 From: ryone Date: Mon, 22 Jan 2018 01:49:01 +0900 Subject: [PATCH 02/11] 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 3956b4cc45da..5cf11848d6c5 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 a711f3059d67..33f1e95db644 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 { From a0c68e609284a274e70798d51d0cd886b82a735d Mon Sep 17 00:00:00 2001 From: ryone Date: Wed, 24 Jan 2018 00:07:00 +0900 Subject: [PATCH 03/11] Fixed an issue that can not be acquired when the target key does not exist --- metricbeat/module/jolokia/jmx/config.go | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/metricbeat/module/jolokia/jmx/config.go b/metricbeat/module/jolokia/jmx/config.go index 33f1e95db644..40aa8d696047 100644 --- a/metricbeat/module/jolokia/jmx/config.go +++ b/metricbeat/module/jolokia/jmx/config.go @@ -39,16 +39,16 @@ type Target struct { // } // ] type RequestBlock struct { - Type string `json:"type"` - MBean string `json:"mbean"` - Attribute []string `json:"attribute"` - Target TargetBlock `json:"target"` + Type string `json:"type"` + MBean string `json:"mbean"` + Attribute []string `json:"attribute"` + Target *TargetBlock `json:"target,omitempty"` } type TargetBlock struct { Url string `json:"url"` - User string `json:"user"` - Password string `json:"password"` + User string `json:"user,omitempty"` + Password string `json:"password,omitempty"` } func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]string, error) { @@ -59,11 +59,13 @@ 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, - }, + } + + 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 { From e2a13b091d1405a12f6dacb6dddfbb323fcb612d Mon Sep 17 00:00:00 2001 From: ryone Date: Mon, 22 Jan 2018 01:49:01 +0900 Subject: [PATCH 04/11] 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 3956b4cc45da..5cf11848d6c5 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 a711f3059d67..33f1e95db644 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 { From 14fceaeb531e4d02be7daca8eb20a7bd7a0a03aa Mon Sep 17 00:00:00 2001 From: ryone Date: Mon, 23 Apr 2018 22:48:51 +0900 Subject: [PATCH 05/11] Add unit tests and integration tests --- CHANGELOG.asciidoc | 1 + metricbeat/module/jolokia/_meta/Dockerfile | 40 ++++++++++++++++--- .../module/jolokia/jmx/_meta/test/config.yml | 17 ++++++++ .../jmx/_meta/test/jolokia_response.json | 19 +++++++++ metricbeat/module/jolokia/jmx/config.go | 23 ++++++++--- metricbeat/module/jolokia/jmx/data_test.go | 2 + .../jolokia/jmx/jmx_integration_test.go | 23 +++++++++++ 7 files changed, 114 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 653b82e8aebe..12f021b96e6c 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -182,6 +182,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di - Update the MySQL dashboard to use the Time Series Visual Builder. {pull}5996[5996] - Add experimental uwsgi module. {pull}6006[6006] - Docker and Kubernetes modules are now GA, instead of Beta. {pull}6105[6105] +- Add Jolokia agent in proxy mode. {pull}6475[6475] *Packetbeat* diff --git a/metricbeat/module/jolokia/_meta/Dockerfile b/metricbeat/module/jolokia/_meta/Dockerfile index b555e9f7a1cc..e8970b7b6edd 100644 --- a/metricbeat/module/jolokia/_meta/Dockerfile +++ b/metricbeat/module/jolokia/_meta/Dockerfile @@ -1,11 +1,39 @@ # Tomcat is started to fetch Jolokia metrics from it -FROM jolokia/java-jolokia:7 -ENV TOMCAT_VERSION 7.0.55 +FROM java:8-jdk-alpine + +ENV TOMCAT_VERSION 7.0.86 ENV TC apache-tomcat-${TOMCAT_VERSION} +ENV JOLOKIA_VERSION 1.5.0 +ENV PROXT_TARGET_TOMCAT_VERSION 9.0.7 +ENV PX_TC apache-tomcat-${PROXT_TARGET_TOMCAT_VERSION} + +RUN apk update;\ + apk add curl -HEALTHCHECK --interval=1s --retries=90 CMD curl -f curl localhost:8778/jolokia/ +HEALTHCHECK --interval=1s --retries=90 CMD curl -f localhost:8778/jolokia/ EXPOSE 8778 -RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/${TC}.tar.gz -RUN tar xzf ${TC}.tar.gz -C /opt -CMD env CATALINA_OPTS=$(jolokia_opts) /opt/${TC}/bin/catalina.sh run +# Prepare a server where jolokia runs in proxy mode +RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/${TC}.tar.gz;\ + tar xzf ${TC}.tar.gz -C /usr;\ + sed -i -e 's/Connector port="8080"/Connector port="8778"/g' /usr/${TC}/conf/server.xml;\ + wget http://central.maven.org/maven2/org/jolokia/jolokia-war/${JOLOKIA_VERSION}/jolokia-war-${JOLOKIA_VERSION}.war -O /usr/${TC}/webapps/jolokia.war + +# Set up a server to be connected in proxy mode +RUN wget http://archive.apache.org/dist/tomcat/tomcat-9/v${PROXT_TARGET_TOMCAT_VERSION}/bin/${PX_TC}.tar.gz;\ + tar xzf ${PX_TC}.tar.gz -C /usr;\ + sed -i -e 's/Connector port="8/Connector port="18/g' /usr/${PX_TC}/conf/server.xml;\ + sed -i -e 's/Server port="8005"/Server port="18005"/g' /usr/${PX_TC}/conf/server.xml + +# JMX setting to request authentication with remote connection +RUN echo "monitorRole QED" >> /usr/lib/jvm/java-1.8-openjdk/jre/lib/management/jmxremote.password;\ + echo "controlRole R&D" >> /usr/lib/jvm/java-1.8-openjdk/jre/lib/management/jmxremote.password;\ + chmod 600 /usr/lib/jvm/java-1.8-openjdk/jre/lib/management/jmxremote.password + +# Start tomcat to accept JMX connection and enable jolokia proxy mode +CMD env CATALINA_OPTS="$(jolokia_opts)\ + -Dcom.sun.management.jmxremote.port=7091\ + -Dcom.sun.management.jmxremote.ssl=false\ + -Dcom.sun.management.jmxremote.authenticate=true"\ + /usr/${PX_TC}/bin/catalina.sh run & \ + env CATALINA_OPTS="-Dorg.jolokia.jsr160ProxyEnabled" /usr/${TC}/bin/catalina.sh run diff --git a/metricbeat/module/jolokia/jmx/_meta/test/config.yml b/metricbeat/module/jolokia/jmx/_meta/test/config.yml index 97ccd8f683ec..5b0b10b0d6ef 100644 --- a/metricbeat/module/jolokia/jmx/_meta/test/config.yml +++ b/metricbeat/module/jolokia/jmx/_meta/test/config.yml @@ -55,6 +55,23 @@ metricbeat.modules: attributes: - attr: Value field: compaction.pending_tasks + +- module: jolokia + metricsets: ["jmx"] + enabled: true + period: 10s + namespace: "jolokia_metrics" + hosts: ["localhost:4004"] + jmx.mappings: + - mbean: 'Catalina:type=Server' + attributes: + - attr: serverInfo + field: server_info + target: + url: 'service:jmx:rmi:///jndi/rmi://jolokia:7091/jmxrmi' + user: 'monitorRole' + password: 'QED' + #================================ Outputs ===================================== #-------------------------- Elasticsearch output ------------------------------ diff --git a/metricbeat/module/jolokia/jmx/_meta/test/jolokia_response.json b/metricbeat/module/jolokia/jmx/_meta/test/jolokia_response.json index 3d3082c02487..f79aed5429a7 100644 --- a/metricbeat/module/jolokia/jmx/_meta/test/jolokia_response.json +++ b/metricbeat/module/jolokia/jmx/_meta/test/jolokia_response.json @@ -71,5 +71,24 @@ }, "timestamp": 1472298687, "status": 200 + }, + { + "request": { + "mbean": "Catalina:type=Server", + "attribute": "serverInfo", + "type": "read", + "target": { + "env": { + "password": "QED", + "user": "monitorRole" + }, + "url": "service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi" + } + }, + "value": { + "serverInfo": "Apache Tomcat/9.0.7" + }, + "timestamp": 1523785646, + "status": 200 } ] diff --git a/metricbeat/module/jolokia/jmx/config.go b/metricbeat/module/jolokia/jmx/config.go index 40aa8d696047..5478a581b894 100644 --- a/metricbeat/module/jolokia/jmx/config.go +++ b/metricbeat/module/jolokia/jmx/config.go @@ -13,8 +13,9 @@ type Attribute struct { Field string } +// Target inputs the value you want to set for jolokia target block type Target struct { - Url string + URL string User string Password string } @@ -35,7 +36,12 @@ type Target struct { // "attribute":[ // "CollectionTime", // "CollectionCount" -// ] +// ], +// "target":{ +// "url":"service:jmx:rmi:///jndi/rmi://targethost:9999/jmxrmi", +// "user":"jolokia", +// "password":"s!cr!t" +// } // } // ] type RequestBlock struct { @@ -45,8 +51,15 @@ type RequestBlock struct { Target *TargetBlock `json:"target,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" +// } type TargetBlock struct { - Url string `json:"url"` + URL string `json:"url"` User string `json:"user,omitempty"` Password string `json:"password,omitempty"` } @@ -61,9 +74,9 @@ func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]strin MBean: mapping.MBean, } - if len(mapping.Target.Url) != 0 { + if len(mapping.Target.URL) != 0 { rb.Target = new(TargetBlock) - rb.Target.Url = mapping.Target.Url + rb.Target.URL = mapping.Target.URL rb.Target.User = mapping.Target.User rb.Target.Password = mapping.Target.Password } diff --git a/metricbeat/module/jolokia/jmx/data_test.go b/metricbeat/module/jolokia/jmx/data_test.go index 864fbc412254..ef248bde1361 100644 --- a/metricbeat/module/jolokia/jmx/data_test.go +++ b/metricbeat/module/jolokia/jmx/data_test.go @@ -27,6 +27,7 @@ func TestEventMapper(t *testing.T) { "java.lang:type=Memory_HeapMemoryUsage": "memory.heap_usage", "java.lang:type=Memory_NonHeapMemoryUsage": "memory.non_heap_usage", "org.springframework.boot:type=Endpoint,name=metricsEndpoint_Metrics": "metrics", + "Catalina:type=Server_serverInfo": "server_info", } event, err := eventMapping(jolokiaResponse, mapping) @@ -58,6 +59,7 @@ func TestEventMapper(t *testing.T) { "classes_loaded": float64(19127), "classes_unloaded": float64(270), }, + "server_info": "Apache Tomcat/9.0.7", } assert.Equal(t, expected, event) diff --git a/metricbeat/module/jolokia/jmx/jmx_integration_test.go b/metricbeat/module/jolokia/jmx/jmx_integration_test.go index 9dcd54927cac..fca620d637a0 100644 --- a/metricbeat/module/jolokia/jmx/jmx_integration_test.go +++ b/metricbeat/module/jolokia/jmx/jmx_integration_test.go @@ -74,6 +74,29 @@ func getConfig() map[string]interface{} { }, }, }, + { + "mbean": "Catalina:type=Server", + "attributes": []map[string]string{ + { + "attr": "serverNumber", + "field": "server_number_local", + }, + }, + }, + { + "mbean": "Catalina:type=Server", + "attributes": []map[string]string{ + { + "attr": "serverInfo", + "field": "server_info_proxy", + }, + }, + "target": &TargetBlock{ + URL: "service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi", + User: "monitorRole", + Password: "QED", + }, + }, }, } } From 45a1e5443dc79e4997a8b930257019d4a47b74f0 Mon Sep 17 00:00:00 2001 From: ryone Date: Wed, 25 Apr 2018 00:39:34 +0900 Subject: [PATCH 06/11] Fix to pass the test --- metricbeat/module/jolokia/jmx/data_test.go | 6 +-- .../jolokia/jmx/jmx_integration_test.go | 38 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/metricbeat/module/jolokia/jmx/data_test.go b/metricbeat/module/jolokia/jmx/data_test.go index 2ca98d6580ac..1762b7bfe5a9 100644 --- a/metricbeat/module/jolokia/jmx/data_test.go +++ b/metricbeat/module/jolokia/jmx/data_test.go @@ -97,6 +97,8 @@ func TestEventGroupingMapper(t *testing.T) { Attr: "NonHEapMemoryUsage", Field: "memory.non_heap_usage", Event: "memory"}, attributeMappingKey{"org.springframework.boot:type=Endpoint,name=metricsEndpoint", "Metrics"}: Attribute{ Attr: "Metrics", Field: "metrics"}, + attributeMappingKey{"Catalina:type=Server", "serverInfo"}: Attribute{ + Attr: "serverInfo", Field: "server_info"}, } events, err := eventMapping(jolokiaResponse, mapping) @@ -111,6 +113,7 @@ func TestEventGroupingMapper(t *testing.T) { "classes_loaded": float64(19127), "classes_unloaded": float64(270), }, + "server_info": "Apache Tomcat/9.0.7", }, { "gc": common.MapStr{ @@ -134,9 +137,6 @@ func TestEventGroupingMapper(t *testing.T) { }, }, }, - { - "server_info": "Apache Tomcat/9.0.7", - }, } assert.ElementsMatch(t, expected, events) diff --git a/metricbeat/module/jolokia/jmx/jmx_integration_test.go b/metricbeat/module/jolokia/jmx/jmx_integration_test.go index f61f2a760bae..4c73ecb25342 100644 --- a/metricbeat/module/jolokia/jmx/jmx_integration_test.go +++ b/metricbeat/module/jolokia/jmx/jmx_integration_test.go @@ -102,28 +102,28 @@ func getConfigs() []map[string]interface{} { }, }, }, - }, - { - "mbean": "Catalina:type=Server", - "attributes": []map[string]string{ - { - "attr": "serverNumber", - "field": "server_number_local", + { + "mbean": "Catalina:type=Server", + "attributes": []map[string]string{ + { + "attr": "serverNumber", + "field": "server_number_local", + }, }, }, - }, - { - "mbean": "Catalina:type=Server", - "attributes": []map[string]string{ - { - "attr": "serverInfo", - "field": "server_info_proxy", + { + "mbean": "Catalina:type=Server", + "attributes": []map[string]string{ + { + "attr": "serverInfo", + "field": "server_info_proxy", + }, + }, + "target": &TargetBlock{ + URL: "service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi", + User: "monitorRole", + Password: "QED", }, - }, - "target": &TargetBlock{ - URL: "service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi", - User: "monitorRole", - Password: "QED", }, }, }, From 0480dbdc19d76e2a9340c117435b4c9ab56a1c38 Mon Sep 17 00:00:00 2001 From: ryone Date: Thu, 26 Apr 2018 21:37:01 +0900 Subject: [PATCH 07/11] Revert to 7db33f226e0408bb2eae9b9022067733dcad1efb --- CHANGELOG.asciidoc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index e223297baf91..f59eeff60a72 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -519,13 +519,6 @@ https://github.com/elastic/beats/compare/v6.0.1...v6.1.0[View commits] - Add experimental Docker autodiscover functionality. {pull}5245[5245] - Add Windows service metricset in the windows module. {pull}5332[5332] - Update gosigar to v0.6.0. {pull}5775[5775] -- Add experimental system/raid metricset. {pull}5642[5642] -- Add a dashboard for the Nginx module. {pull}5991[5991] -- Add experimental mongodb/collstats metricset. {pull}5852[5852] -- Update the MySQL dashboard to use the Time Series Visual Builder. {pull}5996[5996] -- Add experimental uwsgi module. {pull}6006[6006] -- Docker and Kubernetes modules are now GA, instead of Beta. {pull}6105[6105] -- Add Jolokia agent in proxy mode. {pull}6475[6475] *Packetbeat* From 2a53cd221d9c76f94e4ae204b0b5b8349dea77a7 Mon Sep 17 00:00:00 2001 From: ryone Date: Thu, 26 Apr 2018 21:49:13 +0900 Subject: [PATCH 08/11] Add CHANGELOG.asciidoc Jolokia agent in proxy mode --- CHANGELOG.asciidoc | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 665852c0a7f0..4fddd706d96d 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -203,6 +203,7 @@ https://github.com/elastic/beats/compare/v6.0.0-beta2...master[Check the HEAD di - Release config reloading feature as GA. {pull}6891[6891] - Add experimental Elasticsearch index metricset. {pull}6881[6881] - Add dashboards and visualizations for haproxy metrics. {pull}6934[6934] +- Add Jolokia agent in proxy mode. {pull}6475[6475] *Packetbeat* From 4b31ec564c3143fd0bffc56a57150b300dd2ae66 Mon Sep 17 00:00:00 2001 From: ryone Date: Sat, 28 Apr 2018 00:40:51 +0900 Subject: [PATCH 09/11] Remove not needed tar.gz file from final image --- metricbeat/module/jolokia/_meta/Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metricbeat/module/jolokia/_meta/Dockerfile b/metricbeat/module/jolokia/_meta/Dockerfile index e8970b7b6edd..48369f344600 100644 --- a/metricbeat/module/jolokia/_meta/Dockerfile +++ b/metricbeat/module/jolokia/_meta/Dockerfile @@ -16,12 +16,14 @@ EXPOSE 8778 # Prepare a server where jolokia runs in proxy mode RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/${TC}.tar.gz;\ tar xzf ${TC}.tar.gz -C /usr;\ + rm ${TC}.tar.gz;\ sed -i -e 's/Connector port="8080"/Connector port="8778"/g' /usr/${TC}/conf/server.xml;\ wget http://central.maven.org/maven2/org/jolokia/jolokia-war/${JOLOKIA_VERSION}/jolokia-war-${JOLOKIA_VERSION}.war -O /usr/${TC}/webapps/jolokia.war # Set up a server to be connected in proxy mode RUN wget http://archive.apache.org/dist/tomcat/tomcat-9/v${PROXT_TARGET_TOMCAT_VERSION}/bin/${PX_TC}.tar.gz;\ tar xzf ${PX_TC}.tar.gz -C /usr;\ + rm ${PX_TC}.tar.gz;\ sed -i -e 's/Connector port="8/Connector port="18/g' /usr/${PX_TC}/conf/server.xml;\ sed -i -e 's/Server port="8005"/Server port="18005"/g' /usr/${PX_TC}/conf/server.xml From 37c2be9179eed7332420b8f7f87a01b170744225 Mon Sep 17 00:00:00 2001 From: ryone Date: Tue, 1 May 2018 22:17:24 +0900 Subject: [PATCH 10/11] Fix to be possible to run everything in an only Tomcat --- metricbeat/module/jolokia/_meta/Dockerfile | 14 ++------------ .../module/jolokia/jmx/jmx_integration_test.go | 7 ++++++- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/metricbeat/module/jolokia/_meta/Dockerfile b/metricbeat/module/jolokia/_meta/Dockerfile index 48369f344600..eb171fb2d87a 100644 --- a/metricbeat/module/jolokia/_meta/Dockerfile +++ b/metricbeat/module/jolokia/_meta/Dockerfile @@ -4,8 +4,6 @@ FROM java:8-jdk-alpine ENV TOMCAT_VERSION 7.0.86 ENV TC apache-tomcat-${TOMCAT_VERSION} ENV JOLOKIA_VERSION 1.5.0 -ENV PROXT_TARGET_TOMCAT_VERSION 9.0.7 -ENV PX_TC apache-tomcat-${PROXT_TARGET_TOMCAT_VERSION} RUN apk update;\ apk add curl @@ -20,13 +18,6 @@ RUN wget http://archive.apache.org/dist/tomcat/tomcat-7/v${TOMCAT_VERSION}/bin/$ sed -i -e 's/Connector port="8080"/Connector port="8778"/g' /usr/${TC}/conf/server.xml;\ wget http://central.maven.org/maven2/org/jolokia/jolokia-war/${JOLOKIA_VERSION}/jolokia-war-${JOLOKIA_VERSION}.war -O /usr/${TC}/webapps/jolokia.war -# Set up a server to be connected in proxy mode -RUN wget http://archive.apache.org/dist/tomcat/tomcat-9/v${PROXT_TARGET_TOMCAT_VERSION}/bin/${PX_TC}.tar.gz;\ - tar xzf ${PX_TC}.tar.gz -C /usr;\ - rm ${PX_TC}.tar.gz;\ - sed -i -e 's/Connector port="8/Connector port="18/g' /usr/${PX_TC}/conf/server.xml;\ - sed -i -e 's/Server port="8005"/Server port="18005"/g' /usr/${PX_TC}/conf/server.xml - # JMX setting to request authentication with remote connection RUN echo "monitorRole QED" >> /usr/lib/jvm/java-1.8-openjdk/jre/lib/management/jmxremote.password;\ echo "controlRole R&D" >> /usr/lib/jvm/java-1.8-openjdk/jre/lib/management/jmxremote.password;\ @@ -36,6 +27,5 @@ RUN echo "monitorRole QED" >> /usr/lib/jvm/java-1.8-openjdk/jre/lib/management/j CMD env CATALINA_OPTS="$(jolokia_opts)\ -Dcom.sun.management.jmxremote.port=7091\ -Dcom.sun.management.jmxremote.ssl=false\ - -Dcom.sun.management.jmxremote.authenticate=true"\ - /usr/${PX_TC}/bin/catalina.sh run & \ - env CATALINA_OPTS="-Dorg.jolokia.jsr160ProxyEnabled" /usr/${TC}/bin/catalina.sh run + -Dcom.sun.management.jmxremote.authenticate=true\ + -Dorg.jolokia.jsr160ProxyEnabled" /usr/${TC}/bin/catalina.sh run diff --git a/metricbeat/module/jolokia/jmx/jmx_integration_test.go b/metricbeat/module/jolokia/jmx/jmx_integration_test.go index 4c73ecb25342..0976ff747ca0 100644 --- a/metricbeat/module/jolokia/jmx/jmx_integration_test.go +++ b/metricbeat/module/jolokia/jmx/jmx_integration_test.go @@ -107,9 +107,14 @@ func getConfigs() []map[string]interface{} { "attributes": []map[string]string{ { "attr": "serverNumber", - "field": "server_number_local", + "field": "server_number_dosntconnect", }, }, + "target": &TargetBlock{ + URL: "service:jmx:rmi:///jndi/rmi://localhost:7091/jmxrmi", + User: "monitorRole", + Password: "IGNORE", + }, }, { "mbean": "Catalina:type=Server", From 7912c308fabd50a06dfbd6b8774996b3ac960011 Mon Sep 17 00:00:00 2001 From: ryone Date: Sat, 12 May 2018 00:10:37 +0900 Subject: [PATCH 11/11] Fix make check error --- metricbeat/module/jolokia/jmx/config.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/metricbeat/module/jolokia/jmx/config.go b/metricbeat/module/jolokia/jmx/config.go index a2809253e6aa..56eb6d659917 100644 --- a/metricbeat/module/jolokia/jmx/config.go +++ b/metricbeat/module/jolokia/jmx/config.go @@ -61,9 +61,9 @@ type RequestBlock struct { // "password":"s!cr!t" // } type TargetBlock struct { - URL string `json:"url"` - User string `json:"user,omitempty"` - Password string `json:"password,omitempty"` + URL string `json:"url"` + User string `json:"user,omitempty"` + Password string `json:"password,omitempty"` } type attributeMappingKey struct {