2021-11-03 19:27:24 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2021-05-21 21:48:04 +08:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
2023-04-11 10:32:31 +08:00
|
|
|
// #nosec
|
2021-12-23 11:39:10 +08:00
|
|
|
_ "net/http/pprof"
|
|
|
|
|
2021-06-01 11:04:31 +08:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
2021-05-21 21:48:04 +08:00
|
|
|
)
|
|
|
|
|
2021-06-01 16:10:32 +08:00
|
|
|
const (
|
2021-12-13 10:31:17 +08:00
|
|
|
milvusNamespace = "milvus"
|
2022-03-02 16:23:55 +08:00
|
|
|
|
|
|
|
AbandonLabel = "abandon"
|
2022-03-03 16:05:57 +08:00
|
|
|
SuccessLabel = "success"
|
|
|
|
FailLabel = "fail"
|
|
|
|
TotalLabel = "total"
|
2022-03-02 16:23:55 +08:00
|
|
|
|
2022-11-07 10:15:02 +08:00
|
|
|
InsertLabel = "insert"
|
|
|
|
DeleteLabel = "delete"
|
2023-01-04 17:21:36 +08:00
|
|
|
UpsertLabel = "upsert"
|
2022-11-07 10:15:02 +08:00
|
|
|
SearchLabel = "search"
|
|
|
|
QueryLabel = "query"
|
2022-03-02 16:23:55 +08:00
|
|
|
CacheHitLabel = "hit"
|
|
|
|
CacheMissLabel = "miss"
|
2022-11-07 10:15:02 +08:00
|
|
|
TimetickLabel = "timetick"
|
|
|
|
AllLabel = "all"
|
2022-03-03 16:05:57 +08:00
|
|
|
|
|
|
|
UnissuedIndexTaskLabel = "unissued"
|
|
|
|
InProgressIndexTaskLabel = "in-progress"
|
|
|
|
FinishedIndexTaskLabel = "finished"
|
|
|
|
FailedIndexTaskLabel = "failed"
|
|
|
|
RecycledIndexTaskLabel = "recycled"
|
|
|
|
|
2022-11-22 19:21:13 +08:00
|
|
|
// Note: below must matchcommonpb.SegmentState_name fields.
|
2022-03-15 21:51:21 +08:00
|
|
|
SealedSegmentLabel = "Sealed"
|
|
|
|
GrowingSegmentLabel = "Growing"
|
|
|
|
FlushedSegmentLabel = "Flushed"
|
|
|
|
FlushingSegmentLabel = "Flushing"
|
2022-11-22 19:21:13 +08:00
|
|
|
DroppedSegmentLabel = "Dropped"
|
2022-03-15 21:51:21 +08:00
|
|
|
|
2022-11-10 11:51:03 +08:00
|
|
|
Leader = "OnLeader"
|
|
|
|
FromLeader = "FromLeader"
|
|
|
|
|
2023-02-13 16:50:33 +08:00
|
|
|
HookBefore = "before"
|
|
|
|
HookAfter = "after"
|
|
|
|
HookMock = "mock"
|
|
|
|
|
2022-03-15 21:51:21 +08:00
|
|
|
nodeIDLabelName = "node_id"
|
|
|
|
statusLabelName = "status"
|
|
|
|
indexTaskStatusLabelName = "index_task_status"
|
|
|
|
msgTypeLabelName = "msg_type"
|
|
|
|
collectionIDLabelName = "collection_id"
|
2022-11-28 14:53:14 +08:00
|
|
|
partitionIDLabelName = "partition_id"
|
2022-03-15 21:51:21 +08:00
|
|
|
channelNameLabelName = "channel_name"
|
|
|
|
functionLabelName = "function_name"
|
|
|
|
queryTypeLabelName = "query_type"
|
2022-10-18 19:17:27 +08:00
|
|
|
collectionName = "collection_name"
|
2022-04-27 23:03:47 +08:00
|
|
|
segmentStateLabelName = "segment_state"
|
2023-02-13 10:24:33 +08:00
|
|
|
segmentIDLabelName = "segment_id"
|
2022-04-11 19:49:34 +08:00
|
|
|
usernameLabelName = "username"
|
2022-11-02 10:55:34 +08:00
|
|
|
roleNameLabelName = "role_name"
|
2022-04-27 23:03:47 +08:00
|
|
|
cacheNameLabelName = "cache_name"
|
|
|
|
cacheStateLabelName = "cache_state"
|
2022-11-28 14:53:14 +08:00
|
|
|
indexCountLabelName = "indexed_field_count"
|
2022-11-10 11:51:03 +08:00
|
|
|
requestScope = "scope"
|
2023-02-13 16:50:33 +08:00
|
|
|
fullMethodLabelName = "full_method"
|
2022-03-03 16:05:57 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
// buckets involves durations in milliseconds,
|
|
|
|
// [1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536 1.31072e+05]
|
|
|
|
buckets = prometheus.ExponentialBuckets(1, 2, 18)
|
2023-06-26 17:52:44 +08:00
|
|
|
|
|
|
|
NumNodes = prometheus.NewGaugeVec(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Namespace: milvusNamespace,
|
|
|
|
Name: "num_node",
|
|
|
|
Help: "number of nodes and coordinates",
|
|
|
|
}, []string{nodeIDLabelName, roleNameLabelName})
|
2021-06-01 16:10:32 +08:00
|
|
|
)
|
2023-06-26 17:52:44 +08:00
|
|
|
|
|
|
|
// Register serves prometheus http service
|
|
|
|
func Register(r *prometheus.Registry) {
|
|
|
|
r.MustRegister(NumNodes)
|
|
|
|
}
|