Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand JMX configuration options in JSON schema #1213

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions cmd/config-translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"metrics": {
"logs": {
"metrics_collected": {
"jmx": {
"jvm": {
Expand Down
13 changes: 13 additions & 0 deletions translator/config/sampleSchema/invalidMetricsWithJMX.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"metrics": {
"metrics_collected": {
"jmx": {
"jvm": {
"measurement": [
"jvm.memory.heap.init"
]
}
}
}
}
}
26 changes: 26 additions & 0 deletions translator/config/sampleSchema/validLogsWithJMX.json
Original file line number Diff line number Diff line change
@@ -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": {
}
}
}
}
130 changes: 76 additions & 54 deletions translator/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@
},
"metricsMeasurementDefinition": {
"type": "array",
"minItems": 1,
"items": {
"oneOf": [
{
Expand Down Expand Up @@ -632,6 +633,9 @@
"action"
]
}
},
"jmx": {
"$ref": "#/definitions/jmxTargetsDefinition"
}
},
"tls": {
Expand Down Expand Up @@ -716,13 +720,19 @@
"action"
]
}
},
"enable_jvm": {
"type": "boolean"
}
},
"tls": {
"$ref": "#/definitions/metricsDefinition/definitions/tlsDefinitions"
},
"additionalProperties": true
},
"jmx": {
"$ref": "#/definitions/jmxTargetsDefinition"
},
"ecs": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -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"
},
Expand All @@ -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": [
Expand Down
Loading