From c4f4b22df31ea57f7c7cb9a7225a395f3bdeded7 Mon Sep 17 00:00:00 2001 From: Michael Burman Date: Mon, 9 Oct 2023 09:36:54 +0300 Subject: [PATCH] Add more defensives --- .../prometheus/CassandraTasksExports.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/management-api-agent-common/src/main/java/io/k8ssandra/metrics/prometheus/CassandraTasksExports.java b/management-api-agent-common/src/main/java/io/k8ssandra/metrics/prometheus/CassandraTasksExports.java index ed55820c..740ade44 100644 --- a/management-api-agent-common/src/main/java/io/k8ssandra/metrics/prometheus/CassandraTasksExports.java +++ b/management-api-agent-common/src/main/java/io/k8ssandra/metrics/prometheus/CassandraTasksExports.java @@ -296,6 +296,15 @@ List getCompactionStats() { .filter( c -> { String taskType = c.get("taskType"); + if (taskType == null) { + // DSE 6.8 renamed the column + taskType = c.get("operationType"); + } + + if (taskType == null) { + return false; + } + try { OperationType operationType = OperationType.valueOf(taskType.toUpperCase()); // Ignore taskTypes: COUNTER_CACHE_SAVE, KEY_CACHE_SAVE, ROW_CACHE_SAVE (from @@ -327,11 +336,24 @@ List getCompactionStats() { List labelValues = Lists.newArrayListWithCapacity(protoCompleted.getLabelValues().size() + 5); labelValues.addAll(protoCompleted.getLabelValues()); + + String compactionId = c.get("compactionId"); + if (compactionId == null) { + // DSE 6.8 renamed this one also + compactionId = c.get("operationId"); + } + + String taskType = c.get("taskType"); + if (taskType == null) { + // DSE 6.8 + taskType = c.get("operationType"); + } + labelValues.add(c.get("keyspace")); labelValues.add(c.get("columnfamily")); - labelValues.add(c.get("compactionId")); + labelValues.add(compactionId); labelValues.add(c.get("unit")); - labelValues.add(c.get("taskType")); + labelValues.add(taskType); Collector.MetricFamilySamples.Sample completeSample = new Collector.MetricFamilySamples.Sample(