metrics.go 23.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
// 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.

Z
zwd1208 已提交
17 18 19 20 21 22
package metrics

import (
	"net/http"

	"github.com/milvus-io/milvus/internal/log"
C
Cai Yudong 已提交
23
	"github.com/prometheus/client_golang/prometheus"
Z
zwd1208 已提交
24 25 26 27 28
	"github.com/prometheus/client_golang/prometheus/promhttp"

	"go.uber.org/zap"
)

29
const (
C
Cai Yudong 已提交
30 31 32
	milvusNamespace    = "milvus"
	subSystemRootCoord = "rootcoord"
	subSystemDataCoord = "dataCoord"
X
XuanYang-cn 已提交
33
	subSystemDataNode  = "dataNode"
D
dragondriver 已提交
34
	subSystemProxy     = "proxy"
35 36
)

C
Cai Yudong 已提交
37
var (
38
	// RootCoordProxyLister counts the num of registered proxy nodes
39
	RootCoordProxyLister = prometheus.NewGaugeVec(
C
Cai Yudong 已提交
40
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
41 42
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
43
			Name:      "list_of_proxy",
44
			Help:      "List of proxy nodes which have registered with etcd",
C
Cai Yudong 已提交
45 46 47 48 49
		}, []string{"client_id"})

	////////////////////////////////////////////////////////////////////////////
	// for grpc

50
	// RootCoordCreateCollectionCounter counts the num of calls of CreateCollection
C
Cai Yudong 已提交
51
	RootCoordCreateCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
52
		prometheus.CounterOpts{
C
Cai Yudong 已提交
53 54
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
55 56 57 58
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"client_id", "type"})

59
	// RootCoordDropCollectionCounter counts the num of calls of DropCollection
C
Cai Yudong 已提交
60
	RootCoordDropCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
61
		prometheus.CounterOpts{
C
Cai Yudong 已提交
62 63
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
64 65 66 67
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"client_id", "type"})

68
	// RootCoordHasCollectionCounter counts the num of calls of HasCollection
C
Cai Yudong 已提交
69
	RootCoordHasCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
70
		prometheus.CounterOpts{
C
Cai Yudong 已提交
71 72
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
73 74 75 76
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"client_id", "type"})

77
	// RootCoordDescribeCollectionCounter counts the num of calls of DescribeCollection
C
Cai Yudong 已提交
78
	RootCoordDescribeCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
79
		prometheus.CounterOpts{
C
Cai Yudong 已提交
80 81
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
82 83 84 85
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"client_id", "type"})

86
	// RootCoordShowCollectionsCounter counts the num of calls of ShowCollections
C
Cai Yudong 已提交
87
	RootCoordShowCollectionsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
88
		prometheus.CounterOpts{
C
Cai Yudong 已提交
89 90
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
91 92 93 94
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"client_id", "type"})

95
	// RootCoordCreatePartitionCounter counts the num of calls of CreatePartition
C
Cai Yudong 已提交
96
	RootCoordCreatePartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
97
		prometheus.CounterOpts{
C
Cai Yudong 已提交
98 99
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
100 101 102 103
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"client_id", "type"})

104
	// RootCoordDropPartitionCounter counts the num of calls of DropPartition
C
Cai Yudong 已提交
105
	RootCoordDropPartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
106
		prometheus.CounterOpts{
C
Cai Yudong 已提交
107 108
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
109 110 111 112
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"client_id", "type"})

113
	// RootCoordHasPartitionCounter counts the num of calls of HasPartition
C
Cai Yudong 已提交
114
	RootCoordHasPartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
115
		prometheus.CounterOpts{
C
Cai Yudong 已提交
116 117
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
118 119 120 121
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"client_id", "type"})

122
	// RootCoordShowPartitionsCounter counts the num of calls of ShowPartitions
C
Cai Yudong 已提交
123
	RootCoordShowPartitionsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
