Add store & cache download statistics (#7982)

pull/7940/head
Danny Kopping 2 years ago committed by GitHub
parent fe69443a05
commit a4f306399a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      docs/sources/upgrading/_index.md
  2. 4
      pkg/logql/metrics.go
  3. 2
      pkg/logql/metrics_test.go
  4. 18
      pkg/logqlmodel/stats/context.go
  5. 161
      pkg/logqlmodel/stats/stats.pb.go
  6. 1
      pkg/logqlmodel/stats/stats.proto
  7. 9
      pkg/querier/queryrange/codec_test.go
  8. 11
      pkg/querier/queryrange/prometheus_test.go
  9. 4
      pkg/storage/chunk/cache/stats.go
  10. 9
      pkg/util/marshal/legacy/marshal_test.go
  11. 27
      pkg/util/marshal/marshal_test.go

@ -80,6 +80,20 @@ If you are not using Query Scheduler, then to avoid any issues on the Read path
* Rollout changes to `queriers`.
* Roll out the rest of the changes.
### General
#### Store & Cache Statistics
Statistics are now logged in `metrics.go` lines about how long it takes to download chunks from the store, as well as how long it takes to download chunks, index query, and result cache responses from cache.
Example (note the `*_download_time` fields):
```
level=info ts=2022-12-20T15:27:54.858554127Z caller=metrics.go:147 component=frontend org_id=docker latency=fast query="sum(count_over_time({job=\"generated-logs\"}[1h]))" query_type=metric range_type=range length=6h17m48.865587821s start_delta=6h17m54.858533178s end_delta=5.99294552s step=1m30s duration=5.990829396s status=200 limit=30 returned_lines=0 throughput=123MB total_bytes=738MB total_entries=1 store_chunks_download_time=2.319297059s queue_time=2m21.476090991s subqueries=8 cache_chunk_req=81143 cache_chunk_hit=32390 cache_chunk_bytes_stored=1874098 cache_chunk_bytes_fetched=94289610 cache_chunk_download_time=56.96914ms cache_index_req=994 cache_index_hit=710 cache_index_download_time=1.587842ms cache_result_req=7 cache_result_hit=0 cache_result_download_time=380.555µs
```
These statistics are also displayed when using `--stats` with LogCLI.
## 2.7.0
### Loki

@ -126,16 +126,20 @@ func RecordRangeAndInstantQueryMetrics(
"throughput", strings.Replace(humanize.Bytes(uint64(stats.Summary.BytesProcessedPerSecond)), " ", "", 1),
"total_bytes", strings.Replace(humanize.Bytes(uint64(stats.Summary.TotalBytesProcessed)), " ", "", 1),
"total_entries", stats.Summary.TotalEntriesReturned,
"store_chunks_download_time", stats.ChunksDownloadTime(),
"queue_time", logql_stats.ConvertSecondsToNanoseconds(stats.Summary.QueueTime),
"subqueries", stats.Summary.Subqueries,
"cache_chunk_req", stats.Caches.Chunk.EntriesRequested,
"cache_chunk_hit", stats.Caches.Chunk.EntriesFound,
"cache_chunk_bytes_stored", stats.Caches.Chunk.BytesSent,
"cache_chunk_bytes_fetched", stats.Caches.Chunk.BytesReceived,
"cache_chunk_download_time", stats.Caches.Chunk.CacheDownloadTime(),
"cache_index_req", stats.Caches.Index.EntriesRequested,
"cache_index_hit", stats.Caches.Index.EntriesFound,
"cache_index_download_time", stats.Caches.Index.CacheDownloadTime(),
"cache_result_req", stats.Caches.Result.EntriesRequested,
"cache_result_hit", stats.Caches.Result.EntriesFound,
"cache_result_download_time", stats.Caches.Result.CacheDownloadTime(),
}...)
logValues = append(logValues, tagsToKeyValues(queryTags)...)

