Skip to content

Commit 8bb930d

Browse files
Sanitise cluster and host names going into metric names.
ref: Convert cluster names for Graphite ingestion #385 – #385
1 parent 170c9ae commit 8bb930d

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

src/server/src/main/java/io/cassandrareaper/jmx/JmxProxyImpl.java

+13-6
Original file line numberDiff line numberDiff line change
@@ -1075,18 +1075,25 @@ public String getColumnFamily() {
10751075

10761076
private void registerConnectionsGauge() {
10771077
try {
1078-
if (!this.metricRegistry
1078+
if (!metricRegistry
10791079
.getGauges()
10801080
.containsKey(
10811081
MetricRegistry.name(
1082-
JmxProxyImpl.class, this.clusterName, this.host, "repairStatusHandlers"))) {
1083-
this.metricRegistry.register(
1082+
JmxProxyImpl.class,
1083+
clusterName.replace('.', '-'),
1084+
host.replace('.', '-'),
1085+
"repairStatusHandlers"))) {
1086+
1087+
metricRegistry.register(
10841088
MetricRegistry.name(
1085-
JmxProxyImpl.class, this.clusterName, this.host, "repairStatusHandlers"),
1086-
(Gauge<Integer>) () -> this.repairStatusHandlers.size());
1089+
JmxProxyImpl.class,
1090+
clusterName.replace('.', '-'),
1091+
host.replace('.', '-'),
1092+
"repairStatusHandlers"),
1093+
(Gauge<Integer>) () -> repairStatusHandlers.size());
10871094
}
10881095
} catch (IllegalArgumentException e) {
1089-
LOG.warn("Cannot create connection gauge for node {}", this.host, e);
1096+
LOG.warn("Cannot create connection gauge for node {}", host, e);
10901097
}
10911098
}
10921099

src/server/src/main/java/io/cassandrareaper/service/Heart.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,16 @@ private void updateRequestedNodeMetrics() {
115115
.forEach(req -> {
116116

117117
LOG.info("Got metric request for node {} in {}", req.getNode(), req.getCluster());
118-
try (Timer.Context t1 = timer(context, req.getCluster(), req.getNode())) {
118+
try (Timer.Context t1 = timer(
119+
context,
120+
req.getCluster().replace('.', '-'),
121+
req.getNode().replace('.', '-'))) {
122+
119123
try {
120124
JmxProxy nodeProxy
121125
= context.jmxConnectionFactory.connect(
122126
Node.builder().withClusterName(req.getCluster()).withHostname(req.getNode()).build(),
123-
jmxTimeoutSeconds);
127+
jmxTimeoutSeconds);
124128

125129
storage.storeNodeMetrics(
126130
runId,

src/server/src/main/java/io/cassandrareaper/service/SegmentRunner.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,12 @@ private static void postpone(
172172
static void abort(AppContext context, RepairSegment segment, JmxProxy jmxConnection) {
173173
postpone(context, segment, context.storage.getRepairUnit(segment.getRepairUnitId()));
174174
LOG.info("Aborting repair on segment with id {} on coordinator {}", segment.getId(), segment.getCoordinatorHost());
175-
String metric = MetricRegistry.name(SegmentRunner.class, "abort", segment.getCoordinatorHost());
175+
176+
String metric = MetricRegistry.name(
177+
SegmentRunner.class,
178+
"abort",
179+
Optional.fromNullable(segment.getCoordinatorHost()).or("null").replace('.', '-'));
180+
176181
context.metricRegistry.counter(metric).inc();
177182
jmxConnection.cancelAllRepairs();
178183
}

0 commit comments

Comments
 (0)