Skip to content

Commit fce5a3c

Browse files
authored
Add JMX pipeline for container environments (#1379)
1 parent 04445d4 commit fce5a3c

File tree

25 files changed

+829
-163
lines changed

25 files changed

+829
-163
lines changed

cmd/config-translator/translator_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ func TestTracesConfig(t *testing.T) {
6868
func TestJMXConfig(t *testing.T) {
6969
checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/validJMX.json", true, map[string]int{})
7070
expectedErrorMap := map[string]int{}
71+
expectedErrorMap["additional_property_not_allowed"] = 1
72+
expectedErrorMap["number_any_of"] = 1
7173
expectedErrorMap["number_one_of"] = 1
7274
expectedErrorMap["required"] = 1
7375
checkIfSchemaValidateAsExpected(t, "../../translator/config/sampleSchema/invalidJMX.json", false, expectedErrorMap)

translator/config/sampleSchema/invalidJMX.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
"metrics": {
33
"metrics_collected": {
44
"jmx": {
5-
"jvm": {
6-
"measurement": []
7-
}
5+
"measurement": []
86
}
97
}
108
}

translator/config/schema.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,9 +1320,6 @@
13201320
}
13211321
},
13221322
"additionalProperties": false,
1323-
"required": [
1324-
"endpoint"
1325-
],
13261323
"anyOf": [
13271324
{
13281325
"required": [

translator/tocwconfig/sampleConfig/complete_linux_config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ service:
388388
receivers:
389389
- telegraf_net
390390
- telegraf_diskio
391-
metrics/jmx/0:
391+
metrics/jmx/cloudwatch/0:
392392
exporters:
393393
- awscloudwatch
394394
processors:
@@ -399,15 +399,15 @@ service:
399399
- ec2tagger
400400
receivers:
401401
- jmx/0
402-
metrics/jmx/1:
402+
metrics/jmx/cloudwatch/1:
403403
exporters:
404404
- awscloudwatch
405405
processors:
406406
- filter/jmx/1
407407
- resource/jmx
408-
- cumulativetodelta/jmx
409408
- transform/jmx/1
410409
- ec2tagger
410+
- cumulativetodelta/jmx
411411
receivers:
412412
- jmx/1
413413
traces/xray:

translator/tocwconfig/sampleConfig/jmx_config_linux.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ processors:
7575
send_batch_max_size: 0
7676
send_batch_size: 8192
7777
timeout: 1m0s
78-
batch/jmx:
78+
batch/jmx/amp:
7979
metadata_cardinality_limit: 1000
8080
send_batch_max_size: 0
8181
send_batch_size: 8192
@@ -178,18 +178,26 @@ service:
178178
receivers:
179179
- telegraf_cpu
180180
- telegraf_disk
181-
metrics/jmx:
181+
metrics/jmx/amp:
182182
exporters:
183-
- awscloudwatch
184183
- prometheusremotewrite/amp
185184
processors:
186185
- filter/jmx
187186
- resource/jmx
188-
- cumulativetodelta/jmx
189-
- batch/jmx
187+
- batch/jmx/amp
190188
- transform/jmx
191189
receivers:
192190
- jmx
191+
metrics/jmx/cloudwatch:
192+
exporters:
193+
- awscloudwatch
194+
processors:
195+
- filter/jmx
196+
- resource/jmx
197+
- transform/jmx
198+
- cumulativetodelta/jmx
199+
receivers:
200+
- jmx
193201
telemetry:
194202
logs:
195203
development: false
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[agent]
2+
collection_jitter = "0s"
3+
debug = false
4+
flush_interval = "1s"
5+
flush_jitter = "0s"
6+
hostname = ""
7+
interval = "60s"
8+
logfile = ""
9+
logtarget = "lumberjack"
10+
metric_batch_size = 1000
11+
metric_buffer_limit = 10000
12+
omit_hostname = false
13+
precision = ""
14+
quiet = false
15+
round_interval = false
16+
17+
[outputs]
18+
19+
[[outputs.cloudwatch]]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"metrics": {
3+
"metrics_destinations": {
4+
"amp": {
5+
"workspace_id": "ws-12345"
6+
},
7+
"cloudwatch": {}
8+
},
9+
"metrics_collected": {
10+
"jmx": [
11+
{
12+
"jvm": {
13+
"measurement": [
14+
"jvm.memory.heap.init",
15+
{
16+
"name": "jvm.memory.heap.used",
17+
"rename": "JVM_MEM_HEAP_USED",
18+
"unit": "unit"
19+
},
20+
"jvm.memory.nonheap.init"
21+
]
22+
},
23+
"append_dimensions": {
24+
"k1": "v1"
25+
}
26+
},
27+
{
28+
"kafka-consumer": {
29+
"measurement": [
30+
{
31+
"name": "kafka.consumer.fetch-rate",
32+
"rename": "kafka.fetch-rate"
33+
}
34+
]
35+
},
36+
"append_dimensions": {
37+
"k2": "v2"
38+
}
39+
}
40+
]
41+
}
42+
}
43+
}
Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
exporters:
2+
awscloudwatch:
3+
force_flush_interval: 1m0s
4+
max_datums_per_call: 1000
5+
max_values_per_datum: 150
6+
middleware: agenthealth/metrics
7+
namespace: CWAgent
8+
region: us-west-2
9+
resource_to_telemetry_conversion:
10+
enabled: true
11+
prometheusremotewrite/amp:
12+
add_metric_suffixes: true
13+
auth:
14+
authenticator: sigv4auth
15+
compression: ""
16+
disable_keep_alives: false
17+
endpoint: https://aps-workspaces.us-west-2.amazonaws.com/workspaces/ws-12345/api/v1/remote_write
18+
export_created_metric:
19+
enabled: false
20+
http2_ping_timeout: 0s
21+
http2_read_idle_timeout: 0s
22+
max_batch_size_bytes: 3000000
23+
namespace: ""
24+
proxy_url: ""
25+
read_buffer_size: 0
26+
remote_write_queue:
27+
enabled: true
28+
num_consumers: 5
29+
queue_size: 10000
30+
resource_to_telemetry_conversion:
31+
clear_after_copy: true
32+
enabled: true
33+
retry_on_failure:
34+
enabled: true
35+
initial_interval: 50ms
36+
max_elapsed_time: 5m0s
37+
max_interval: 30s
38+
multiplier: 1.5
39+
randomization_factor: 0.5
40+
send_metadata: false
41+
target_info:
42+
enabled: true
43+
timeout: 5s
44+
tls:
45+
ca_file: ""
46+
cert_file: ""
47+
include_system_ca_certs_pool: false
48+
insecure: false
49+
insecure_skip_verify: false
50+
key_file: ""
51+
max_version: ""
52+
min_version: ""
53+
reload_interval: 0s
54+
server_name_override: ""
55+
write_buffer_size: 524288
56+
extensions:
57+
agenthealth/metrics:
58+
is_usage_data_enabled: true
59+
stats:
60+
operations:
61+
- PutMetricData
62+
usage_flags:
63+
mode: EC2
64+
region_type: ACJ
65+
sigv4auth:
66+
assume_role:
67+
sts_region: us-west-2
68+
region: us-west-2
69+
processors:
70+
batch/jmx/amp/0:
71+
metadata_cardinality_limit: 1000
72+
send_batch_max_size: 0
73+
send_batch_size: 8192
74+
timeout: 1m0s
75+
batch/jmx/amp/1:
76+
metadata_cardinality_limit: 1000
77+
send_batch_max_size: 0
78+
send_batch_size: 8192
79+
timeout: 1m0s
80+
cumulativetodelta/jmx:
81+
exclude:
82+
match_type: ""
83+
include:
84+
match_type: ""
85+
initial_value: 2
86+
max_staleness: 0s
87+
filter/jmx/0:
88+
error_mode: propagate
89+
logs: {}
90+
metrics:
91+
include:
92+
match_type: strict
93+
metric_names:
94+
- jvm.memory.heap.init
95+
- jvm.memory.heap.used
96+
- jvm.memory.nonheap.init
97+
spans: {}
98+
traces: {}
99+
filter/jmx/1:
100+
error_mode: propagate
101+
logs: {}
102+
metrics:
103+
include:
104+
match_type: strict
105+
metric_names:
106+
- kafka.consumer.fetch-rate
107+
spans: {}
108+
traces: {}
109+
resource/jmx/0:
110+
attributes:
111+
- action: upsert
112+
converted_type: ""
113+
from_attribute: ""
114+
from_context: ""
115+
key: k1
116+
pattern: ""
117+
value: v1
118+
resource/jmx/1:
119+
attributes:
120+
- action: upsert
121+
converted_type: ""
122+
from_attribute: ""
123+
from_context: ""
124+
key: k2
125+
pattern: ""
126+
value: v2
127+
transform/jmx/0:
128+
error_mode: propagate
129+
flatten_data: false
130+
log_statements: []
131+
metric_statements:
132+
- context: metric
133+
statements:
134+
- set(unit, "unit") where name == "jvm.memory.heap.used"
135+
- set(name, "JVM_MEM_HEAP_USED") where name == "jvm.memory.heap.used"
136+
trace_statements: []
137+
transform/jmx/1:
138+
error_mode: propagate
139+
flatten_data: false
140+
log_statements: []
141+
metric_statements:
142+
- context: metric
143+
statements:
144+
- set(name, "kafka.fetch-rate") where name == "kafka.consumer.fetch-rate"
145+
trace_statements: []
146+
receivers:
147+
otlp/jmx:
148+
protocols:
149+
http:
150+
endpoint: 0.0.0.0:4314
151+
include_metadata: false
152+
logs_url_path: /v1/logs
153+
max_request_body_size: 0
154+
metrics_url_path: /v1/metrics
155+
traces_url_path: /v1/traces
156+
service:
157+
extensions:
158+
- agenthealth/metrics
159+
- sigv4auth
160+
pipelines:
161+
metrics/jmx/amp/0:
162+
exporters:
163+
- prometheusremotewrite/amp
164+
processors:
165+
- filter/jmx/0
166+
- resource/jmx/0
167+
- transform/jmx/0
168+
- batch/jmx/amp/0
169+
receivers:
170+
- otlp/jmx
171+
metrics/jmx/amp/1:
172+
exporters:
173+
- prometheusremotewrite/amp
174+
processors:
175+
- filter/jmx/1
176+
- resource/jmx/1
177+
- transform/jmx/1
178+
- batch/jmx/amp/1
179+
receivers:
180+
- otlp/jmx
181+
metrics/jmx/cloudwatch/0:
182+
exporters:
183+
- awscloudwatch
184+
processors:
185+
- filter/jmx/0
186+
- resource/jmx/0
187+
- transform/jmx/0
188+
- cumulativetodelta/jmx
189+
receivers:
190+
- otlp/jmx
191+
metrics/jmx/cloudwatch/1:
192+
exporters:
193+
- awscloudwatch
194+
processors:
195+
- filter/jmx/1
196+
- resource/jmx/1
197+
- transform/jmx/1
198+
- cumulativetodelta/jmx
199+
receivers:
200+
- otlp/jmx
201+
telemetry:
202+
logs:
203+
development: false
204+
disable_caller: false
205+
disable_stacktrace: false
206+
encoding: console
207+
level: info
208+
sampling:
209+
enabled: true
210+
initial: 2
211+
thereafter: 500
212+
tick: 10s
213+
metrics:
214+
address: ""
215+
level: None
216+
traces: {}

translator/tocwconfig/tocwconfig_unix_test.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@ func TestJMXConfigLinux(t *testing.T) {
4545
context.CurrentContext().SetMode(config.ModeEC2)
4646
testutil.SetPrometheusRemoteWriteTestingEnv(t)
4747
t.Setenv("JMX_JAR_PATH", "../../packaging/opentelemetry-jmx-metrics.jar")
48-
context.CurrentContext().SetMode(config.ModeEC2)
4948
expectedEnvVars := map[string]string{}
5049
checkTranslation(t, "jmx_config_linux", "linux", expectedEnvVars, "")
5150
}
5251

52+
func TestJMXConfigEKS(t *testing.T) {
53+
resetContext(t)
54+
testutil.SetPrometheusRemoteWriteTestingEnv(t)
55+
context.CurrentContext().SetMode(config.ModeEC2)
56+
context.CurrentContext().SetRunInContainer(true)
57+
expectedEnvVars := map[string]string{}
58+
checkTranslation(t, "jmx_eks_config_linux", "linux", expectedEnvVars, "")
59+
}
60+
5361
func TestDeltaConfigLinux(t *testing.T) {
5462
resetContext(t)
5563
context.CurrentContext().SetMode(config.ModeEC2)

0 commit comments

Comments
 (0)