diff --git a/common/src/main/java/com/zegelin/prometheus/cassandra/FactoriesSupplier.java b/common/src/main/java/com/zegelin/prometheus/cassandra/FactoriesSupplier.java index 23c3103..bc3364c 100644 --- a/common/src/main/java/com/zegelin/prometheus/cassandra/FactoriesSupplier.java +++ b/common/src/main/java/com/zegelin/prometheus/cassandra/FactoriesSupplier.java @@ -168,7 +168,7 @@ private Factory clientMetricFactory(final FactoryBuilder.CollectorConstructor co } private Factory clientRequestMetricFactory(final FactoryBuilder.CollectorConstructor collectorConstructor, final String jmxName, final String familyNameSuffix, final String help) { - final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=ClientRequest,name=%s,scope=*-*", jmxName); + final ObjectName objectNamePattern = format("org.apache.cassandra.metrics:type=ClientRequest,name=%s,scope=*", jmxName); final String metricFamilyName = String.format("client_request_%s", familyNameSuffix); return new FactoryBuilder(collectorConstructor, objectNamePattern, metricFamilyName) @@ -182,13 +182,18 @@ private Factory clientRequestMetricFactory(final FactoryBuilder.CollectorConstru if (!matcher.matches()) throw new IllegalStateException(); - final String operation = matcher.group("operation").toLowerCase(); - final String consistency = matcher.group("consistency"); + final ImmutableMap.Builder labelsBuilder = ImmutableMap.builder(); - return ImmutableMap.of( - "operation", operation, - "consistency", consistency - ); + labelsBuilder.put("operation", matcher.group("operation").toLowerCase()); + + { + final String consistency = matcher.group("consistency"); + if (consistency != null) { + labelsBuilder.put("consistency", consistency); + } + } + + return labelsBuilder.build(); }) .build(); }