124
		prometheus.CounterOpts{
C
Cai Yudong 已提交
125 126
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
127 128 129 130
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"client_id", "type"})

131
	// RootCoordCreateIndexCounter counts the num of calls of CreateIndex
C
Cai Yudong 已提交
132
	RootCoordCreateIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
133
		prometheus.CounterOpts{
C
Cai Yudong 已提交
134 135
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
136 137 138 139
			Name:      "create_index_total",
			Help:      "Counter of create index",
		}, []string{"client_id", "type"})

140
	// RootCoordDropIndexCounter counts the num of calls of DropIndex
C
Cai Yudong 已提交
141
	RootCoordDropIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
142
		prometheus.CounterOpts{
C
Cai Yudong 已提交
143 144
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
145 146 147 148
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"client_id", "type"})

149
	// RootCoordDescribeIndexCounter counts the num of calls of DescribeIndex
C
Cai Yudong 已提交
150
	RootCoordDescribeIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
151
		prometheus.CounterOpts{
C
Cai Yudong 已提交
152 153
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
154 155 156 157
			Name:      "describe_index_total",
			Help:      "Counter of describe index",
		}, []string{"client_id", "type"})

158
	// RootCoordDescribeSegmentCounter counts the num of calls of DescribeSegment
C
Cai Yudong 已提交
159
	RootCoordDescribeSegmentCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
160
		prometheus.CounterOpts{
C
Cai Yudong 已提交
161 162
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
163 164 165 166
			Name:      "describe_segment_total",
			Help:      "Counter of describe segment",
		}, []string{"client_id", "type"})

167
	// RootCoordShowSegmentsCounter counts the num of calls of ShowSegments
C
Cai Yudong 已提交
168
	RootCoordShowSegmentsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
169
		prometheus.CounterOpts{
C
Cai Yudong 已提交
170 171
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
172 173 174 175 176 177 178
			Name:      "show_segments_total",
			Help:      "Counter of show segments",
		}, []string{"client_id", "type"})

	////////////////////////////////////////////////////////////////////////////
	// for time tick

179
	// RootCoordInsertChannelTimeTick counts the time tick num of insert channel in 24H
C
Cai Yudong 已提交
180
	RootCoordInsertChannelTimeTick = prometheus.NewGaugeVec(
C
Cai Yudong 已提交
181
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
182 183
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
184 185 186 187
			Name:      "insert_channel_time_tick",
			Help:      "Time tick of insert Channel in 24H",
		}, []string{"vchannel"})

188
	// RootCoordDDChannelTimeTick counts the time tick num of dd channel in 24H
C
Cai Yudong 已提交
189
	RootCoordDDChannelTimeTick = prometheus.NewGauge(
C
Cai Yudong 已提交
190
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
191 192
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
193 194 195 196 197
			Name:      "dd_channel_time_tick",
			Help:      "Time tick of dd Channel in 24H",
		})
)

198
//RegisterRootCoord registers RootCoord metrics
C
Cai Yudong 已提交
199
func RegisterRootCoord() {
200
	prometheus.MustRegister(RootCoordProxyLister)
C
Cai Yudong 已提交
201 202

	// for grpc
C
Cai Yudong 已提交
203 204 205 206 207 208 209 210 211 212 213 214 215 216
	prometheus.MustRegister(RootCoordCreateCollectionCounter)
	prometheus.MustRegister(RootCoordDropCollectionCounter)
	prometheus.MustRegister(RootCoordHasCollectionCounter)
	prometheus.MustRegister(RootCoordDescribeCollectionCounter)
	prometheus.MustRegister(RootCoordShowCollectionsCounter)
	prometheus.MustRegister(RootCoordCreatePartitionCounter)
	prometheus.MustRegister(RootCoordDropPartitionCounter)
	prometheus.MustRegister(RootCoordHasPartitionCounter)
	prometheus.MustRegister(RootCoordShowPartitionsCounter)
	prometheus.MustRegister(RootCoordCreateIndexCounter)
	prometheus.MustRegister(RootCoordDropIndexCounter)
	prometheus.MustRegister(RootCoordDescribeIndexCounter)
	prometheus.MustRegister(RootCoordDescribeSegmentCounter)
	prometheus.MustRegister(RootCoordShowSegmentsCounter)
C
Cai Yudong 已提交
217 218

	// for time tick
C
Cai Yudong 已提交
219 220
	prometheus.MustRegister(RootCoordInsertChannelTimeTick)
	prometheus.MustRegister(RootCoordDDChannelTimeTick)
Z
zwd1208 已提交
221 222 223
	//prometheus.MustRegister(PanicCounter)
}