@ -85,7 +85,7 @@ func TestLogSlowQuery(t *testing.T) {
}, logqlmodel.Streams{logproto.Stream{Entries: make([]logproto.Entry, 10)}})
require.Regexp(t,
regexp.MustCompile(fmt.Sprintf(
`level=info org_id=foo traceID=%s latency=slow query=".*" query_type=filter range_type=range length=1h0m0s start_delta=.* end_delta=.* step=1m0s duration=25.25s status=200 limit=1000 returned_lines=10 throughput=100kB total_bytes=100kB total_entries=10 queue_time=2ns subqueries=0 cache_chunk_req=0 cache_chunk_hit=0 cache_chunk_bytes_stored=0 cache_chunk_bytes_fetched=0 cache_index_req=0 cache_index_hit=0 cache_result_req=0 cache_result_hit=0 source=logvolhist feature=beta\n`,
`level=info org_id=foo traceID=%s latency=slow query=".*" query_type=filter range_type=range length=1h0m0s .*\n`,
sp.Context().(jaeger.SpanContext).SpanID().String(),
)),
buf.String())

@ -201,6 +201,11 @@ func (c *Cache) Merge(m Cache) {
c.Requests += m.Requests
c.BytesSent += m.BytesSent
c.BytesReceived += m.BytesReceived
c.DownloadTime += m.DownloadTime
}
func (c *Cache) CacheDownloadTime() time.Duration {
return time.Duration(c.DownloadTime)
}
// Merge merges two results of statistics.
@ -347,6 +352,16 @@ func (c *Context) AddCacheBytesSent(t CacheType, i int) {
atomic.AddInt64(&stats.BytesSent, int64(i))
}
// AddCacheDownloadTime measures the time to download the data from cache
func (c *Context) AddCacheDownloadTime(t CacheType, i time.Duration) {
stats := c.getCacheStatsByType(t)
if stats == nil {
return
}
atomic.AddInt64(&stats.DownloadTime, int64(i))
}
// AddCacheRequest counts the number of fetch/store requests to the cache
func (c *Context) AddCacheRequest(t CacheType, i int) {
stats := c.getCacheStatsByType(t)
@ -422,17 +437,20 @@ func (c Caches) Log(log log.Logger) {
"Cache.Chunk.EntriesStored", c.Chunk.EntriesStored,
"Cache.Chunk.BytesSent", humanize.Bytes(uint64(c.Chunk.BytesSent)),
"Cache.Chunk.BytesReceived", humanize.Bytes(uint64(c.Chunk.BytesReceived)),
"Cache.Chunk.DownloadTime", c.Chunk.CacheDownloadTime(),
"Cache.Index.Requests", c.Index.Requests,
"Cache.Index.EntriesRequested", c.Index.EntriesRequested,
"Cache.Index.EntriesFound", c.Index.EntriesFound,
"Cache.Index.EntriesStored", c.Index.EntriesStored,
"Cache.Index.BytesSent", humanize.Bytes(uint64(c.Index.BytesSent)),
"Cache.Index.BytesReceived", humanize.Bytes(uint64(c.Index.BytesReceived)),
"Cache.Index.DownloadTime", c.Index.CacheDownloadTime(),
"Cache.Result.Requests", c.Result.Requests,
"Cache.Result.EntriesRequested", c.Result.EntriesRequested,
"Cache.Result.EntriesFound", c.Result.EntriesFound,
"Cache.Result.EntriesStored", c.Result.EntriesStored,
"Cache.Result.BytesSent", humanize.Bytes(uint64(c.Result.BytesSent)),
"Cache.Result.BytesReceived", humanize.Bytes(uint64(c.Result.BytesReceived)),
"Cache.Result.DownloadTime", c.Result.CacheDownloadTime(),
)
}

