Improve the metric of stored binlog size to the level of collection and segment (#23859)

Signed-off-by: bigsheeper <yihao.dai@zilliz.com>
pull/23919/head
yihao.dai 2023-05-07 20:52:38 +08:00 committed by GitHub
parent ad75afdcd1
commit fc010ee86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View File

@ -257,7 +257,6 @@ func (m *meta) GetCollectionBinlogSize() (int64, map[UniqueID]int64) {
m.RLock() m.RLock()
defer m.RUnlock() defer m.RUnlock()
collectionBinlogSize := make(map[UniqueID]int64) collectionBinlogSize := make(map[UniqueID]int64)
sizesOfStates := make(map[commonpb.SegmentState]int64)
segments := m.segments.GetSegments() segments := m.segments.GetSegments()
var total int64 var total int64
for _, segment := range segments { for _, segment := range segments {
@ -266,10 +265,8 @@ func (m *meta) GetCollectionBinlogSize() (int64, map[UniqueID]int64) {
total += segmentSize total += segmentSize
collectionBinlogSize[segment.GetCollectionID()] += segmentSize collectionBinlogSize[segment.GetCollectionID()] += segmentSize
} }
sizesOfStates[segment.GetState()] += segmentSize metrics.DataCoordStoredBinlogSize.WithLabelValues(
} fmt.Sprint(segment.GetCollectionID()), fmt.Sprint(segment.GetID())).Set(float64(segmentSize))
for state, size := range sizesOfStates {
metrics.DataCoordStoredBinlogSize.WithLabelValues(state.String()).Set(float64(size))
} }
return total, collectionBinlogSize return total, collectionBinlogSize
} }

View File

@ -96,7 +96,10 @@ var (
Subsystem: typeutil.DataCoordRole, Subsystem: typeutil.DataCoordRole,
Name: "stored_binlog_size", Name: "stored_binlog_size",
Help: "binlog size of segments", Help: "binlog size of segments",
}, []string{segmentStateLabelName}) }, []string{
collectionIDLabelName,
segmentIDLabelName,
})
DataCoordSegmentBinLogFileCount = prometheus.NewGaugeVec( DataCoordSegmentBinLogFileCount = prometheus.NewGaugeVec(
prometheus.GaugeOpts{ prometheus.GaugeOpts{
@ -204,4 +207,8 @@ func CleanupDataCoordSegmentMetrics(collectionID int64, segmentID int64) {
collectionIDLabelName: fmt.Sprint(collectionID), collectionIDLabelName: fmt.Sprint(collectionID),
segmentIDLabelName: fmt.Sprint(segmentID), segmentIDLabelName: fmt.Sprint(segmentID),
}) })
DataCoordStoredBinlogSize.Delete(prometheus.Labels{
collectionIDLabelName: fmt.Sprint(collectionID),
segmentIDLabelName: fmt.Sprint(segmentID),
})
} }