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": [