mirror of https://github.com/milvus-io/milvus.git
enhance: Add collection name label for some metric (#36951)
Signed-off-by: aoiasd <zhicheng.yue@zilliz.com>pull/36693/head
parent
ac2858d418
commit
22b917a1e6
|
@ -824,7 +824,7 @@ func (m *indexMeta) SetStoredIndexFileSizeMetric(collections map[UniqueID]*colle
|
|||
for _, segmentIdx := range m.buildID2SegmentIndex {
|
||||
coll, ok := collections[segmentIdx.CollectionID]
|
||||
if ok {
|
||||
metrics.DataCoordStoredIndexFilesSize.WithLabelValues(coll.DatabaseName,
|
||||
metrics.DataCoordStoredIndexFilesSize.WithLabelValues(coll.DatabaseName, coll.Schema.GetName(),
|
||||
fmt.Sprint(segmentIdx.CollectionID), fmt.Sprint(segmentIdx.SegmentID)).Set(float64(segmentIdx.IndexSize))
|
||||
total += segmentIdx.IndexSize
|
||||
}
|
||||
|
|
|
@ -446,7 +446,7 @@ func (m *meta) GetQuotaInfo() *metricsinfo.DataCoordQuotaMetrics {
|
|||
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.DataCoordNumStoredRows.WithLabelValues(coll.DatabaseName, fmt.Sprint(collectionID), coll.Schema.GetName(), state.String()).Set(float64(rows))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error
|
|||
}
|
||||
|
||||
minTsafeChannel, minTsafe := node.tSafeManager.Min()
|
||||
collections := node.manager.Collection.List()
|
||||
collections := node.manager.Collection.ListWithName()
|
||||
nodeID := fmt.Sprint(node.GetNodeID())
|
||||
|
||||
metrics.QueryNodeNumEntities.Reset()
|
||||
|
@ -70,7 +70,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error
|
|||
growingGroupByCollection := lo.GroupBy(growingSegments, func(seg segments.Segment) int64 {
|
||||
return seg.Collection()
|
||||
})
|
||||
for _, collection := range collections {
|
||||
for collection := range collections {
|
||||
segs := growingGroupByCollection[collection]
|
||||
size := lo.SumBy(segs, func(seg segments.Segment) int64 {
|
||||
return seg.MemSize()
|
||||
|
@ -90,6 +90,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error
|
|||
segment := segs[0]
|
||||
metrics.QueryNodeNumEntities.WithLabelValues(
|
||||
segment.DatabaseName(),
|
||||
collections[segment.Collection()],
|
||||
nodeID,
|
||||
fmt.Sprint(segment.Collection()),
|
||||
fmt.Sprint(segment.Partition()),
|
||||
|
@ -101,7 +102,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error
|
|||
sealedGroupByCollection := lo.GroupBy(sealedSegments, func(seg segments.Segment) int64 {
|
||||
return seg.Collection()
|
||||
})
|
||||
for _, collection := range collections {
|
||||
for collection := range collections {
|
||||
segs := sealedGroupByCollection[collection]
|
||||
size := lo.SumBy(segs, func(seg segments.Segment) int64 {
|
||||
return seg.MemSize()
|
||||
|
@ -119,6 +120,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error
|
|||
segment := segs[0]
|
||||
metrics.QueryNodeNumEntities.WithLabelValues(
|
||||
segment.DatabaseName(),
|
||||
collections[segment.Collection()],
|
||||
nodeID,
|
||||
fmt.Sprint(segment.Collection()),
|
||||
fmt.Sprint(segment.Partition()),
|
||||
|
@ -148,7 +150,7 @@ func getQuotaMetrics(node *QueryNode) (*metricsinfo.QueryNodeQuotaMetrics, error
|
|||
GrowingSegmentsSize: totalGrowingSize,
|
||||
Effect: metricsinfo.NodeEffect{
|
||||
NodeID: node.GetNodeID(),
|
||||
CollectionIDs: collections,
|
||||
CollectionIDs: lo.Keys(collections),
|
||||
},
|
||||
DeleteBufferInfo: metricsinfo.DeleteBufferInfo{
|
||||
CollectionDeleteBufferNum: deleteBufferNum,
|
||||
|
|
|
@ -47,6 +47,7 @@ import (
|
|||
|
||||
type CollectionManager interface {
|
||||
List() []int64
|
||||
ListWithName() map[int64]string
|
||||
Get(collectionID int64) *Collection
|
||||
PutOrRef(collectionID int64, schema *schemapb.CollectionSchema, meta *segcorepb.CollectionIndexMeta, loadMeta *querypb.LoadMetaInfo)
|
||||
Ref(collectionID int64, count uint32) bool
|
||||
|
@ -74,6 +75,16 @@ func (m *collectionManager) List() []int64 {
|
|||
return lo.Keys(m.collections)
|
||||
}
|
||||
|
||||
// return all collections by map id --> name
|
||||
func (m *collectionManager) ListWithName() map[int64]string {
|
||||
m.mut.RLock()
|
||||
defer m.mut.RUnlock()
|
||||
|
||||
return lo.MapValues(m.collections, func(coll *Collection, _ int64) string {
|
||||
return coll.Schema().GetName()
|
||||
})
|
||||
}
|
||||
|
||||
func (m *collectionManager) Get(collectionID int64) *Collection {
|
||||
m.mut.RLock()
|
||||
defer m.mut.RUnlock()
|
||||
|
|
|
@ -118,6 +118,53 @@ func (_c *MockCollectionManager_List_Call) RunAndReturn(run func() []int64) *Moc
|
|||
return _c
|
||||
}
|
||||
|
||||
// ListWithName provides a mock function with given fields:
|
||||
func (_m *MockCollectionManager) ListWithName() map[int64]string {
|
||||
ret := _m.Called()
|
||||
|
||||
if len(ret) == 0 {
|
||||
panic("no return value specified for ListWithName")
|
||||
}
|
||||
|
||||
var r0 map[int64]string
|
||||
if rf, ok := ret.Get(0).(func() map[int64]string); ok {
|
||||
r0 = rf()
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(map[int64]string)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MockCollectionManager_ListWithName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListWithName'
|
||||
type MockCollectionManager_ListWithName_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// ListWithName is a helper method to define mock.On call
|
||||
func (_e *MockCollectionManager_Expecter) ListWithName() *MockCollectionManager_ListWithName_Call {
|
||||
return &MockCollectionManager_ListWithName_Call{Call: _e.mock.On("ListWithName")}
|
||||
}
|
||||
|
||||
func (_c *MockCollectionManager_ListWithName_Call) Run(run func()) *MockCollectionManager_ListWithName_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCollectionManager_ListWithName_Call) Return(_a0 map[int64]string) *MockCollectionManager_ListWithName_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MockCollectionManager_ListWithName_Call) RunAndReturn(run func() map[int64]string) *MockCollectionManager_ListWithName_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// PutOrRef provides a mock function with given fields: collectionID, schema, meta, loadMeta
|
||||
func (_m *MockCollectionManager) PutOrRef(collectionID int64, schema *schemapb.CollectionSchema, meta *segcorepb.CollectionIndexMeta, loadMeta *querypb.LoadMetaInfo) {
|
||||
_m.Called(collectionID, schema, meta, loadMeta)
|
||||
|
|
|
@ -96,6 +96,7 @@ var (
|
|||
}, []string{
|
||||
databaseLabelName,
|
||||
collectionIDLabelName,
|
||||
collectionName,
|
||||
segmentStateLabelName,
|
||||
})
|
||||
|
||||
|
@ -163,6 +164,7 @@ var (
|
|||
Help: "index files size of the segments",
|
||||
}, []string{
|
||||
databaseLabelName,
|
||||
collectionName,
|
||||
collectionIDLabelName,
|
||||
segmentIDLabelName,
|
||||
})
|
||||
|
@ -403,7 +405,7 @@ func CleanupDataCoordSegmentMetrics(dbName string, collectionID int64, segmentID
|
|||
collectionIDLabelName: fmt.Sprint(collectionID),
|
||||
segmentIDLabelName: fmt.Sprint(segmentID),
|
||||
})
|
||||
DataCoordStoredIndexFilesSize.Delete(prometheus.Labels{
|
||||
DataCoordStoredIndexFilesSize.DeletePartialMatch(prometheus.Labels{
|
||||
databaseLabelName: dbName,
|
||||
collectionIDLabelName: fmt.Sprint(collectionID),
|
||||
segmentIDLabelName: fmt.Sprint(segmentID),
|
||||
|
|
|
@ -439,6 +439,7 @@ var (
|
|||
Help: "number of entities which can be searched/queried, clustered by collection, partition and state",
|
||||
}, []string{
|
||||
databaseLabelName,
|
||||
collectionName,
|
||||
nodeIDLabelName,
|
||||
collectionIDLabelName,
|
||||
partitionIDLabelName,
|
||||
|
|
Loading…
Reference in New Issue