From 7ac0640c24eefdf951f5cf9344fb6cb773a19bdd Mon Sep 17 00:00:00 2001 From: Jeffrey Chien Date: Mon, 17 Jun 2024 10:51:33 -0400 Subject: [PATCH] Expand JMX configuration options in JSON schema (#1213) --- cmd/config-translator/translator_test.go | 19 ++- ...nvalidJMX.json => invalidLogsWithJMX.json} | 2 +- .../sampleSchema/invalidMetricsWithJMX.json | 13 ++ .../config/sampleSchema/validLogsWithJMX.json | 26 ++++ ...validJMX.json => validMetricsWithJMX.json} | 0 translator/config/schema.json | 130 ++++++++++-------- 6 files changed, 130 insertions(+), 60 deletions(-) rename translator/config/sampleSchema/{invalidJMX.json => invalidLogsWithJMX.json} (88%) create mode 100644 translator/config/sampleSchema/invalidMetricsWithJMX.json 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/invalidJMX.json b/translator/config/sampleSchema/invalidLogsWithJMX.json similarity index 88% rename from translator/config/sampleSchema/invalidJMX.json rename to translator/config/sampleSchema/invalidLogsWithJMX.json index 2fdb7bf045..d7b07f7b9a 100644 --- a/translator/config/sampleSchema/invalidJMX.json +++ b/translator/config/sampleSchema/invalidLogsWithJMX.json @@ -1,5 +1,5 @@ { - "metrics": { + "logs": { "metrics_collected": { "jmx": { "jvm": { diff --git a/translator/config/sampleSchema/invalidMetricsWithJMX.json b/translator/config/sampleSchema/invalidMetricsWithJMX.json new file mode 100644 index 0000000000..041e6cd78e --- /dev/null +++ b/translator/config/sampleSchema/invalidMetricsWithJMX.json @@ -0,0 +1,13 @@ +{ + "metrics": { + "metrics_collected": { + "jmx": { + "jvm": { + "measurement": [ + "jvm.memory.heap.init" + ] + } + } + } + } +} \ No newline at end of file diff --git a/translator/config/sampleSchema/validLogsWithJMX.json b/translator/config/sampleSchema/validLogsWithJMX.json new file mode 100644 index 0000000000..8fc9c4730f --- /dev/null +++ b/translator/config/sampleSchema/validLogsWithJMX.json @@ -0,0 +1,26 @@ +{ + "logs": { + "metrics_collected": { + "application_signals": { + "enable_jvm": true + }, + "jmx": { + "jvm": { + "measurement": [ + "jvm.classes.loaded" + ] + }, + "tomcat": { + "measurement": [ + { + "name": "tomcat.sessions", + "rename": "TOMCAT_SESSIONS" + } + ] + } + }, + "kubernetes": { + } + } + } +} \ 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..6a9a237355 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" ] } + }, + "enable_jvm": { + "type": "boolean" } }, "tls": { @@ -723,6 +730,9 @@ }, "additionalProperties": true }, + "jmx": { + "$ref": "#/definitions/jmxTargetsDefinition" + }, "ecs": { "type": "object", "properties": { @@ -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": [