Skip to content

Commit 9d32993

Browse files
authored
Merge pull request #66 from geobeau/master
Add metric pendingtasksbytablename to exporter
2 parents fcaa0d6 + 526956a commit 9d32993

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/main/java/com/criteo/nosql/cassandra/exporter/JmxScraper.java

+25
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ private void updateStats(NodeInfo nodeInfo, String metricName, Double value) {
142142
}
143143
}
144144

145+
146+
if (metricName.startsWith("org:apache:cassandra:metrics:compaction:pendingtasksbytablename:")) {
147+
int pathLength = "org:apache:cassandra:metrics:compaction:pendingtasksbytablename:".length();
148+
int keyspacePos = metricName.indexOf(':', pathLength);
149+
int tablePos = metricName.indexOf(':', keyspacePos + 1);
150+
String keyspaceName = metricName.substring(pathLength, keyspacePos);
151+
String tableName = tablePos > 0 ? metricName.substring(keyspacePos + 1, tablePos) : "";
152+
153+
if (nodeInfo.keyspaces.contains(keyspaceName) && nodeInfo.tables.contains(tableName)) {
154+
this.stats.labels(concat(new String[] {nodeInfo.clusterName, nodeInfo.datacenterName, keyspaceName, tableName, metricName}, additionalLabelValues)).set(value);
155+
return;
156+
}
157+
}
158+
159+
145160
this.stats.labels(concat( new String[] { nodeInfo.clusterName, nodeInfo.datacenterName, "", "", metricName}, additionalLabelValues)).set(value);
146161
}
147162

@@ -297,6 +312,16 @@ private void updateMetric(MBeanServerConnection beanConn, MBeanInfo mBeanInfo, N
297312
//Most beans declared as Object are Double in disguise
298313
if (first >= '0' && first <= '9') {
299314
updateStats(nodeInfo, mBeanInfo.metricName, Double.valueOf(str));
315+
316+
} else if (first == '{' && mBeanInfo.metricName.equalsIgnoreCase("org:apache:cassandra:metrics:compaction:pendingtasksbytablename:value")) {
317+
HashMap<String, HashMap<String, Integer>> pendingTasks = (HashMap<String, HashMap<String, Integer>>) value;
318+
for (String keyspace : pendingTasks.keySet()) {
319+
for (String table : pendingTasks.get(keyspace).keySet()) {
320+
String labels = String.join(":", keyspace, table, "value");
321+
String metricName = mBeanInfo.metricName.replace("value", labels);
322+
updateStats(nodeInfo, metricName, pendingTasks.get(keyspace).get(table).doubleValue());
323+
}
324+
}
300325

301326
// https://books.google.fr/books?id=BvsVuph6ehMC&pg=PA82
302327
// EstimatedHistogram are object for JMX but are long[] behind

0 commit comments

Comments
 (0)