D
dragondriver 已提交
224
var (
225
	// ProxyCreateCollectionCounter counts the num of calls of CreateCollection
D
dragondriver 已提交
226 227 228 229 230 231 232 233
	ProxyCreateCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"status"})

234
	// ProxyDropCollectionCounter counts the num of calls of DropCollection
D
dragondriver 已提交
235 236 237 238 239 240 241 242
	ProxyDropCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"status"})

243
	// ProxyHasCollectionCounter counts the num of calls of HasCollection
D
dragondriver 已提交
244 245 246 247 248 249 250 251
	ProxyHasCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"status"})

252
	// ProxyLoadCollectionCounter counts the num of calls of LoadCollection
D
dragondriver 已提交
253 254 255 256 257 258 259 260
	ProxyLoadCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "load_collection_total",
			Help:      "Counter of load collection",
		}, []string{"status"})

261
	// ProxyReleaseCollectionCounter counts the num of calls of ReleaseCollection
D
dragondriver 已提交
262 263 264 265 266 267 268 269
	ProxyReleaseCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_collection_total",
			Help:      "Counter of release collection",
		}, []string{"status"})

270
	// ProxyDescribeCollectionCounter counts the num of calls of DescribeCollection
D
dragondriver 已提交
271 272 273 274 275 276 277 278
	ProxyDescribeCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"status"})

279
	// ProxyGetCollectionStatisticsCounter counts the num of calls of GetCollectionStatistics
D
dragondriver 已提交
280 281 282 283 284 285 286 287
	ProxyGetCollectionStatisticsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_collection_statistics_total",
			Help:      "Counter of get collection statistics",
		}, []string{"status"})

288
	// ProxyShowCollectionsCounter counts the num of calls of ShowCollections
D
dragondriver 已提交
289 290 291 292 293 294 295 296
	ProxyShowCollectionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"status"})

297
	// ProxyCreatePartitionCounter counts the num of calls of CreatePartition
D
dragondriver 已提交
298 299 300 301 302 303 304 305
	ProxyCreatePartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"status"})

306
	// ProxyDropPartitionCounter counts the num of calls of DropPartition
D
dragondriver 已提交
307 308 309 310 311 312 313 314
	ProxyDropPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"status"})

315
	// ProxyHasPartitionCounter counts the num of calls of HasPartition
D
dragondriver 已提交
316 317 318 319 320 321 322 323
	ProxyHasPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"status"})

324
	// ProxyLoadPartitionsCounter counts the num of calls of LoadPartitions
D
dragondriver 已提交
325 326 327 328 329 330 331 332
	ProxyLoadPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "load_partitions_total",
			Help:      "Counter of load partitions",
		}, []string{"status"})

333
	// ProxyReleasePartitionsCounter counts the num of calls of ReleasePartitions
D
dragondriver 已提交
334 335 336 337 338 339 340 341
	ProxyReleasePartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_partitions_total",
			Help:      "Counter of release partitions",
		}, []string{"status"})

342
	// ProxyGetPartitionStatisticsCounter counts the num of calls of GetPartitionStatistics
D
dragondriver 已提交
343 344 345 346 347 348 349 350
	ProxyGetPartitionStatisticsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_partition_statistics_total",
			Help:      "Counter of get partition statistics",
		}, []string{"status"})

