Skip to content

Commit

Permalink
Expose info for each TSDB
Browse files Browse the repository at this point in the history
This commit exposes the label set alongside the min and max time
for each TSDB covered by a Store.

This information is used to scope the min time for a remote query
so that we do not produce partial aggregates in distriuted mode.

Signed-off-by: Filip Petkovski <[email protected]>
  • Loading branch information
fpetkovski committed May 2, 2023
1 parent 6d838e7 commit f855642
Show file tree
Hide file tree
Showing 20 changed files with 698 additions and 98 deletions.
2 changes: 1 addition & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -782,12 +782,12 @@ func runQuery(
info.WithStoreInfoFunc(func() *infopb.StoreInfo {
if httpProbe.IsReady() {
mint, maxt := proxy.TimeRange()

return &infopb.StoreInfo{
MinTime: mint,
MaxTime: maxt,
SupportsSharding: true,
SupportsWithoutReplicaLabels: true,
TsdbInfos: proxy.TSDBInfos(),
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ func runReceive(
MaxTime: maxTime,
SupportsSharding: true,
SupportsWithoutReplicaLabels: true,
TsdbInfos: proxy.TSDBInfos(),
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/thanos/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,7 @@ func runRule(
MaxTime: maxt,
SupportsSharding: true,
SupportsWithoutReplicaLabels: true,
TsdbInfos: tsdbStore.TSDBInfos(),
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/thanos/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ func runSidecar(
MaxTime: maxt,
SupportsSharding: true,
SupportsWithoutReplicaLabels: true,
TsdbInfos: promStore.TSDBInfos(),
}
}
return nil
Expand Down
1 change: 1 addition & 0 deletions cmd/thanos/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ func runStore(
MaxTime: maxt,
SupportsSharding: true,
SupportsWithoutReplicaLabels: true,
TsdbInfos: bs.TSDBInfos(),
}
}
return nil
Expand Down
40 changes: 40 additions & 0 deletions pkg/info/infopb/custom.pb.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package infopb

import (
"math"

"github.com/prometheus/prometheus/model/labels"

"github.com/thanos-io/thanos/pkg/store/labelpb"
)

func NewTSDBInfo(mint, maxt int64, lbls []labelpb.ZLabel) TSDBInfo {
return TSDBInfo{
Labels: labelpb.ZLabelSet{
Labels: lbls,
},
MinTime: mint,
MaxTime: maxt,
}
}

type TSDBInfos []TSDBInfo

func (infos TSDBInfos) MaxT() int64 {
var maxt int64 = math.MinInt64
for _, info := range infos {
if info.MaxTime > maxt {
maxt = info.MaxTime
}
}
return maxt
}

func (infos TSDBInfos) LabelSets() []labels.Labels {
lsets := make([]labels.Labels, 0, len(infos))
for _, info := range infos {
lsets = append(lsets, labelpb.ZLabelsToPromLabels(info.Labels.Labels))

}
return lsets
}
Loading

0 comments on commit f855642

Please sign in to comment.