Skip to content

Commit 831df0e

Browse files
committed
add jmx exporter back in
1 parent 10d5141 commit 831df0e

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

rust/operator-binary/src/config/jvm.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use stackable_operator::{
66

77
use crate::crd::{
88
JVM_SECURITY_PROPERTIES_FILE, LOG4J_CONFIG_FILE, LOGBACK_CONFIG_FILE, LoggingFramework,
9-
STACKABLE_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR,
9+
METRICS_PORT, STACKABLE_CONFIG_DIR, STACKABLE_LOG_CONFIG_DIR,
1010
v1alpha1::{ZookeeperCluster, ZookeeperConfig, ZookeeperConfigFragment},
1111
};
1212

@@ -36,6 +36,9 @@ fn construct_jvm_args(
3636

3737
let jvm_args = vec![
3838
format!("-Djava.security.properties={STACKABLE_CONFIG_DIR}/{JVM_SECURITY_PROPERTIES_FILE}"),
39+
format!(
40+
"-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar={METRICS_PORT}:/stackable/jmx/server.yaml"
41+
),
3942
match logging_framework {
4043
LoggingFramework::LOG4J => {
4144
format!("-Dlog4j.configuration=file:{STACKABLE_LOG_CONFIG_DIR}/{LOG4J_CONFIG_FILE}")
@@ -120,6 +123,7 @@ mod tests {
120123
assert_eq!(
121124
non_heap_jvm_args,
122125
"-Djava.security.properties=/stackable/config/security.properties \
126+
-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar=9505:/stackable/jmx/server.yaml \
123127
-Dlogback.configurationFile=/stackable/log_config/logback.xml"
124128
);
125129
assert_eq!(zk_server_heap_env, "409");
@@ -164,6 +168,7 @@ mod tests {
164168
assert_eq!(
165169
non_heap_jvm_args,
166170
"-Djava.security.properties=/stackable/config/security.properties \
171+
-javaagent:/stackable/jmx/jmx_prometheus_javaagent.jar=9505:/stackable/jmx/server.yaml \
167172
-Dlogback.configurationFile=/stackable/log_config/logback.xml \
168173
-Dhttps.proxyHost=proxy.my.corp \
169174
-Djava.net.preferIPv4Stack=true \

rust/operator-binary/src/crd/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ pub const OPERATOR_NAME: &str = "zookeeper.stackable.tech";
4747
pub const ZOOKEEPER_PROPERTIES_FILE: &str = "zoo.cfg";
4848
pub const JVM_SECURITY_PROPERTIES_FILE: &str = "security.properties";
4949

50+
pub const METRICS_PORT: u16 = 9505;
5051
pub const METRICS_PROVIDER_HTTP_PORT_KEY: &str = "metricsProvider.httpPort";
51-
pub const METRICS_PROVIDER_HTTP_PORT: u16 = 9505;
52+
pub const METRICS_PROVIDER_HTTP_PORT: u16 = 7000;
5253

5354
pub const STACKABLE_DATA_DIR: &str = "/stackable/data";
5455
pub const STACKABLE_CONFIG_DIR: &str = "/stackable/config";

rust/operator-binary/src/zk_controller.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,12 @@ fn build_server_rolegroup_service(
715715
},
716716
ServicePort {
717717
name: Some("metrics".to_string()),
718+
port: 9505,
719+
protocol: Some("TCP".to_string()),
720+
..ServicePort::default()
721+
},
722+
ServicePort {
723+
name: Some("native-metrics".to_string()),
718724
port: metrics_port_from_rolegroup_config(rolegroup_config).into(),
719725
protocol: Some("TCP".to_string()),
720726
..ServicePort::default()
@@ -900,8 +906,9 @@ fn build_server_rolegroup_statefulset(
900906
.add_container_port("zk", zookeeper_security.client_port().into())
901907
.add_container_port("zk-leader", 2888)
902908
.add_container_port("zk-election", 3888)
909+
.add_container_port("metrics", 9505)
903910
.add_container_port(
904-
"metrics",
911+
"native-metrics",
905912
metrics_port_from_rolegroup_config(server_config).into(),
906913
)
907914
.add_volume_mount("data", STACKABLE_DATA_DIR)

tests/templates/kuttl/smoke/test_zookeeper.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,18 @@ def check_ruok(hosts):
6060

6161
def check_monitoring(hosts):
6262
for host in hosts:
63-
url = host + ":9505/metrics"
63+
# test for the jmx exporter metrics
64+
url = host + ":9505"
65+
response = try_get(url)
66+
67+
if response.ok:
68+
continue
69+
else:
70+
print("Error for [" + url + "]: could not access monitoring")
71+
exit(-1)
72+
73+
# test for the native metrics
74+
url = host + ":7000/metrics"
6475
response = try_get(url)
6576

6677
if response.ok:

0 commit comments

Comments
 (0)