{"record":{"id":"b4a9f08c1796be97","repo":"apache/cassandra","slug":"unknown-compaction-metric","errorCode":null,"errorMessage":"Unknown compaction metric ","messagePattern":"Unknown compaction metric ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/NodeProbe.java","lineNumber":2278,"sourceCode":"                case \"CompressedBytesCompacted\":\n                case \"CompactionsAborted\":\n                case \"CompactionsReduced\":\n                case \"SSTablesDroppedFromCompaction\":\n                    return JMX.newMBeanProxy(mbeanServerConn,\n                            new ObjectName(\"org.apache.cassandra.metrics:type=Compaction,name=\" + metricName),\n                            CassandraMetricsRegistry.JmxCounterMBean.class);\n                case \"CompletedTasks\":\n                case \"PendingTasks\":\n                case \"PendingTasksByTableName\":\n                    return JMX.newMBeanProxy(mbeanServerConn,\n                            new ObjectName(\"org.apache.cassandra.metrics:type=Compaction,name=\" + metricName),\n                            CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();\n                case \"TotalCompactionsCompleted\":\n                    return JMX.newMBeanProxy(mbeanServerConn,\n                            new ObjectName(\"org.apache.cassandra.metrics:type=Compaction,name=\" + metricName),\n                            CassandraMetricsRegistry.JmxMeterMBean.class);\n                default:\n                    throw new RuntimeException(\"Unknown compaction metric \" + metricName);\n            }\n        }\n        catch (MalformedObjectNameException e)\n        {\n            throw new RuntimeException(e);\n        }\n    }\n\n    /**\n     * Retrieve Proxy metrics\n     * @param metricName\n     */\n    public Object getClientMetric(String metricName)\n    {\n        try\n        {\n            switch(metricName)\n            {","sourceCodeStart":2260,"sourceCodeEnd":2296,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/NodeProbe.java#L2260-L2296","documentation":"getCompactionMetric uses a switch over metricName; any name outside the supported set (CompactionCompleted, TotalCompactionsCompleted, PendingCompactions, etc.) hits the default branch and throws RuntimeException(\"Unknown compaction metric \" + metricName). It is a fail-fast guard against unsupported metric names.","triggerScenarios":"Calling getCompactionMetric(metricName) with a string not matched by any case label — e.g. a misspelled name or a metric that exists in a different Cassandra version but not this one.","commonSituations":"Monitoring configs written for a different Cassandra release; typos like 'totalCompactionsCompleted' (wrong case); renaming of compaction metrics between major versions.","solutions":["Use one of the supported compaction metric names exactly as spelled in NodeProbe's switch (case-sensitive).","Check the NodeProbe source for your Cassandra version to enumerate valid names.","Add the case to NodeProbe and rebuild if you need a metric that is legitimately present in JMX but not exposed here.","Wrap the call in try-catch to convert the failure into a clear config error in your tooling."],"exampleFix":"// before\nprobe.getCompactionMetric(\"CompactionsCompleted\"); // unknown\n// after\nprobe.getCompactionMetric(\"TotalCompactionsCompleted\");","handlingStrategy":"try-catch","validationCode":"Set<String> VALID = Set.of(\"PendingCompactions\", \"CompletedCompactions\", \"CompactionsAborted\", \"CompactionsReduced\", \"TotalCompactionsCompleted\");\nif (!VALID.contains(metricName)) throw new IllegalArgumentException(\"Unknown compaction metric: \" + metricName);","typeGuard":null,"tryCatchPattern":"try {\n    return probe.getCompactionMetric(metricName);\n} catch (RuntimeException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"Unknown compaction metric\"))\n        throw new IllegalArgumentException(e.getMessage() + \" — valid: PendingCompactions, CompletedCompactions, TotalCompactionsCompleted, ...\", e);\n    throw e;\n}","preventionTips":["Match case exactly — the switch is case-sensitive","Re-check metric names after each Cassandra version bump","Enumerate supported names from the NodeProbe switch of your build","Prefer type-specific accessors over guessing names"],"tags":["invalid-argument","metric-name","nodeprobe","switch-default"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}