@@ -1968,18 +1968,21 @@ func (i *Ingester) QueryStream(req *client.QueryRequest, stream client.Ingester_
1968
1968
numSamples := 0
1969
1969
numSeries := 0
1970
1970
totalDataBytes := 0
1971
- numSeries , numSamples , totalDataBytes , err = i .queryStreamChunks (ctx , db , int64 (from ), int64 (through ), matchers , shardMatcher , stream )
1971
+ numChunks := 0
1972
+ numSeries , numSamples , totalDataBytes , numChunks , err = i .queryStreamChunks (ctx , db , int64 (from ), int64 (through ), matchers , shardMatcher , stream )
1972
1973
1973
1974
if err != nil {
1974
1975
return err
1975
1976
}
1976
1977
1977
1978
i .metrics .queriedSeries .Observe (float64 (numSeries ))
1978
1979
i .metrics .queriedSamples .Observe (float64 (numSamples ))
1979
- level .Debug (spanlog ).Log ("series" , numSeries , "samples" , numSamples , "data_bytes" , totalDataBytes )
1980
+ i .metrics .queriedChunks .Observe (float64 (numChunks ))
1981
+ level .Debug (spanlog ).Log ("series" , numSeries , "samples" , numSamples , "data_bytes" , totalDataBytes , "chunks" , numChunks )
1980
1982
spanlog .SetTag ("series" , numSeries )
1981
1983
spanlog .SetTag ("samples" , numSamples )
1982
1984
spanlog .SetTag ("data_bytes" , totalDataBytes )
1985
+ spanlog .SetTag ("chunks" , numChunks )
1983
1986
return nil
1984
1987
}
1985
1988
@@ -1998,16 +2001,16 @@ func (i *Ingester) trackInflightQueryRequest() (func(), error) {
1998
2001
}
1999
2002
2000
2003
// queryStreamChunks streams metrics from a TSDB. This implements the client.IngesterServer interface
2001
- func (i * Ingester ) queryStreamChunks (ctx context.Context , db * userTSDB , from , through int64 , matchers []* labels.Matcher , sm * storepb.ShardMatcher , stream client.Ingester_QueryStreamServer ) (numSeries , numSamples , totalBatchSizeBytes int , _ error ) {
2004
+ func (i * Ingester ) queryStreamChunks (ctx context.Context , db * userTSDB , from , through int64 , matchers []* labels.Matcher , sm * storepb.ShardMatcher , stream client.Ingester_QueryStreamServer ) (numSeries , numSamples , totalBatchSizeBytes , numChunks int , _ error ) {
2002
2005
q , err := db .ChunkQuerier (from , through )
2003
2006
if err != nil {
2004
- return 0 , 0 , 0 , err
2007
+ return 0 , 0 , 0 , 0 , err
2005
2008
}
2006
2009
defer q .Close ()
2007
2010
2008
2011
c , err := i .trackInflightQueryRequest ()
2009
2012
if err != nil {
2010
- return 0 , 0 , 0 , err
2013
+ return 0 , 0 , 0 , 0 , err
2011
2014
}
2012
2015
hints := & storage.SelectHints {
2013
2016
Start : from ,
@@ -2018,7 +2021,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2018
2021
ss := q .Select (ctx , false , hints , matchers ... )
2019
2022
c ()
2020
2023
if ss .Err () != nil {
2021
- return 0 , 0 , 0 , ss .Err ()
2024
+ return 0 , 0 , 0 , 0 , ss .Err ()
2022
2025
}
2023
2026
2024
2027
chunkSeries := make ([]client.TimeSeriesChunk , 0 , queryStreamBatchSize )
@@ -2044,7 +2047,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2044
2047
// It is not guaranteed that chunk returned by iterator is populated.
2045
2048
// For now just return error. We could also try to figure out how to read the chunk.
2046
2049
if meta .Chunk == nil {
2047
- return 0 , 0 , 0 , errors .Errorf ("unfilled chunk returned from TSDB chunk querier" )
2050
+ return 0 , 0 , 0 , 0 , errors .Errorf ("unfilled chunk returned from TSDB chunk querier" )
2048
2051
}
2049
2052
2050
2053
ch := client.Chunk {
@@ -2061,10 +2064,11 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2061
2064
case chunkenc .EncFloatHistogram :
2062
2065
ch .Encoding = int32 (encoding .PrometheusFloatHistogramChunk )
2063
2066
default :
2064
- return 0 , 0 , 0 , errors .Errorf ("unknown chunk encoding from TSDB chunk querier: %v" , meta .Chunk .Encoding ())
2067
+ return 0 , 0 , 0 , 0 , errors .Errorf ("unknown chunk encoding from TSDB chunk querier: %v" , meta .Chunk .Encoding ())
2065
2068
}
2066
2069
2067
2070
ts .Chunks = append (ts .Chunks , ch )
2071
+ numChunks ++
2068
2072
numSamples += meta .Chunk .NumSamples ()
2069
2073
}
2070
2074
numSeries ++
@@ -2078,7 +2082,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2078
2082
Chunkseries : chunkSeries ,
2079
2083
})
2080
2084
if err != nil {
2081
- return 0 , 0 , 0 , err
2085
+ return 0 , 0 , 0 , 0 , err
2082
2086
}
2083
2087
2084
2088
batchSizeBytes = 0
@@ -2091,7 +2095,7 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2091
2095
2092
2096
// Ensure no error occurred while iterating the series set.
2093
2097
if err := ss .Err (); err != nil {
2094
- return 0 , 0 , 0 , err
2098
+ return 0 , 0 , 0 , 0 , err
2095
2099
}
2096
2100
2097
2101
// Final flush any existing metrics
@@ -2100,11 +2104,11 @@ func (i *Ingester) queryStreamChunks(ctx context.Context, db *userTSDB, from, th
2100
2104
Chunkseries : chunkSeries ,
2101
2105
})
2102
2106
if err != nil {
2103
- return 0 , 0 , 0 , err
2107
+ return 0 , 0 , 0 , 0 , err
2104
2108
}
2105
2109
}
2106
2110
2107
- return numSeries , numSamples , totalBatchSizeBytes , nil
2111
+ return numSeries , numSamples , totalBatchSizeBytes , numChunks , nil
2108
2112
}
2109
2113
2110
2114
func (i * Ingester ) getTSDB (userID string ) * userTSDB {
0 commit comments