Skip to content

Commit

Permalink
enhance: Add metrics for Delete entries num of L0seg (#36175)
Browse files Browse the repository at this point in the history
- Add metrics *DataCoordL0DeleteEntriesNum*
- Remove metrics *DataCoordRateStoredL0Segment*

See also: #36147

---------

Signed-off-by: yangxuan <xuan.yang@zilliz.com>
  • Loading branch information
XuanYang-cn committed Sep 12, 2024
1 parent b5ff348 commit e8840a1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
14 changes: 11 additions & 3 deletions internal/datacoord/meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,22 @@ func (m *meta) GetQuotaInfo() *metricsinfo.DataCoordQuotaMetrics {

metrics.DataCoordNumStoredRows.Reset()
for collectionID, statesRows := range collectionRowsNum {
for state, rows := range statesRows {
coll, ok := m.collections[collectionID]
if ok {
coll, ok := m.collections[collectionID]
if ok {
for state, rows := range statesRows {
metrics.DataCoordNumStoredRows.WithLabelValues(coll.DatabaseName, fmt.Sprint(collectionID), state.String()).Set(float64(rows))
}
}
}

metrics.DataCoordL0DeleteEntriesNum.Reset()
for collectionID, entriesNum := range collectionL0RowCounts {
coll, ok := m.collections[collectionID]
if ok {
metrics.DataCoordL0DeleteEntriesNum.WithLabelValues(coll.DatabaseName, fmt.Sprint(collectionID)).Set(float64(entriesNum))
}
}

info.TotalBinlogSize = total
info.CollectionBinlogSize = collectionBinlogSize
info.PartitionsBinlogSize = partitionBinlogSize
Expand Down
2 changes: 0 additions & 2 deletions internal/datacoord/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,6 @@ func (s *Server) SaveBinlogPaths(ctx context.Context, req *datapb.SaveBinlogPath

if req.GetSegLevel() == datapb.SegmentLevel_L0 {
metrics.DataCoordSizeStoredL0Segment.WithLabelValues(fmt.Sprint(req.GetCollectionID())).Observe(calculateL0SegmentSize(req.GetField2StatslogPaths()))
metrics.DataCoordRateStoredL0Segment.WithLabelValues().Inc()

return merr.Success(), nil
}

Expand Down
18 changes: 12 additions & 6 deletions pkg/metrics/datacoord_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ var (
collectionIDLabelName,
})

DataCoordRateStoredL0Segment = prometheus.NewCounterVec(
prometheus.CounterOpts{
DataCoordL0DeleteEntriesNum = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: milvusNamespace,
Subsystem: typeutil.DataCoordRole,
Name: "store_level0_segment_rate",
Help: "stored l0 segment rate",
}, []string{})
Name: "l0_delete_entries_num",
Help: "Delete entries number of Level zero segment",
}, []string{
databaseLabelName,
collectionIDLabelName,
})

// DataCoordNumStoredRows all metrics will be cleaned up after removing matched collectionID and
// segment state labels in CleanupDataCoordNumStoredRows method.
Expand Down Expand Up @@ -349,7 +352,7 @@ func RegisterDataCoord(registry *prometheus.Registry) {
registry.MustRegister(DataCoordCompactionTaskNum)
registry.MustRegister(DataCoordCompactionLatency)
registry.MustRegister(DataCoordSizeStoredL0Segment)
registry.MustRegister(DataCoordRateStoredL0Segment)
registry.MustRegister(DataCoordL0DeleteEntriesNum)
registry.MustRegister(FlushedSegmentFileNum)
registry.MustRegister(IndexRequestCounter)
registry.MustRegister(IndexTaskNum)
Expand Down Expand Up @@ -402,4 +405,7 @@ func CleanupDataCoordWithCollectionID(collectionID int64) {
DataCoordSizeStoredL0Segment.Delete(prometheus.Labels{
collectionIDLabelName: fmt.Sprint(collectionID),
})
DataCoordL0DeleteEntriesNum.DeletePartialMatch(prometheus.Labels{
collectionIDLabelName: fmt.Sprint(collectionID),
})
}

0 comments on commit e8840a1

Please sign in to comment.