@ -553,6 +553,7 @@ type Cache struct {
BytesReceived int64 `protobuf:"varint,4,opt,name=bytesReceived,proto3" json:"bytesReceived"`
BytesSent int64 `protobuf:"varint,5,opt,name=bytesSent,proto3" json:"bytesSent"`
Requests int32 `protobuf:"varint,6,opt,name=requests,proto3" json:"requests"`
DownloadTime int64 `protobuf:"varint,7,opt,name=downloadTime,proto3" json:"downloadTime"`
}
func (m *Cache) Reset() { *m = Cache{} }
@ -629,6 +630,13 @@ func (m *Cache) GetRequests() int32 {
return 0
}
func (m *Cache) GetDownloadTime() int64 {
if m != nil {
return m.DownloadTime
}
return 0
}
func init() {
proto.RegisterType((*Result)(nil), "stats.Result")
proto.RegisterType((*Caches)(nil), "stats.Caches")
@ -643,65 +651,66 @@ func init() {
func init() { proto.RegisterFile("pkg/logqlmodel/stats/stats.proto", fileDescriptor_6cdfe5d2aea33ebb) }
var fileDescriptor_6cdfe5d2aea33ebb = []byte{
// 925 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x56, 0x4b, 0x6f, 0xe4, 0x44,
0x10, 0x1e, 0xcf, 0xc4, 0x33, 0xd9, 0x26, 0xaf, 0xed, 0xcd, 0xb2, 0x06, 0x24, 0x3b, 0x9a, 0x53,
0x24, 0x50, 0x46, 0x3c, 0x24, 0x04, 0x62, 0x25, 0xe4, 0x2c, 0x2b, 0x45, 0x5a, 0xc4, 0x52, 0x81,
0x0b, 0x37, 0x8f, 0xdd, 0x3b, 0xb1, 0xe2, 0x71, 0x67, 0xfc, 0x80, 0xdd, 0x1b, 0x37, 0x8e, 0xf0,
0x1b, 0x10, 0x07, 0x2e, 0xfc, 0x8f, 0x1c, 0x73, 0xdc, 0x93, 0x45, 0x26, 0x17, 0xe4, 0xd3, 0x4a,
0xfc, 0x01, 0xd4, 0xd5, 0x3d, 0xb6, 0xdb, 0xe3, 0x91, 0xb8, 0x4c, 0x57, 0x7d, 0x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, 0x53, 0xf6, 0xff, 0x15, 0x06, 0x95, 0x25,
0x2e, 0x30, 0x68, 0x56, 0xd2, 0xa8, 0xee, 0x45, 0x4d, 0x1c, 0x34, 0xcf, 0x9d, 0x5e, 0xdf, 0xd8,
0xbd, 0x57, 0x37, 0x76, 0xef, 0xf5, 0x8d, 0x6d, 0xfc, 0xbc, 0xb4, 0x8d, 0x3f, 0x97, 0xb6, 0xf1,
0x72, 0x69, 0x1b, 0xd7, 0x4b, 0xdb, 0xf8, 0x7b, 0x69, 0x1b, 0xff, 0x2c, 0xed, 0xde, 0xeb, 0xa5,
0x6d, 0xfc, 0x76, 0x6b, 0xf7, 0xae, 0x6f, 0xed, 0xde, 0xab, 0x5b, 0xbb, 0xf7, 0xc3, 0x07, 0xb3,
0x30, 0xbb, 0xc8, 0xa7, 0x27, 0x3e, 0x9f, 0x4f, 0x66, 0x89, 0xf7, 0xcc, 0x8b, 0xbd, 0x49, 0xc4,
0x2f, 0xc3, 0x49, 0xd7, 0x97, 0xdd, 0x74, 0x88, 0xdf, 0x6d, 0x1f, 0xff, 0x1f, 0x00, 0x00, 0xff,
0xff, 0x33, 0x50, 0xe6, 0x64, 0xf8, 0x09, 0x00, 0x00,
}
func (this *Result) Equal(that interface{}) bool {
@ -981,6 +990,9 @@ func (this *Cache) Equal(that interface{}) bool {
if this.Requests != that1.Requests {
return false
}
if this.DownloadTime != that1.DownloadTime {
return false
}
return true
}
func (this *Result) GoString() string {
@ -1081,7 +1093,7 @@ func (this *Cache) GoString() string {
if this == nil {
return "nil"
}
s := make([]string, 0, 10)
s := make([]string, 0, 11)
s = append(s, "&stats.Cache{")
s = append(s, "EntriesFound: "+fmt.Sprintf("%#v", this.EntriesFound)+",\n")
s = append(s, "EntriesRequested: "+fmt.Sprintf("%#v", this.EntriesRequested)+",\n")
@ -1089,6 +1101,7 @@ func (this *Cache) GoString() string {
s = append(s, "BytesReceived: "+fmt.Sprintf("%#v", this.BytesReceived)+",\n")
s = append(s, "BytesSent: "+fmt.Sprintf("%#v", this.BytesSent)+",\n")
s = append(s, "Requests: "+fmt.Sprintf("%#v", this.Requests)+",\n")
s = append(s, "DownloadTime: "+fmt.Sprintf("%#v", this.DownloadTime)+",\n")
s = append(s, "}")
return strings.Join(s, "")
}
@ -1488,6 +1501,11 @@ func (m *Cache) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i
var l int
_ = l
if m.DownloadTime != 0 {
i = encodeVarintStats(dAtA, i, uint64(m.DownloadTime))
i--
dAtA[i] = 0x38
}
if m.Requests != 0 {
i = encodeVarintStats(dAtA, i, uint64(m.Requests))
i--
@ -1702,6 +1720,9 @@ func (m *Cache) Size() (n int) {
if m.Requests != 0 {
n += 1 + sovStats(uint64(m.Requests))
}
if m.DownloadTime != 0 {
n += 1 + sovStats(uint64(m.DownloadTime))
}
return n
}
@ -1816,6 +1837,7 @@ func (this *Cache) String() string {
`BytesReceived:` + fmt.Sprintf("%v", this.BytesReceived) + `,`,
`BytesSent:` + fmt.Sprintf("%v", this.BytesSent) + `,`,
`Requests:` + fmt.Sprintf("%v", this.Requests) + `,`,
`DownloadTime:` + fmt.Sprintf("%v", this.DownloadTime) + `,`,
`}`,
}, "")
return s
@ -3055,6 +3077,25 @@ func (m *Cache) Unmarshal(dAtA []byte) error {
break
}
}
case 7:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field DownloadTime", wireType)
}
m.DownloadTime = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowStats
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.DownloadTime |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
default:
iNdEx = preIndex
skippy, err := skipStats(dAtA[iNdEx:])

@ -126,4 +126,5 @@ message Cache {
int64 bytesReceived = 4 [(gogoproto.jsontag) = "bytesReceived"];
int64 bytesSent = 5 [(gogoproto.jsontag) = "bytesSent"];
int32 requests = 6 [(gogoproto.jsontag) = "requests"];
int64 downloadTime = 7 [(gogoproto.jsontag) = "downloadTime"];
}

@ -983,7 +983,8 @@ var (
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"index": {
"entriesFound": 0,
@ -991,7 +992,8 @@ var (
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"result": {
"entriesFound": 0,
@ -999,7 +1001,8 @@ var (
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
}
},
"summary": {

@ -54,7 +54,8 @@ var emptyStats = `"stats": {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"index": {
"entriesFound": 0,
@ -62,7 +63,8 @@ var emptyStats = `"stats": {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"result": {
"entriesFound": 0,
@ -70,7 +72,8 @@ var emptyStats = `"stats": {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
}
},
"summary": {
@ -80,7 +83,7 @@ var emptyStats = `"stats": {
"queueTime": 0,
"subqueries": 0,
"totalBytesProcessed":0,
"totalEntriesReturned":0,
"totalEntriesReturned":0,
"totalLinesProcessed":0
}
}`

@ -2,6 +2,7 @@ package cache
import (
"context"
"time"
"github.com/grafana/loki/pkg/logqlmodel/stats"
)
@ -32,8 +33,11 @@ func (s statsCollector) Fetch(ctx context.Context, keys []string) (found []strin
st := stats.FromContext(ctx)
st.AddCacheRequest(s.Cache.GetCacheType(), 1)
start := time.Now()
found, bufs, missing, err = s.Cache.Fetch(ctx, keys)
st.AddCacheDownloadTime(s.Cache.GetCacheType(), time.Since(start))
st.AddCacheEntriesFound(s.Cache.GetCacheType(), len(found))
st.AddCacheEntriesRequested(s.Cache.GetCacheType(), len(keys))

@ -85,7 +85,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"index": {
"entriesFound": 0,
@ -93,7 +94,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"result": {
"entriesFound": 0,
@ -101,7 +103,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
}
},
"summary": {

@ -94,7 +94,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"index": {
"entriesFound": 0,
@ -102,7 +103,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"result": {
"entriesFound": 0,
@ -110,7 +112,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
}
},
"summary": {
@ -230,7 +233,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"index": {
"entriesFound": 0,
@ -238,7 +242,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"result": {
"entriesFound": 0,
@ -246,7 +251,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
}
},
"summary": {
@ -383,7 +389,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"index": {
"entriesFound": 0,
@ -391,7 +398,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
},
"result": {
"entriesFound": 0,
@ -399,7 +407,8 @@ var queryTests = []struct {
"entriesStored": 0,
"bytesReceived": 0,
"bytesSent": 0,
"requests": 0
"requests": 0,
"downloadTime": 0
}
},
"summary": {

Loading…
Cancel
Save