Skip to content

Commit

Permalink
Merge pull request #6329 from fpetkovski/expose-tsdb-infos
Browse files Browse the repository at this point in the history
Expose info for each TSDB
  • Loading branch information
fpetkovski authored May 8, 2023
2 parents df6c6f7 + 6fd6d2c commit 6e925ad
Show file tree
Hide file tree
Showing 19 changed files with 725 additions and 96 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 @@ -343,6 +343,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 6e925ad

Please sign in to comment.