apache/cassandra · error · RuntimeException
Unknown Cache metric name
Error message
Unknown Cache metric name
What it means
NodeProbe.getCacheMetric(String cacheType, String metricName) throws when the metricName argument is not one of the supported cache metric keys handled in the switch (e.g. Entries, Hits, Misses, Capacity, Size, HitRate, MissLatency, MissLatencyUnit). The metric name is a CLI-supplied string mapped to JMX MBean attributes, and unknown names cannot be resolved to an MBean proxy.
Source
Thrown at src/java/org/apache/cassandra/tools/NodeProbe.java:1905
return JMX.newMBeanProxy(mbeanServerConn,
new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName),
CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();
case "Requests":
case "Hits":
case "Misses":
return JMX.newMBeanProxy(mbeanServerConn,
new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName),
CassandraMetricsRegistry.JmxMeterMBean.class).getCount();
case "MissLatency":
return JMX.newMBeanProxy(mbeanServerConn,
new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=" + metricName),
CassandraMetricsRegistry.JmxTimerMBean.class).getMean();
case "MissLatencyUnit":
return JMX.newMBeanProxy(mbeanServerConn,
new ObjectName("org.apache.cassandra.metrics:type=Cache,scope=" + cacheType + ",name=MissLatency"),
CassandraMetricsRegistry.JmxTimerMBean.class).getDurationUnit();
default:
throw new RuntimeException("Unknown Cache metric name " + metricName);
}
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException(e);
}
}
/**
* Retrieve buffer pool metrics based on the buffer pool type
* @param poolType networking chunk-cache
* @param metricName UsedSize Size
* @return
*/
public Object getBufferPoolMetric(String poolType, String metricName)
{
tryView on GitHub (pinned to 88fd0f6a0e)
Solutions
- Use a supported metric name exactly as spelled in the switch: e.g. Entries, Hits, Misses, Capacity, Size, HitRate, MissLatency, MissLatencyUnit
- Check `nodetool help cachemetrics` for accepted names on your version
- Inspect available Cache MBeans via JMX (org.apache.cassandra.metrics:type=Cache) to see valid attributes
Example fix
// before
Object v = probe.getCacheMetric("KeyCache", "hitrate");
// after
Object v = probe.getCacheMetric("KeyCache", "HitRate"); Defensive patterns
Strategy: validation
Validate before calling
java.util.Set<String> VALID = Set.of("Entries","Size","Capacity","Hits","Misses","HitRate","MissLatency","MissLatencyUnit");
if (!VALID.contains(metricName)) throw new IllegalArgumentException("Unknown cache metric: " + metricName); Try / catch
try { return probe.getCacheMetric(cacheType, metricName); } catch (RuntimeException e) { throw new IllegalArgumentException("Supported cache metrics: Entries, Size, Capacity, Hits, Misses, HitRate, MissLatency, MissLatencyUnit", e); } Prevention
- Match metric names exactly including case
- List supported names with nodetool help for your version
- Cross-check with the Cache MBeans in JMX console
When it happens
Trigger: Running `nodetool cachemetrics <cacheType> <badMetricName>` with a name outside the switch cases.
Common situations: Typo or case mismatch (e.g. 'hitrate' vs 'HitRate'); expecting metrics from other tool versions; guessing metric names instead of consulting `nodetool help cachemetrics`.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Unknown BufferPool metric name
- Error while refreshing system.size_estimates
- Timeout type requires one of (read, range, write, counterwri
- timeout must be non-negative
- Error setting log for on level . Please check logback confi
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/04cd9292923ba86d.
Report an issue: GitHub.