Skip to content

Commit 1108f83

Browse files
authored
Add a took time histogram for search triggered cache miss to blob cache metrics (elastic#135257)
This adds a es.blob_cache.search_origin.download_took_time.total histogram metric to track the times we spend downloading from remote storage, but only when triggered by a search operation.
1 parent 7a6f394 commit 1108f83

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/BlobCacheMetrics.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class BlobCacheMetrics {
3131
public static final String LUCENE_FILE_EXTENSION_ATTRIBUTE_KEY = "file_extension";
3232
public static final String NON_LUCENE_EXTENSION_TO_RECORD = "other";
3333
public static final String BLOB_CACHE_COUNT_OF_EVICTED_REGIONS_TOTAL = "es.blob_cache.count_of_evicted_regions.total";
34+
public static final String SEARCH_ORIGIN_REMOTE_STORAGE_DOWNLOAD_TOOK_TIME = "es.blob_cache.search_origin.download_took_time.total";
3435

3536
private final LongCounter cacheMissCounter;
3637
private final LongCounter evictedCountNonZeroFrequency;
@@ -43,6 +44,7 @@ public class BlobCacheMetrics {
4344
private final LongAdder missCount = new LongAdder();
4445
private final LongAdder readCount = new LongAdder();
4546
private final LongCounter epochChanges;
47+
private final LongHistogram searchOriginDownloadTime;
4648

4749
public enum CachePopulationReason {
4850
/**
@@ -100,7 +102,12 @@ public BlobCacheMetrics(MeterRegistry meterRegistry) {
100102
"The time spent copying data into the cache",
101103
"milliseconds"
102104
),
103-
meterRegistry.registerLongCounter("es.blob_cache.epoch.total", "The epoch changes of the LFU cache", "count")
105+
meterRegistry.registerLongCounter("es.blob_cache.epoch.total", "The epoch changes of the LFU cache", "count"),
106+
meterRegistry.registerLongHistogram(
107+
SEARCH_ORIGIN_REMOTE_STORAGE_DOWNLOAD_TOOK_TIME,
108+
"The distribution of time in millis taken to download data from remote storage for search requests",
109+
"milliseconds"
110+
)
104111
);
105112

106113
meterRegistry.registerLongGauge(
@@ -137,7 +144,8 @@ public BlobCacheMetrics(MeterRegistry meterRegistry) {
137144
DoubleHistogram cachePopulationThroughput,
138145
LongCounter cachePopulationBytes,
139146
LongCounter cachePopulationTime,
140-
LongCounter epochChanges
147+
LongCounter epochChanges,
148+
LongHistogram searchOriginDownloadTime
141149
) {
142150
this.cacheMissCounter = cacheMissCounter;
143151
this.evictedCountNonZeroFrequency = evictedCountNonZeroFrequency;
@@ -147,6 +155,7 @@ public BlobCacheMetrics(MeterRegistry meterRegistry) {
147155
this.cachePopulationBytes = cachePopulationBytes;
148156
this.cachePopulationTime = cachePopulationTime;
149157
this.epochChanges = epochChanges;
158+
this.searchOriginDownloadTime = searchOriginDownloadTime;
150159
}
151160

152161
public static final BlobCacheMetrics NOOP = new BlobCacheMetrics(TelemetryProvider.NOOP.getMeterRegistry());
@@ -167,6 +176,10 @@ public LongHistogram getCacheMissLoadTimes() {
167176
return cacheMissLoadTimes;
168177
}
169178

179+
public LongHistogram getSearchOriginDownloadTime() {
180+
return searchOriginDownloadTime;
181+
}
182+
170183
/**
171184
* Record the various cache population metrics after a chunk is copied to the cache
172185
*

x-pack/plugin/blob-cache/src/main/java/org/elasticsearch/blobcache/shared/SharedBlobCacheService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ public BlobCacheMetrics getBlobCacheMetrics() {
420420
return blobCacheMetrics;
421421
}
422422

423+
public ThreadPool getThreadPool() {
424+
return threadPool;
425+
}
426+
423427
public int getRangeSize() {
424428
return rangeSize;
425429
}

0 commit comments

Comments
 (0)