{"record":{"id":"e8c46ac9be37f804","repo":"apache/cassandra","slug":"unknown-client-metric","errorCode":null,"errorMessage":"Unknown client metric ","messagePattern":"Unknown client metric ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/NodeProbe.java","lineNumber":2305,"sourceCode":"    /**\n     * Retrieve Proxy metrics\n     * @param metricName\n     */\n    public Object getClientMetric(String metricName)\n    {\n        try\n        {\n            switch(metricName)\n            {\n                case \"connections\": // List<Map<String,String>> - list of all native connections and their properties\n                case \"connectedNativeClients\": // number of connected native clients\n                case \"connectedNativeClientsByUser\": // number of native clients by username\n                case \"clientsByProtocolVersion\": // number of native clients by protocol version\n                    return JMX.newMBeanProxy(mbeanServerConn,\n                            new ObjectName(\"org.apache.cassandra.metrics:type=Client,name=\" + metricName),\n                            CassandraMetricsRegistry.JmxGaugeMBean.class).getValue();\n                default:\n                    throw new RuntimeException(\"Unknown client metric \" + metricName);\n            }\n        }\n        catch (MalformedObjectNameException e)\n        {\n            throw new RuntimeException(e);\n        }\n    }\n\n    public Object getCidrFilteringMetric(String metricName)\n    {\n        try\n        {\n            switch(metricName)\n            {\n                case CIDRAuthorizerMetrics.CIDR_CHECKS_LATENCY:\n                    return JMX.newMBeanProxy(mbeanServerConn,\n                                             new ObjectName(\"org.apache.cassandra.metrics:type=CIDRAuthorization,name=\"\n                                                            + metricName),","sourceCodeStart":2287,"sourceCodeEnd":2323,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/NodeProbe.java#L2287-L2323","documentation":"getClientMetric switches over metricName (connectedNativeClients, connectedNativeClientsByUser, clientsByProtocolVersion, etc.); an unrecognized name falls to default and throws RuntimeException(\"Unknown client metric \" + metricName). This is an explicit unsupported-argument guard, not a JMX connectivity failure.","triggerScenarios":"Calling getClientMetric with a string outside the supported client-metric set — misspellings, wrong casing, or names from another Cassandra version (e.g. metrics added later like cidr-related or auth metrics).","commonSituations":"Dashboards built against a newer Cassandra being run against an older one; typos in nodetool-extending scripts; names drifted after Cassandra metric renames.","solutions":["Use an exact supported name as listed in NodeProbe's switch (case-sensitive).","Enumerate valid names from the NodeProbe source of your Cassandra version.","Extend NodeProbe's switch (and rebuild) if the metric exists in JMX but is not yet exposed.","Guard the call site with try-catch and fail the report generation with a clear message."],"exampleFix":"// before\nprobe.getClientMetric(\"connected_native_clients\"); // unknown\n// after\nprobe.getClientMetric(\"connectedNativeClients\");","handlingStrategy":"try-catch","validationCode":"Set<String> VALID = Set.of(\"connectedNativeClients\", \"connectedNativeClientsByUser\", \"clientsByProtocolVersion\");\nif (!VALID.contains(metricName)) throw new IllegalArgumentException(\"Unknown client metric: \" + metricName);","typeGuard":null,"tryCatchPattern":"try {\n    return probe.getClientMetric(metricName);\n} catch (RuntimeException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"Unknown client metric\"))\n        throw new IllegalArgumentException(e.getMessage() + \" — check NodeProbe switch for valid names\", e);\n    throw e;\n}","preventionTips":["Use camelCase names exactly as in the switch","Verify the metric exists in your Cassandra version (client metrics grew over releases)","Fail dashboards loudly at startup by probing all configured names once","Read NodeProbe's source for the authoritative name list"],"tags":["invalid-argument","metric-name","client-metrics","nodeprobe"],"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"}