351
	// ProxyShowPartitionsCounter counts the num of calls of ShowPartitions
D
dragondriver 已提交
352 353 354 355 356 357 358 359
	ProxyShowPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"status"})

360
	// ProxyCreateIndexCounter counts the num of calls of CreateIndex
D
dragondriver 已提交
361 362 363 364 365 366 367 368
	ProxyCreateIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_index_counter",
			Help:      "Counter of create index",
		}, []string{"status"})

369
	// ProxyDescribeIndexCounter counts the num of calls of DescribeIndex
D
dragondriver 已提交
370 371 372 373 374 375 376 377
	ProxyDescribeIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "describe_index_counter",
			Help:      "Counter of describe index",
		}, []string{"status"})

378
	// ProxyGetIndexStateCounter counts the num of calls of GetIndexState
D
dragondriver 已提交
379 380 381 382 383 384 385 386
	ProxyGetIndexStateCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_index_state_counter",
			Help:      "Counter of get index state",
		}, []string{"status"})

387
	// ProxyGetIndexBuildProgressCounter counts the num of calls of GetIndexBuildProgress
D
dragondriver 已提交
388 389 390 391 392 393 394 395
	ProxyGetIndexBuildProgressCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_index_build_progress_total",
			Help:      "Counter of get index build progress",
		}, []string{"status"})

396
	// ProxyDropIndexCounter counts the num of calls of DropIndex
D
dragondriver 已提交
397 398 399 400 401 402 403 404
	ProxyDropIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"status"})

405
	// ProxyInsertCounter counts the num of calls of Insert
D
dragondriver 已提交
406 407 408 409 410 411 412 413
	ProxyInsertCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "insert_total",
			Help:      "Counter of insert",
		}, []string{"status"})

414
	// ProxySearchCounter counts the num of calls of Search
D
dragondriver 已提交
415 416 417 418 419 420 421 422
	ProxySearchCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "search_total",
			Help:      "Counter of search",
		}, []string{"status"})

423
	// ProxyRetrieveCounter counts the num of calls of Retrieve
D
dragondriver 已提交
424 425 426 427 428 429 430 431
	ProxyRetrieveCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "retrieve_total",
			Help:      "Counter of retrieve",
		}, []string{"status"})

432
	// ProxyFlushCounter counts the num of calls of Flush
D
dragondriver 已提交
433 434 435 436 437 438 439 440
	ProxyFlushCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "flush_total",
			Help:      "Counter of flush",
		}, []string{"status"})

441
	// ProxyQueryCounter counts the num of calls of Query
D
dragondriver 已提交
442 443 444 445 446 447 448 449
	ProxyQueryCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "query_total",
			Help:      "Counter of query",
		}, []string{"status"})

450
	// ProxyGetPersistentSegmentInfoCounter counts the num of calls of GetPersistentSegmentInfo
D
dragondriver 已提交
451 452 453 454 455 456 457 458
	ProxyGetPersistentSegmentInfoCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_persistent_segment_info_total",
			Help:      "Counter of get persistent segment info",
		}, []string{"status"})

459
	// ProxyGetQuerySegmentInfoCounter counts the num of calls of GetQuerySegmentInfo
D
dragondriver 已提交
460 461 462 463 464 465 466 467
	ProxyGetQuerySegmentInfoCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_query_segment_info_total",
			Help:      "Counter of get query segment info",
		}, []string{"status"})

468
	// ProxyDummyCounter counts the num of calls of Dummy
D
dragondriver 已提交
469 470 471 472 473 474 475 476
	ProxyDummyCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "dummy_total",
			Help:      "Counter of dummy",
		}, []string{"status"})

477
	// ProxyRegisterLinkCounter counts the num of calls of RegisterLink
D
dragondriver 已提交
478 479 480 481 482 483 484 485
	ProxyRegisterLinkCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "register_link_total",
			Help:      "Counter of register link",
		}, []string{"status"})

