Skip to content

Commit

Permalink
Add JMX pipeline for container environments (#1379)
Browse files Browse the repository at this point in the history
  • Loading branch information
jefchien authored Oct 8, 2024
1 parent 04445d4 commit fce5a3c
Show file tree
Hide file tree
Showing 25 changed files with 829 additions and 163 deletions.
2 changes: 2 additions & 0 deletions cmd/config-translator/translator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ 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["additional_property_not_allowed"] = 1
expectedErrorMap["number_any_of"] = 1
expectedErrorMap["number_one_of"] = 1
expectedErrorMap["required"] = 1
checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/invalidJMX.json", false, expectedErrorMap)
Expand Down
4 changes: 1 addition & 3 deletions translator/config/sampleSchema/invalidJMX.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"metrics": {
"metrics_collected": {
"jmx": {
"jvm": {
"measurement": []
}
"measurement": []
}
}
}
Expand Down
3 changes: 0 additions & 3 deletions translator/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1320,9 +1320,6 @@
}
},
"additionalProperties": false,
"required": [
"endpoint"
],
"anyOf": [
{
"required": [
Expand Down
6 changes: 3 additions & 3 deletions translator/tocwconfig/sampleConfig/complete_linux_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ service:
receivers:
- telegraf_net
- telegraf_diskio
metrics/jmx/0:
metrics/jmx/cloudwatch/0:
exporters:
- awscloudwatch
processors:
Expand All @@ -399,15 +399,15 @@ service:
- ec2tagger
receivers:
- jmx/0
metrics/jmx/1:
metrics/jmx/cloudwatch/1:
exporters:
- awscloudwatch
processors:
- filter/jmx/1
- resource/jmx
- cumulativetodelta/jmx
- transform/jmx/1
- ec2tagger
- cumulativetodelta/jmx
receivers:
- jmx/1
traces/xray:
Expand Down
18 changes: 13 additions & 5 deletions translator/tocwconfig/sampleConfig/jmx_config_linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ processors:
send_batch_max_size: 0
send_batch_size: 8192
timeout: 1m0s
batch/jmx:
batch/jmx/amp:
metadata_cardinality_limit: 1000
send_batch_max_size: 0
send_batch_size: 8192
Expand Down Expand Up @@ -178,18 +178,26 @@ service:
receivers:
- telegraf_cpu
- telegraf_disk
metrics/jmx:
metrics/jmx/amp:
exporters:
- awscloudwatch
- prometheusremotewrite/amp
processors:
- filter/jmx
- resource/jmx
- cumulativetodelta/jmx
- batch/jmx
- batch/jmx/amp
- transform/jmx
receivers:
- jmx
metrics/jmx/cloudwatch:
exporters:
- awscloudwatch
processors:
- filter/jmx
- resource/jmx
- transform/jmx
- cumulativetodelta/jmx
receivers:
- jmx
telemetry:
logs:
development: false
Expand Down
19 changes: 19 additions & 0 deletions translator/tocwconfig/sampleConfig/jmx_eks_config_linux.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[agent]
collection_jitter = "0s"
debug = false
flush_interval = "1s"
flush_jitter = "0s"
hostname = ""
interval = "60s"
logfile = ""
logtarget = "lumberjack"
metric_batch_size = 1000
metric_buffer_limit = 10000
omit_hostname = false
precision = ""
quiet = false
round_interval = false

[outputs]

[[outputs.cloudwatch]]
43 changes: 43 additions & 0 deletions translator/tocwconfig/sampleConfig/jmx_eks_config_linux.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"metrics": {
"metrics_destinations": {
"amp": {
"workspace_id": "ws-12345"
},
"cloudwatch": {}
},
"metrics_collected": {
"jmx": [
{
"jvm": {
"measurement": [
"jvm.memory.heap.init",
{
"name": "jvm.memory.heap.used",
"rename": "JVM_MEM_HEAP_USED",
"unit": "unit"
},
"jvm.memory.nonheap.init"
]
},
"append_dimensions": {
"k1": "v1"
}
},
{
"kafka-consumer": {
"measurement": [
{
"name": "kafka.consumer.fetch-rate",
"rename": "kafka.fetch-rate"
}
]
},
"append_dimensions": {
"k2": "v2"
}
}
]
}
}
}
216 changes: 216 additions & 0 deletions translator/tocwconfig/sampleConfig/jmx_eks_config_linux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
exporters:
awscloudwatch:
force_flush_interval: 1m0s
max_datums_per_call: 1000
max_values_per_datum: 150
middleware: agenthealth/metrics
namespace: CWAgent
region: us-west-2
resource_to_telemetry_conversion:
enabled: true
prometheusremotewrite/amp:
add_metric_suffixes: true
auth:
authenticator: sigv4auth
compression: ""
disable_keep_alives: false
endpoint: https://aps-workspaces.us-west-2.amazonaws.com/workspaces/ws-12345/api/v1/remote_write
export_created_metric:
enabled: false
http2_ping_timeout: 0s
http2_read_idle_timeout: 0s
max_batch_size_bytes: 3000000
namespace: ""
proxy_url: ""
read_buffer_size: 0
remote_write_queue:
enabled: true
num_consumers: 5
queue_size: 10000
resource_to_telemetry_conversion:
clear_after_copy: true
enabled: true
retry_on_failure:
enabled: true
initial_interval: 50ms
max_elapsed_time: 5m0s
max_interval: 30s
multiplier: 1.5
randomization_factor: 0.5
send_metadata: false
target_info:
enabled: true
timeout: 5s
tls:
ca_file: ""
cert_file: ""
include_system_ca_certs_pool: false
insecure: false
insecure_skip_verify: false
key_file: ""
max_version: ""
min_version: ""
reload_interval: 0s
server_name_override: ""
write_buffer_size: 524288
extensions:
agenthealth/metrics:
is_usage_data_enabled: true
stats:
operations:
- PutMetricData
usage_flags:
mode: EC2
region_type: ACJ
sigv4auth:
assume_role:
sts_region: us-west-2
region: us-west-2
processors:
batch/jmx/amp/0:
metadata_cardinality_limit: 1000
send_batch_max_size: 0
send_batch_size: 8192
timeout: 1m0s
batch/jmx/amp/1:
metadata_cardinality_limit: 1000
send_batch_max_size: 0
send_batch_size: 8192
timeout: 1m0s
cumulativetodelta/jmx:
exclude:
match_type: ""
include:
match_type: ""
initial_value: 2
max_staleness: 0s
filter/jmx/0:
error_mode: propagate
logs: {}
metrics:
include:
match_type: strict
metric_names:
- jvm.memory.heap.init
- jvm.memory.heap.used
- jvm.memory.nonheap.init
spans: {}
traces: {}
filter/jmx/1:
error_mode: propagate
logs: {}
metrics:
include:
match_type: strict
metric_names:
- kafka.consumer.fetch-rate
spans: {}
traces: {}
resource/jmx/0:
attributes:
- action: upsert
converted_type: ""
from_attribute: ""
from_context: ""
key: k1
pattern: ""
value: v1
resource/jmx/1:
attributes:
- action: upsert
converted_type: ""
from_attribute: ""
from_context: ""
key: k2
pattern: ""
value: v2
transform/jmx/0:
error_mode: propagate
flatten_data: false
log_statements: []
metric_statements:
- context: metric
statements:
- set(unit, "unit") where name == "jvm.memory.heap.used"
- set(name, "JVM_MEM_HEAP_USED") where name == "jvm.memory.heap.used"
trace_statements: []
transform/jmx/1:
error_mode: propagate
flatten_data: false
log_statements: []
metric_statements:
- context: metric
statements:
- set(name, "kafka.fetch-rate") where name == "kafka.consumer.fetch-rate"
trace_statements: []
receivers:
otlp/jmx:
protocols:
http:
endpoint: 0.0.0.0:4314
include_metadata: false
logs_url_path: /v1/logs
max_request_body_size: 0
metrics_url_path: /v1/metrics
traces_url_path: /v1/traces
service:
extensions:
- agenthealth/metrics
- sigv4auth
pipelines:
metrics/jmx/amp/0:
exporters:
- prometheusremotewrite/amp
processors:
- filter/jmx/0
- resource/jmx/0
- transform/jmx/0
- batch/jmx/amp/0
receivers:
- otlp/jmx
metrics/jmx/amp/1:
exporters:
- prometheusremotewrite/amp
processors:
- filter/jmx/1
- resource/jmx/1
- transform/jmx/1
- batch/jmx/amp/1
receivers:
- otlp/jmx
metrics/jmx/cloudwatch/0:
exporters:
- awscloudwatch
processors:
- filter/jmx/0
- resource/jmx/0
- transform/jmx/0
- cumulativetodelta/jmx
receivers:
- otlp/jmx
metrics/jmx/cloudwatch/1:
exporters:
- awscloudwatch
processors:
- filter/jmx/1
- resource/jmx/1
- transform/jmx/1
- cumulativetodelta/jmx
receivers:
- otlp/jmx
telemetry:
logs:
development: false
disable_caller: false
disable_stacktrace: false
encoding: console
level: info
sampling:
enabled: true
initial: 2
thereafter: 500
tick: 10s
metrics:
address: ""
level: None
traces: {}
10 changes: 9 additions & 1 deletion translator/tocwconfig/tocwconfig_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,19 @@ func TestJMXConfigLinux(t *testing.T) {
context.CurrentContext().SetMode(config.ModeEC2)
testutil.SetPrometheusRemoteWriteTestingEnv(t)
t.Setenv("JMX_JAR_PATH", "../../packaging/opentelemetry-jmx-metrics.jar")
context.CurrentContext().SetMode(config.ModeEC2)
expectedEnvVars := map[string]string{}
checkTranslation(t, "jmx_config_linux", "linux", expectedEnvVars, "")
}

func TestJMXConfigEKS(t *testing.T) {
resetContext(t)
testutil.SetPrometheusRemoteWriteTestingEnv(t)
context.CurrentContext().SetMode(config.ModeEC2)
context.CurrentContext().SetRunInContainer(true)
expectedEnvVars := map[string]string{}
checkTranslation(t, "jmx_eks_config_linux", "linux", expectedEnvVars, "")
}

func TestDeltaConfigLinux(t *testing.T) {
resetContext(t)
context.CurrentContext().SetMode(config.ModeEC2)
Expand Down
Loading

0 comments on commit fce5a3c

Please sign in to comment.