Skip to content
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

[Feature] adds index_uuid as a tag in node stats all shard metrics #680

Merged
merged 6 commits into from
Jul 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,17 @@ configOverridesWrapper, getCollectorName())) {
for (Map.Entry currentShard : currentPerShardStats.entrySet()) {
ShardId shardId = (ShardId) currentShard.getKey();
ShardStats currentShardStats = (ShardStats) currentShard.getValue();
String indexUuid = null;
if (shardId.getIndex() != null) {
indexUuid = shardId.getIndex().getUUID();
}

if (prevPerShardStats.size() == 0) {
// Populating value for the first run.
recordMetrics(
new NodeStatsMetricsAllShardsPerCollectionStatus(currentShardStats),
shardId.getIndexName(),
indexUuid,
String.valueOf(shardId.id()));
continue;
}
Expand All @@ -154,14 +160,16 @@ configOverridesWrapper, getCollectorName())) {
recordMetrics(
new NodeStatsMetricsAllShardsPerCollectionStatus(currentShardStats),
shardId.getIndexName(),
indexUuid,
String.valueOf(shardId.id()));
continue;
}
NodeStatsMetricsAllShardsPerCollectionStatus prevValue =
new NodeStatsMetricsAllShardsPerCollectionStatus(prevShardStats);
NodeStatsMetricsAllShardsPerCollectionStatus currValue =
new NodeStatsMetricsAllShardsPerCollectionStatus(currentShardStats);
populateDiffMetricValue(prevValue, currValue, shardId.getIndexName(), shardId.id());
populateDiffMetricValue(
prevValue, currValue, shardId.getIndexName(), indexUuid, shardId.id());
atharvasharma61 marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down Expand Up @@ -245,12 +253,17 @@ public void populatePerShardStats(IndicesService indicesService) {
private void recordMetrics(
NodeStatsMetricsAllShardsPerCollectionStatus metrics,
String indexName,
String indexUuid,
String shardId) {
Tags nodeStatsMetricsTag =
Tags.create()
.addTag(RTFMetrics.CommonDimension.INDEX_NAME.toString(), indexName)
.addTag(RTFMetrics.CommonDimension.SHARD_ID.toString(), shardId);

if (indexUuid != null) {
nodeStatsMetricsTag.addTag(RTFMetrics.CommonDimension.INDEX_UUID.toString(), indexUuid);
}

cacheQueryMissMetrics.add(metrics.getQueryCacheMissCount(), nodeStatsMetricsTag);
cacheQuerySizeMetrics.add(metrics.getQueryCacheInBytes(), nodeStatsMetricsTag);
cacheQueryHitMetrics.add(metrics.getQueryCacheHitCount(), nodeStatsMetricsTag);
Expand All @@ -268,6 +281,7 @@ public void populateDiffMetricValue(
NodeStatsMetricsAllShardsPerCollectionStatus prevValue,
NodeStatsMetricsAllShardsPerCollectionStatus currValue,
String indexName,
String indexUuid,
int shardId) {

NodeStatsMetricsAllShardsPerCollectionStatus metrics =
Expand All @@ -289,7 +303,7 @@ public void populateDiffMetricValue(
0),
currValue.requestCacheInBytes);

recordMetrics(metrics, indexName, String.valueOf(shardId));
recordMetrics(metrics, indexName, indexUuid, String.valueOf(shardId));
}

public static class NodeStatsMetricsAllShardsPerCollectionStatus extends MetricStatus {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ public void testCollectMetrics() throws IOException {
createIndex(TEST_INDEX);
rtfNodeStatsAllShardsMetricsCollector.collectMetrics(startTimeInMills);
verify(rtfNodeStatsAllShardsMetricsCollector, never())
.populateDiffMetricValue(any(), any(), anyString(), anyInt());
.populateDiffMetricValue(any(), any(), anyString(), anyString(), anyInt());
startTimeInMills += 500;
rtfNodeStatsAllShardsMetricsCollector.collectMetrics(startTimeInMills);
verify(rtfNodeStatsAllShardsMetricsCollector, times(1))
.populateDiffMetricValue(any(), any(), anyString(), anyInt());
.populateDiffMetricValue(any(), any(), anyString(), anyString(), anyInt());
verify(cacheFieldDataEvictionCounter, atLeastOnce()).add(anyDouble(), any());
verify(cacheFieldDataSizeCounter, atLeastOnce()).add(anyDouble(), any());
verify(cacheQueryMissCounter, atLeastOnce()).add(anyDouble(), any());
Expand Down
Loading