486
	// ProxyGetComponentStatesCounter counts the num of calls of GetComponentStates
D
dragondriver 已提交
487 488 489 490 491 492 493 494
	ProxyGetComponentStatesCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_component_states_total",
			Help:      "Counter of get component states",
		}, []string{"status"})

495
	// ProxyGetStatisticsChannelCounter counts the num of calls of GetStatisticsChannel
D
dragondriver 已提交
496 497 498 499 500 501 502 503
	ProxyGetStatisticsChannelCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_statistics_channel_total",
			Help:      "Counter of get statistics channel",
		}, []string{"status"})

504
	// ProxyInvalidateCollectionMetaCacheCounter counts the num of calls of InvalidateCollectionMetaCache
D
dragondriver 已提交
505 506 507 508 509 510 511 512
	ProxyInvalidateCollectionMetaCacheCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "invalidate_collection_meta_cache_total",
			Help:      "Counter of invalidate collection meta cache",
		}, []string{"status"})

513
	// ProxyGetDdChannelCounter counts the num of calls of GetDdChannel
D
dragondriver 已提交
514 515 516 517 518 519 520 521
	ProxyGetDdChannelCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_dd_channel_total",
			Help:      "Counter of get dd channel",
		}, []string{"status"})

522
	// ProxyReleaseDQLMessageStreamCounter counts the num of calls of ReleaseDQLMessageStream
D
dragondriver 已提交
523 524 525 526 527 528 529
	ProxyReleaseDQLMessageStreamCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_dql_message_stream_total",
			Help:      "Counter of release dql message stream",
		}, []string{"status"})
530

531
	// ProxyDmlChannelTimeTick counts the time tick value of dml channels
532 533 534 535 536 537 538
	ProxyDmlChannelTimeTick = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "dml_channels_time_tick",
			Help:      "Time tick of dml channels",
		}, []string{"pchan"})
D
dragondriver 已提交
539
)
Z
zwd1208 已提交
540

541
//RegisterProxy registers Proxy metrics
D
dragondriver 已提交
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585
func RegisterProxy() {
	prometheus.MustRegister(ProxyCreateCollectionCounter)
	prometheus.MustRegister(ProxyDropCollectionCounter)
	prometheus.MustRegister(ProxyHasCollectionCounter)
	prometheus.MustRegister(ProxyLoadCollectionCounter)
	prometheus.MustRegister(ProxyReleaseCollectionCounter)
	prometheus.MustRegister(ProxyDescribeCollectionCounter)
	prometheus.MustRegister(ProxyGetCollectionStatisticsCounter)
	prometheus.MustRegister(ProxyShowCollectionsCounter)

	prometheus.MustRegister(ProxyCreatePartitionCounter)
	prometheus.MustRegister(ProxyDropPartitionCounter)
	prometheus.MustRegister(ProxyHasPartitionCounter)
	prometheus.MustRegister(ProxyLoadPartitionsCounter)
	prometheus.MustRegister(ProxyReleasePartitionsCounter)
	prometheus.MustRegister(ProxyGetPartitionStatisticsCounter)
	prometheus.MustRegister(ProxyShowPartitionsCounter)

	prometheus.MustRegister(ProxyCreateIndexCounter)
	prometheus.MustRegister(ProxyDescribeIndexCounter)
	prometheus.MustRegister(ProxyGetIndexStateCounter)
	prometheus.MustRegister(ProxyGetIndexBuildProgressCounter)
	prometheus.MustRegister(ProxyDropIndexCounter)

	prometheus.MustRegister(ProxyInsertCounter)
	prometheus.MustRegister(ProxySearchCounter)
	prometheus.MustRegister(ProxyRetrieveCounter)
	prometheus.MustRegister(ProxyFlushCounter)
	prometheus.MustRegister(ProxyQueryCounter)

	prometheus.MustRegister(ProxyGetPersistentSegmentInfoCounter)
	prometheus.MustRegister(ProxyGetQuerySegmentInfoCounter)

	prometheus.MustRegister(ProxyDummyCounter)

	prometheus.MustRegister(ProxyRegisterLinkCounter)

	prometheus.MustRegister(ProxyGetComponentStatesCounter)
	prometheus.MustRegister(ProxyGetStatisticsChannelCounter)

	prometheus.MustRegister(ProxyInvalidateCollectionMetaCacheCounter)
	prometheus.MustRegister(ProxyGetDdChannelCounter)

	prometheus.MustRegister(ProxyReleaseDQLMessageStreamCounter)
586 587

	prometheus.MustRegister(ProxyDmlChannelTimeTick)
Z
zwd1208 已提交
588 589
}

