-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding new metrics for SAI in nodetool tablestats command. #3742
base: trunk
Are you sure you want to change the base?
Changes from 3 commits
f5e31ee
8a322bc
e12e844
c383226
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -175,6 +175,16 @@ private Map<String, Object> convertStatsTableToMap(StatsTable table) | |
mpTable.put("top_tombstone_partitions", table.topTombstonePartitions); | ||
if (locationCheck) | ||
mpTable.put("sstables_in_correct_location", table.isInCorrectLocation); | ||
|
||
mpTable.put("sai_local_query_latency",String.format("%01.3f", table.saiQueryLatencyMs)); | ||
mpTable.put("sai_post_filtering_read_latency",String.format("%01.3f", table.saiPostFilteringReadLatencyms)); | ||
mpTable.put("sai_disk_used_bytes",table.saiDiskUsedBytes); | ||
mpTable.put("sai_sstable_indexes_hit",table.saiSSTableIndexesHit); | ||
mpTable.put("sai_index_segments_hit",table.saiIndexSegmentsHit); | ||
mpTable.put("sai_rows_filtered",table.saiRowsFiltered); | ||
mpTable.put("sai_total_query_timeouts",table.saiTotalQueryTimeouts); | ||
mpTable.put("sai_queryable_total_indexes", table.saiTotalQueryableIndexRatio); | ||
|
||
return mpTable; | ||
} | ||
|
||
|
@@ -392,13 +402,54 @@ private void initializeKeyspaces(NodeProbe probe, boolean ignore, List<String> t | |
statsTable.topTombstonePartitions = table.getTopTombstonePartitions(); | ||
if (table.getTopTombstonePartitionsLastUpdate() != null) | ||
statsTable.topTombstonePartitionsLastUpdate = millisToDateString(table.getTopTombstonePartitionsLastUpdate()); | ||
Object queryLatencyMetric = probe.getSaiMetric(keyspaceName, tableName, "QueryLatency"); // Add sai here as well. | ||
double QueryLatency = getMetricMean(queryLatencyMetric); | ||
statsTable.saiQueryLatencyMs = QueryLatency > 0 ? QueryLatency : Double.NaN; | ||
|
||
Object PostFilteringReadLatency = probe.getSaiMetric(keyspaceName, tableName, "PostFilteringReadLatency"); | ||
double postfilteringreadlatency = getMetricMean(PostFilteringReadLatency); | ||
statsTable.saiPostFilteringReadLatencyms = postfilteringreadlatency > 0 ? postfilteringreadlatency : Double.NaN; | ||
|
||
Object diskUsedBytes = probe.getSaiMetric(keyspaceName, tableName, "DiskUsedBytes"); | ||
long saidiskusedbytes = (diskUsedBytes != null) ? (long) diskUsedBytes : 0L; | ||
statsTable.saiDiskUsedBytes = FileUtils.stringifyFileSize(saidiskusedbytes, humanReadable); | ||
|
||
Object SSTableIndexesHit = probe.getSaiMetric(keyspaceName, tableName, "SSTableIndexesHit"); | ||
statsTable.saiSSTableIndexesHit = getMetricMean(SSTableIndexesHit); | ||
|
||
Object IndexSegmentsHit = probe.getSaiMetric(keyspaceName, tableName, "IndexSegmentsHit"); | ||
statsTable.saiIndexSegmentsHit = getMetricMean(IndexSegmentsHit); | ||
|
||
Object RowsFiltered = probe.getSaiMetric(keyspaceName, tableName, "RowsFiltered"); | ||
statsTable.saiRowsFiltered = getMetricMean(RowsFiltered); | ||
|
||
Object totalQueryTimeouts = probe.getSaiMetric(keyspaceName, tableName, "TotalQueryTimeouts"); | ||
statsTable.saiTotalQueryTimeouts = (totalQueryTimeouts != null) ? (Long) totalQueryTimeouts : 0L; | ||
|
||
Object totalIndexCount = probe.getSaiMetric(keyspaceName, tableName, "TotalIndexCount"); | ||
int saiTotalIndexCount = (totalIndexCount != null) ? (int) totalIndexCount : 0; | ||
|
||
Object totalQueryableIndexCount = probe.getSaiMetric(keyspaceName, tableName, "TotalQueryableIndexCount"); | ||
int saiTotalQueryableIndexCount = (totalQueryableIndexCount != null) ? (int) totalQueryableIndexCount : 0; | ||
|
||
statsTable.saiTotalQueryableIndexRatio = String.format("%d/%d", saiTotalIndexCount, saiTotalQueryableIndexCount); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we avoid the entire block above if we're looking at a system keyspace? We've got a check at print-time in |
||
|
||
statsKeyspace.tables.add(statsTable); | ||
} | ||
keyspaces.add(statsKeyspace); | ||
} | ||
} | ||
|
||
private double getMetricMean(Object metricObject) { | ||
if (metricObject instanceof CassandraMetricsRegistry.JmxTimerMBean) { | ||
return ((CassandraMetricsRegistry.JmxTimerMBean) metricObject).getMean() / 1000; | ||
} | ||
if (metricObject instanceof CassandraMetricsRegistry.JmxHistogramMBean) { | ||
return Math.round(((CassandraMetricsRegistry.JmxHistogramMBean) metricObject).getMean() * 100.0) / 100.0; | ||
} | ||
return Double.NaN; | ||
} | ||
|
||
private void maybeAddTWCSWindowWithMaxDuration(StatsTable statsTable, NodeProbe probe, String keyspaceName, String tableName) | ||
{ | ||
Map<String, String> compactionParameters = probe.getCfsProxy(statsTable.keyspaceName, statsTable.tableName) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
import java.util.Map; | ||
|
||
import org.apache.cassandra.io.util.FileUtils; | ||
import org.apache.cassandra.schema.SchemaConstants; | ||
import org.apache.cassandra.utils.FBUtilities; | ||
|
||
public class TableStatsPrinter<T extends StatsHolder> | ||
|
@@ -168,9 +169,27 @@ protected void printStatsTable(StatsTable table, String tableDisplayName, String | |
for (Map.Entry<String, Long> tombstonecnt : table.topTombstonePartitions.entrySet()) | ||
out.printf(indent + " %-" + maxWidth + "s %s%n", tombstonecnt.getKey(), tombstonecnt.getValue()); | ||
} | ||
|
||
if (!isSystemKeyspaces(table.keyspaceName)) | ||
{ | ||
out.println(indent + "SAI local query latency (mean): " + FBUtilities.prettyPrintLatency(table.saiQueryLatencyMs)); | ||
out.println(indent + "SAI post-filtering latency (mean): " + FBUtilities.prettyPrintLatency(table.saiPostFilteringReadLatencyms)); | ||
out.println(indent + "SAI space used (bytes): " + table.saiDiskUsedBytes); | ||
out.println(indent + "SAI sstable indexes hit per query (mean): " + table.saiSSTableIndexesHit); | ||
out.println(indent + "SAI index segments hit per query (mean): " + table.saiIndexSegmentsHit); | ||
out.println(indent + "SAI rows filtered per query (mean): " + table.saiRowsFiltered); | ||
out.println(indent + "SAI local query timeouts: " + table.saiTotalQueryTimeouts); | ||
out.println(indent + "SAI queryable/total indexes: " + table.saiTotalQueryableIndexRatio); | ||
} | ||
|
||
out.println(""); | ||
} | ||
|
||
private boolean isSystemKeyspaces(String keyspaceName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: newline for |
||
return SchemaConstants.isSystemKeyspace(keyspaceName); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: unnecessary newline |
||
} | ||
|
||
private String formatDataSize(long bytes, boolean humanReadable) | ||
{ | ||
return humanReadable ? FileUtils.stringifyFileSize(bytes) : Long.toString(bytes); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit/formatting: For everything below, newlines after
}
and before thecatch