Skip to content

Commit ad439e8

Browse files
committed
startree node,indices,shards stats
Signed-off-by: Sandesh Kumar <sandeshkr419@gmail.com>
1 parent 621421e commit ad439e8

File tree

5 files changed

+97
-2
lines changed

5 files changed

+97
-2
lines changed

server/src/main/java/org/opensearch/index/search/stats/SearchStats.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ public static class Stats implements Writeable, ToXContentFragment {
166166

167167
private long searchIdleReactivateCount;
168168

169+
private long starTreeQueryCount;
170+
private long starTreeQueryTime;
171+
private long starTreeQueryTimeInMillis;
172+
169173
@Nullable
170174
private RequestStatsLongHolder requestStatsLongHolder;
171175

@@ -197,7 +201,10 @@ public Stats(
197201
long suggestCount,
198202
long suggestTimeInMillis,
199203
long suggestCurrent,
200-
long searchIdleReactivateCount
204+
long searchIdleReactivateCount,
205+
long starTreeQueryCount,
206+
long starTreeQueryTime,
207+
long starTreeQueryTimeInMillis
201208
) {
202209
this.requestStatsLongHolder = new RequestStatsLongHolder();
203210
this.queryCount = queryCount;
@@ -226,6 +233,10 @@ public Stats(
226233
this.pitCurrent = pitCurrent;
227234

228235
this.searchIdleReactivateCount = searchIdleReactivateCount;
236+
237+
this.starTreeQueryCount = starTreeQueryCount;
238+
this.starTreeQueryTime = starTreeQueryTime;
239+
this.starTreeQueryTimeInMillis = starTreeQueryTimeInMillis;
229240
}
230241

231242
private Stats(StreamInput in) throws IOException {
@@ -265,6 +276,12 @@ private Stats(StreamInput in) throws IOException {
265276
if (in.getVersion().onOrAfter(Version.V_2_14_0)) {
266277
searchIdleReactivateCount = in.readVLong();
267278
}
279+
280+
if (in.getVersion().onOrAfter(Version.V_3_1_0)) {
281+
starTreeQueryCount = in.readVLong();
282+
starTreeQueryTime = in.readVLong();
283+
starTreeQueryTimeInMillis = in.readVLong();
284+
}
268285
}
269286

270287
public void add(Stats stats) {
@@ -294,6 +311,10 @@ public void add(Stats stats) {
294311
pitCurrent += stats.pitCurrent;
295312

296313
searchIdleReactivateCount += stats.searchIdleReactivateCount;
314+
315+
starTreeQueryCount += stats.starTreeQueryCount;
316+
starTreeQueryTime += stats.starTreeQueryTime;
317+
starTreeQueryTimeInMillis += stats.starTreeQueryTimeInMillis;
297318
}
298319

299320
public void addForClosingShard(Stats stats) {
@@ -320,6 +341,10 @@ public void addForClosingShard(Stats stats) {
320341
queryConcurrency += stats.queryConcurrency;
321342

322343
searchIdleReactivateCount += stats.searchIdleReactivateCount;
344+
345+
starTreeQueryCount += stats.starTreeQueryCount;
346+
starTreeQueryTime += stats.starTreeQueryTime;
347+
starTreeQueryTimeInMillis += stats.starTreeQueryTimeInMillis;
323348
}
324349

325350
public long getQueryCount() {
@@ -430,6 +455,14 @@ public long getSearchIdleReactivateCount() {
430455
return searchIdleReactivateCount;
431456
}
432457

458+
public long getStarTreeQueryCount() {
459+
return starTreeQueryCount;
460+
}
461+
462+
public TimeValue getStarTreeQueryTime() {
463+
return new TimeValue(starTreeQueryTimeInMillis);
464+
}
465+
433466
public static Stats readStats(StreamInput in) throws IOException {
434467
return new Stats(in);
435468
}
@@ -479,6 +512,12 @@ public void writeTo(StreamOutput out) throws IOException {
479512
if (out.getVersion().onOrAfter(Version.V_2_14_0)) {
480513
out.writeVLong(searchIdleReactivateCount);
481514
}
515+
516+
if (out.getVersion().onOrAfter(Version.V_3_1_0)) {
517+
out.writeVLong(starTreeQueryCount);
518+
out.writeVLong(starTreeQueryTime);
519+
out.writeVLong(starTreeQueryTimeInMillis);
520+
}
482521
}
483522

484523
@Override
@@ -492,6 +531,9 @@ public XContentBuilder toXContent(XContentBuilder builder, Params params) throws
492531
builder.field(Fields.CONCURRENT_QUERY_CURRENT, concurrentQueryCurrent);
493532
builder.field(Fields.CONCURRENT_AVG_SLICE_COUNT, getConcurrentAvgSliceCount());
494533

534+
builder.field(Fields.STARTREE_QUERY_TOTAL, starTreeQueryCount);
535+
builder.humanReadableField(Fields.STARTREE_QUERY_TIME_IN_MILLIS, Fields.STARTREE_QUERY_TIME, getStarTreeQueryTime());
536+
495537
builder.field(Fields.FETCH_TOTAL, fetchCount);
496538
builder.humanReadableField(Fields.FETCH_TIME_IN_MILLIS, Fields.FETCH_TIME, getFetchTime());
497539
builder.field(Fields.FETCH_CURRENT, fetchCurrent);
@@ -677,6 +719,9 @@ static final class Fields {
677719
static final String CONCURRENT_QUERY_TIME_IN_MILLIS = "concurrent_query_time_in_millis";
678720
static final String CONCURRENT_QUERY_CURRENT = "concurrent_query_current";
679721
static final String CONCURRENT_AVG_SLICE_COUNT = "concurrent_avg_slice_count";
722+
static final String STARTREE_QUERY_TOTAL = "startree_query_total";
723+
static final String STARTREE_QUERY_TIME = "startree_query_time";
724+
static final String STARTREE_QUERY_TIME_IN_MILLIS = "startree_query_time_in_millis";
680725
static final String FETCH_TOTAL = "fetch_total";
681726
static final String FETCH_TIME = "fetch_time";
682727
static final String FETCH_TIME_IN_MILLIS = "fetch_time_in_millis";

server/src/main/java/org/opensearch/index/search/stats/ShardSearchStats.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ public void onQueryPhase(SearchContext searchContext, long tookInNanos) {
133133
assert searchContext.searcher().getSlices() != null;
134134
statsHolder.queryConcurrencyMetric.inc(searchContext.searcher().getSlices().length);
135135
}
136+
if (searchContext.getQueryShardContext().getStarTreeQueryContext() != null) {
137+
statsHolder.starTreeQueryCount.inc();
138+
statsHolder.starTreeQueryMetric.inc(tookInNanos);
139+
}
136140
}
137141
});
138142
}
@@ -245,6 +249,8 @@ static final class StatsHolder {
245249
final CounterMetric pitCurrent = new CounterMetric();
246250
final CounterMetric suggestCurrent = new CounterMetric();
247251
final CounterMetric searchIdleMetric = new CounterMetric();
252+
final CounterMetric starTreeQueryCount = new CounterMetric();
253+
final MeanMetric starTreeQueryMetric = new MeanMetric();
248254

249255
SearchStats.Stats stats() {
250256
return new SearchStats.Stats(
@@ -267,7 +273,10 @@ SearchStats.Stats stats() {
267273
suggestMetric.count(),
268274
TimeUnit.NANOSECONDS.toMillis(suggestMetric.sum()),
269275
suggestCurrent.count(),
270-
searchIdleMetric.count()
276+
searchIdleMetric.count(),
277+
starTreeQueryCount.count(),
278+
starTreeQueryMetric.sum(),
279+
TimeUnit.NANOSECONDS.toMillis(starTreeQueryMetric.sum())
271280
);
272281
}
273282
}

server/src/main/java/org/opensearch/rest/action/cat/RestIndicesAction.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,18 @@ protected Table getTableWithHeader(final RestRequest request, final PageToken pa
677677
);
678678
table.addCell("pri.search.concurrent_avg_slice_count", "default:false;text-align:right;desc:average query concurrency");
679679

680+
table.addCell(
681+
"search.startree_query_total",
682+
"sibling:pri;alias:stqc,startreeQueryTotal;default:false;text-align:right;desc:total star tree resolved queries"
683+
);
684+
table.addCell("pri.startree.query_total", "default:false;text-align:right;desc:total star tree resolved queries");
685+
686+
table.addCell(
687+
"search.startree_query_time",
688+
"sibling:pri;alias:stqt,startreeQueryTime;default:false;text-align:right;desc:time spent in star tree queries"
689+
);
690+
table.addCell("pri.startree.query_time", "default:false;text-align:right;desc:time spent in star tree queries");
691+
680692
table.addCell(
681693
"search.scroll_current",
682694
"sibling:pri;alias:scc,searchScrollCurrent;default:false;text-align:right;desc:open scroll contexts"
@@ -1011,6 +1023,12 @@ protected Table buildTable(
10111023
table.addCell(totalStats.getSearch() == null ? null : totalStats.getSearch().getTotal().getConcurrentAvgSliceCount());
10121024
table.addCell(primaryStats.getSearch() == null ? null : primaryStats.getSearch().getTotal().getConcurrentAvgSliceCount());
10131025

1026+
table.addCell(totalStats.getSearch() == null ? null : totalStats.getSearch().getTotal().getStarTreeQueryCount());
1027+
table.addCell(primaryStats.getSearch() == null ? null : primaryStats.getSearch().getTotal().getStarTreeQueryCount());
1028+
1029+
table.addCell(totalStats.getSearch() == null ? null : totalStats.getSearch().getTotal().getStarTreeQueryTime());
1030+
table.addCell(primaryStats.getSearch() == null ? null : primaryStats.getSearch().getTotal().getStarTreeQueryTime());
1031+
10141032
table.addCell(totalStats.getSearch() == null ? null : totalStats.getSearch().getTotal().getScrollCurrent());
10151033
table.addCell(primaryStats.getSearch() == null ? null : primaryStats.getSearch().getTotal().getScrollCurrent());
10161034

server/src/main/java/org/opensearch/rest/action/cat/RestNodesAction.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,15 @@ protected Table getTableWithHeader(final RestRequest request) {
340340
"alias:scto,searchPointInTimeTotal;default:false;text-align:right;desc:completed point in time contexts"
341341
);
342342

343+
table.addCell(
344+
"search.startree_query_total",
345+
"alias:stqc,startreeQueryTotal;default:false;text-align:right;desc:total star tree resolved queries"
346+
);
347+
table.addCell(
348+
"search.startree_query_time",
349+
"alias:stqt,startreeQueryTime;default:false;text-align:right;desc:time spent in star tree queries"
350+
);
351+
343352
table.addCell("segments.count", "alias:sc,segmentsCount;default:false;text-align:right;desc:number of segments");
344353
table.addCell("segments.memory", "alias:sm,segmentsMemory;default:false;text-align:right;desc:memory used by segments");
345354
table.addCell(
@@ -556,6 +565,8 @@ Table buildTable(
556565
table.addCell(searchStats == null ? null : searchStats.getTotal().getPitCurrent());
557566
table.addCell(searchStats == null ? null : searchStats.getTotal().getPitTime());
558567
table.addCell(searchStats == null ? null : searchStats.getTotal().getPitCount());
568+
table.addCell(searchStats == null ? null : searchStats.getTotal().getStarTreeQueryCount());
569+
table.addCell(searchStats == null ? null : searchStats.getTotal().getStarTreeQueryTime());
559570

560571
SegmentsStats segmentsStats = indicesStats == null ? null : indicesStats.getSegments();
561572
table.addCell(segmentsStats == null ? null : segmentsStats.getCount());

server/src/main/java/org/opensearch/rest/action/cat/RestShardsAction.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,15 @@ protected Table getTableWithHeader(final RestRequest request, final PageToken pa
249249
"search.concurrent_avg_slice_count",
250250
"alias:casc,searchConcurrentAvgSliceCount;default:false;text-align:right;desc:average query concurrency"
251251
);
252+
table.addCell(
253+
"search.startree_query_total",
254+
"alias:stqc,startreeQueryTotal;default:false;text-align:right;desc:total star tree resolved queries"
255+
);
256+
table.addCell(
257+
"search.startree_query_time",
258+
"alias:stqt,startreeQueryTime;default:false;text-align:right;desc:time spent in star tree queries"
259+
);
260+
252261
table.addCell("search.scroll_current", "alias:scc,searchScrollCurrent;default:false;text-align:right;desc:open scroll contexts");
253262
table.addCell(
254263
"search.scroll_time",
@@ -449,6 +458,9 @@ Table buildTable(
449458
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getConcurrentQueryCount()));
450459
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getConcurrentAvgSliceCount()));
451460

461+
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getStarTreeQueryCount()));
462+
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getStarTreeQueryTime()));
463+
452464
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getScrollCurrent()));
453465
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getScrollTime()));
454466
table.addCell(getOrNull(commonStats, CommonStats::getSearch, i -> i.getTotal().getScrollCount()));

0 commit comments

Comments
 (0)