590
//RegisterQueryCoord registers QueryCoord metrics
C
Cai Yudong 已提交
591
func RegisterQueryCoord() {
Z
zwd1208 已提交
592 593 594

}

595
//RegisterQueryNode registers QueryNode metrics
Z
zwd1208 已提交
596 597 598 599
func RegisterQueryNode() {

}

600
var (
C
Cai Yudong 已提交
601 602
	//DataCoordDataNodeList records the num of regsitered data nodes
	DataCoordDataNodeList = prometheus.NewGaugeVec(
603 604
		prometheus.GaugeOpts{
			Namespace: milvusNamespace,
C
Cai Yudong 已提交
605
			Subsystem: subSystemDataCoord,
606
			Name:      "list_of_data_node",
D
dragondriver 已提交
607
			Help:      "List of data nodes registered within etcd",
608 609 610 611
		}, []string{"status"},
	)
)

612
//RegisterDataCoord registers DataCoord metrics
C
Cai Yudong 已提交
613
func RegisterDataCoord() {
C
congqixia 已提交
614
	prometheus.MustRegister(DataCoordDataNodeList)
Z
zwd1208 已提交
615 616
}

X
XuanYang-cn 已提交
617
var (
618
	// DataNodeFlushSegmentsCounter counts the num of calls of FlushSegments
X
XuanYang-cn 已提交
619 620 621 622 623 624 625 626
	DataNodeFlushSegmentsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemDataNode,
			Name:      "flush_segments_total",
			Help:      "Counter of flush segments",
		}, []string{"type"})

627
	// DataNodeWatchDmChannelsCounter counts the num of calls of WatchDmChannels
X
XuanYang-cn 已提交
628 629 630 631 632 633 634 635 636
	DataNodeWatchDmChannelsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemDataNode,
			Name:      "watch_dm_channels_total",
			Help:      "Counter of watch dm channel",
		}, []string{"type"})
)

637
//RegisterDataNode registers DataNode metrics
Z
zwd1208 已提交
638
func RegisterDataNode() {
C
congqixia 已提交
639 640
	prometheus.MustRegister(DataNodeFlushSegmentsCounter)
	prometheus.MustRegister(DataNodeWatchDmChannelsCounter)
Z
zwd1208 已提交
641 642
}

643
//RegisterIndexCoord registers IndexCoord metrics
C
Cai Yudong 已提交
644
func RegisterIndexCoord() {
Z
zwd1208 已提交
645 646 647

}

648
//RegisterIndexNode registers IndexNode metrics
Z
zwd1208 已提交
649 650 651 652
func RegisterIndexNode() {

}

653
//RegisterMsgStreamCoord registers MsgStreamCoord metrics
C
Cai Yudong 已提交
654
func RegisterMsgStreamCoord() {
Z
zwd1208 已提交
655 656 657

}

658
//ServeHTTP serves prometheus http service
Z
zwd1208 已提交
659 660 661 662 663 664 665 666
func ServeHTTP() {
	http.Handle("/metrics", promhttp.Handler())
	go func() {
		if err := http.ListenAndServe(":9091", nil); err != nil {
			log.Error("handle metrics failed", zap.Error(err))
		}
	}()
}