From 778c02837ac3b2aa9832ece2de5897774576bf57 Mon Sep 17 00:00:00 2001 From: Jeffrey Chien Date: Tue, 11 Jun 2024 19:56:53 -0400 Subject: [PATCH 1/2] Add JMX to logs/metrics_collected in JSON schema. --- cmd/config-translator/translator_test.go | 19 ++- .../sampleSchema/invalidLogsWithJMX.json | 13 ++ ...lidJMX.json => invalidMetricsWithJMX.json} | 4 +- .../config/sampleSchema/validLogsWithJMX.json | 32 +++++ ...validJMX.json => validMetricsWithJMX.json} | 0 translator/config/schema.json | 130 ++++++++++-------- 6 files changed, 138 insertions(+), 60 deletions(-) create mode 100644 translator/config/sampleSchema/invalidLogsWithJMX.json rename translator/config/sampleSchema/{invalidJMX.json => invalidMetricsWithJMX.json} (58%) create mode 100644 translator/config/sampleSchema/validLogsWithJMX.json rename translator/config/sampleSchema/{validJMX.json => validMetricsWithJMX.json} (100%) diff --git a/cmd/config-translator/translator_test.go b/cmd/config-translator/translator_test.go index 096216cfad..07b5f84a80 100644 --- a/cmd/config-translator/translator_test.go +++ b/cmd/config-translator/translator_test.go @@ -66,11 +66,20 @@ func TestTracesConfig(t *testing.T) { } func TestJMXConfig(t *testing.T) { - checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/validJMX.json", true, map[string]int{}) - expectedErrorMap := map[string]int{} - expectedErrorMap["number_one_of"] = 1 - expectedErrorMap["required"] = 1 - checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/invalidJMX.json", false, expectedErrorMap) + t.Run("WithMetrics", func(t *testing.T) { + checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/validMetricsWithJMX.json", true, map[string]int{}) + expectedErrorMap := map[string]int{} + expectedErrorMap["number_all_of"] = 1 + expectedErrorMap["number_one_of"] = 1 + expectedErrorMap["required"] = 1 + checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/invalidMetricsWithJMX.json", false, expectedErrorMap) + }) + t.Run("WithLogs", func(t *testing.T) { + checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/validLogsWithJMX.json", true, map[string]int{}) + expectedErrorMap := map[string]int{} + expectedErrorMap["array_min_items"] = 1 + checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/invalidLogsWithJMX.json", false, expectedErrorMap) + }) } func TestLogFilesConfig(t *testing.T) { diff --git a/translator/config/sampleSchema/invalidLogsWithJMX.json b/translator/config/sampleSchema/invalidLogsWithJMX.json new file mode 100644 index 0000000000..8ba8a799b5 --- /dev/null +++ b/translator/config/sampleSchema/invalidLogsWithJMX.json @@ -0,0 +1,13 @@ +{ + "logs": { + "metrics_collected": { + "application_signals": { + "jmx": { + "jvm": { + "measurement": [] + } + } + } + } + } +} \ No newline at end of file diff --git a/translator/config/sampleSchema/invalidJMX.json b/translator/config/sampleSchema/invalidMetricsWithJMX.json similarity index 58% rename from translator/config/sampleSchema/invalidJMX.json rename to translator/config/sampleSchema/invalidMetricsWithJMX.json index 2fdb7bf045..041e6cd78e 100644 --- a/translator/config/sampleSchema/invalidJMX.json +++ b/translator/config/sampleSchema/invalidMetricsWithJMX.json @@ -3,7 +3,9 @@ "metrics_collected": { "jmx": { "jvm": { - "measurement": [] + "measurement": [ + "jvm.memory.heap.init" + ] } } } diff --git a/translator/config/sampleSchema/validLogsWithJMX.json b/translator/config/sampleSchema/validLogsWithJMX.json new file mode 100644 index 0000000000..030370080c --- /dev/null +++ b/translator/config/sampleSchema/validLogsWithJMX.json @@ -0,0 +1,32 @@ +{ + "logs": { + "metrics_collected": { + "application_signals": { + "jmx": { + "jvm": { + "measurement": [ + "jvm.classes.loaded" + ] + } + } + }, + "kubernetes": { + "jmx": { + "jvm": { + "measurement": [ + "jvm.classes.loaded" + ] + }, + "tomcat": { + "measurement": [ + { + "name": "tomcat.sessions", + "rename": "TOMCAT_SESSIONS" + } + ] + } + } + } + } + } +} \ No newline at end of file diff --git a/translator/config/sampleSchema/validJMX.json b/translator/config/sampleSchema/validMetricsWithJMX.json similarity index 100% rename from translator/config/sampleSchema/validJMX.json rename to translator/config/sampleSchema/validMetricsWithJMX.json diff --git a/translator/config/schema.json b/translator/config/schema.json index 68505ed585..99c1af5ed6 100644 --- a/translator/config/schema.json +++ b/translator/config/schema.json @@ -502,6 +502,7 @@ }, "metricsMeasurementDefinition": { "type": "array", + "minItems": 1, "items": { "oneOf": [ { @@ -632,6 +633,9 @@ "action" ] } + }, + "jmx": { + "$ref": "#/definitions/jmxTargetsDefinition" } }, "tls": { @@ -716,6 +720,9 @@ "action" ] } + }, + "jmx": { + "$ref": "#/definitions/jmxTargetsDefinition" } }, "tls": { @@ -750,6 +757,9 @@ "disable_metric_extraction": { "description": "Disable the extraction of metrics from EMF logs", "type": "boolean" + }, + "jmx": { + "$ref": "#/definitions/jmxTargetsDefinition" } }, "additionalProperties": true @@ -1201,50 +1211,73 @@ }, "jmxObjectDefinition": { "type": "object", - "properties": { - "endpoint": { - "description": "The endpoint to listen for JMX", - "$ref": "#/definitions/endpointOverrideDefinition" - }, - "metrics_collection_interval": { - "$ref": "#/definitions/timeIntervalDefinition" - }, - "username": { - "description": "The username to use for JMX authentication", - "type": "string" - }, - "password_file": { - "description": "The password file to read in the passwords for JMX authentication", - "type": "string" - }, - "keystore_path": { - "description": "The keystore path is required if SSL is enabled on the target JVM", - "type": "string" - }, - "keystore_type": { - "description": "The keystore type if required by SSL", - "type": "string" - }, - "truststore_path": { - "description": "The truststore path is required if SSL is enabled on the target JVM", - "type": "string" - }, - "truststore_type": { - "description": "The truststore type if required by SSL", - "type": "string" - }, - "registry_ssl_enabled": { - "description": "If SSL is enabled for RMI registry", - "type": "boolean" - }, - "remote_profile": { - "description": "Supported JMX remote profiles in combination with SASL profiles", - "type": "string" - }, - "realm": { - "description": "The realm, as required by remote profile SASL/DIGEST-MD5.", - "type": "string" + "allOf": [ + { + "$ref": "#/definitions/jmxTargetsDefinition" }, + { + "type": "object", + "properties": { + "endpoint": { + "description": "The endpoint to listen for JMX", + "$ref": "#/definitions/endpointOverrideDefinition" + }, + "metrics_collection_interval": { + "$ref": "#/definitions/timeIntervalDefinition" + }, + "username": { + "description": "The username to use for JMX authentication", + "type": "string" + }, + "password_file": { + "description": "The password file to read in the passwords for JMX authentication", + "type": "string" + }, + "keystore_path": { + "description": "The keystore path is required if SSL is enabled on the target JVM", + "type": "string" + }, + "keystore_type": { + "description": "The keystore type if required by SSL", + "type": "string" + }, + "truststore_path": { + "description": "The truststore path is required if SSL is enabled on the target JVM", + "type": "string" + }, + "truststore_type": { + "description": "The truststore type if required by SSL", + "type": "string" + }, + "registry_ssl_enabled": { + "description": "If SSL is enabled for RMI registry", + "type": "boolean" + }, + "remote_profile": { + "description": "Supported JMX remote profiles in combination with SASL profiles", + "type": "string" + }, + "realm": { + "description": "The realm, as required by remote profile SASL/DIGEST-MD5.", + "type": "string" + }, + "insecure": { + "description": "Disable JMX remote TLS/password authentication requirements", + "type": "boolean" + }, + "append_dimensions": { + "$ref": "#/definitions/generalAppendDimensionsDefinition" + } + }, + "required": [ + "endpoint" + ] + } + ] + }, + "jmxTargetsDefinition": { + "type": "object", + "properties": { "jvm": { "$ref": "#/definitions/jmxTargetDefinition" }, @@ -1259,19 +1292,8 @@ }, "tomcat": { "$ref": "#/definitions/jmxTargetDefinition" - }, - "insecure": { - "description": "Disable JMX remote TLS/password authentication requirements", - "type": "boolean" - }, - "append_dimensions": { - "$ref": "#/definitions/generalAppendDimensionsDefinition" } }, - "additionalProperties": false, - "required": [ - "endpoint" - ], "anyOf": [ { "required": [ From 296c24971f9d3d06b2869cbe8df2abd2253be989 Mon Sep 17 00:00:00 2001 From: Jeffrey Chien Date: Mon, 17 Jun 2024 10:22:07 -0400 Subject: [PATCH 2/2] Update schema --- .../sampleSchema/invalidLogsWithJMX.json | 8 ++--- .../config/sampleSchema/validLogsWithJMX.json | 36 ++++++++----------- translator/config/schema.json | 10 +++--- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/translator/config/sampleSchema/invalidLogsWithJMX.json b/translator/config/sampleSchema/invalidLogsWithJMX.json index 8ba8a799b5..d7b07f7b9a 100644 --- a/translator/config/sampleSchema/invalidLogsWithJMX.json +++ b/translator/config/sampleSchema/invalidLogsWithJMX.json @@ -1,11 +1,9 @@ { "logs": { "metrics_collected": { - "application_signals": { - "jmx": { - "jvm": { - "measurement": [] - } + "jmx": { + "jvm": { + "measurement": [] } } } diff --git a/translator/config/sampleSchema/validLogsWithJMX.json b/translator/config/sampleSchema/validLogsWithJMX.json index 030370080c..8fc9c4730f 100644 --- a/translator/config/sampleSchema/validLogsWithJMX.json +++ b/translator/config/sampleSchema/validLogsWithJMX.json @@ -2,30 +2,24 @@ "logs": { "metrics_collected": { "application_signals": { - "jmx": { - "jvm": { - "measurement": [ - "jvm.classes.loaded" - ] - } + "enable_jvm": true + }, + "jmx": { + "jvm": { + "measurement": [ + "jvm.classes.loaded" + ] + }, + "tomcat": { + "measurement": [ + { + "name": "tomcat.sessions", + "rename": "TOMCAT_SESSIONS" + } + ] } }, "kubernetes": { - "jmx": { - "jvm": { - "measurement": [ - "jvm.classes.loaded" - ] - }, - "tomcat": { - "measurement": [ - { - "name": "tomcat.sessions", - "rename": "TOMCAT_SESSIONS" - } - ] - } - } } } } diff --git a/translator/config/schema.json b/translator/config/schema.json index 99c1af5ed6..6a9a237355 100644 --- a/translator/config/schema.json +++ b/translator/config/schema.json @@ -721,8 +721,8 @@ ] } }, - "jmx": { - "$ref": "#/definitions/jmxTargetsDefinition" + "enable_jvm": { + "type": "boolean" } }, "tls": { @@ -730,6 +730,9 @@ }, "additionalProperties": true }, + "jmx": { + "$ref": "#/definitions/jmxTargetsDefinition" + }, "ecs": { "type": "object", "properties": { @@ -757,9 +760,6 @@ "disable_metric_extraction": { "description": "Disable the extraction of metrics from EMF logs", "type": "boolean" - }, - "jmx": { - "$ref": "#/definitions/jmxTargetsDefinition" } }, "additionalProperties": true