metrics.go 22.4 KB
Newer Older
Z
zwd1208 已提交
1 2 3 4 5 6
package metrics

import (
	"net/http"

	"github.com/milvus-io/milvus/internal/log"
C
Cai Yudong 已提交
7
	"github.com/prometheus/client_golang/prometheus"
Z
zwd1208 已提交
8 9 10 11 12
	"github.com/prometheus/client_golang/prometheus/promhttp"

	"go.uber.org/zap"
)

13
const (
C
Cai Yudong 已提交
14 15 16
	milvusNamespace    = "milvus"
	subSystemRootCoord = "rootcoord"
	subSystemDataCoord = "dataCoord"
X
XuanYang-cn 已提交
17
	subSystemDataNode  = "dataNode"
D
dragondriver 已提交
18
	subSystemProxy     = "proxy"
19 20
)

C
Cai Yudong 已提交
21
var (
22
	// RootCoordProxyLister counts the num of registered proxy nodes
23
	RootCoordProxyLister = prometheus.NewGaugeVec(
C
Cai Yudong 已提交
24
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
25 26
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
27
			Name:      "list_of_proxy",
28
			Help:      "List of proxy nodes which have registered with etcd",
C
Cai Yudong 已提交
29 30 31 32 33
		}, []string{"client_id"})

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

34
	// RootCoordCreateCollectionCounter counts the num of calls of CreateCollection
C
Cai Yudong 已提交
35
	RootCoordCreateCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
36
		prometheus.CounterOpts{
C
Cai Yudong 已提交
37 38
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
39 40 41 42
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"client_id", "type"})

43
	// RootCoordDropCollectionCounter counts the num of calls of DropCollection
C
Cai Yudong 已提交
44
	RootCoordDropCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
45
		prometheus.CounterOpts{
C
Cai Yudong 已提交
46 47
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
48 49 50 51
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"client_id", "type"})

52
	// RootCoordHasCollectionCounter counts the num of calls of HasCollection
C
Cai Yudong 已提交
53
	RootCoordHasCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
54
		prometheus.CounterOpts{
C
Cai Yudong 已提交
55 56
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
57 58 59 60
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"client_id", "type"})

61
	// RootCoordDescribeCollectionCounter counts the num of calls of DescribeCollection
C
Cai Yudong 已提交
62
	RootCoordDescribeCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
63
		prometheus.CounterOpts{
C
Cai Yudong 已提交
64 65
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
66 67 68 69
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"client_id", "type"})

70
	// RootCoordShowCollectionsCounter counts the num of calls of ShowCollections
C
Cai Yudong 已提交
71
	RootCoordShowCollectionsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
72
		prometheus.CounterOpts{
C
Cai Yudong 已提交
73 74
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
75 76 77 78
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"client_id", "type"})

79
	// RootCoordCreatePartitionCounter counts the num of calls of CreatePartition
C
Cai Yudong 已提交
80
	RootCoordCreatePartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
81
		prometheus.CounterOpts{
C
Cai Yudong 已提交
82 83
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
84 85 86 87
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"client_id", "type"})

88
	// RootCoordDropPartitionCounter counts the num of calls of DropPartition
C
Cai Yudong 已提交
89
	RootCoordDropPartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
90
		prometheus.CounterOpts{
C
Cai Yudong 已提交
91 92
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
93 94 95 96
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"client_id", "type"})

97
	// RootCoordHasPartitionCounter counts the num of calls of HasPartition
C
Cai Yudong 已提交
98
	RootCoordHasPartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
99
		prometheus.CounterOpts{
C
Cai Yudong 已提交
100 101
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
102 103 104 105
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"client_id", "type"})

106
	// RootCoordShowPartitionsCounter counts the num of calls of ShowPartitions
C
Cai Yudong 已提交
107
	RootCoordShowPartitionsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
108
		prometheus.CounterOpts{
C
Cai Yudong 已提交
109 110
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
111 112 113 114
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"client_id", "type"})

115
	// RootCoordCreateIndexCounter counts the num of calls of CreateIndex
C
Cai Yudong 已提交
116
	RootCoordCreateIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
117
		prometheus.CounterOpts{
C
Cai Yudong 已提交
118 119
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
120 121 122 123
			Name:      "create_index_total",
			Help:      "Counter of create index",
		}, []string{"client_id", "type"})

124
	// RootCoordDropIndexCounter counts the num of calls of DropIndex
C
Cai Yudong 已提交
125
	RootCoordDropIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
126
		prometheus.CounterOpts{
C
Cai Yudong 已提交
127 128
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
129 130 131 132
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"client_id", "type"})

133
	// RootCoordDescribeIndexCounter counts the num of calls of DescribeIndex
C
Cai Yudong 已提交
134
	RootCoordDescribeIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
135
		prometheus.CounterOpts{
C
Cai Yudong 已提交
136 137
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
138 139 140 141
			Name:      "describe_index_total",
			Help:      "Counter of describe index",
		}, []string{"client_id", "type"})

142
	// RootCoordDescribeSegmentCounter counts the num of calls of DescribeSegment
C
Cai Yudong 已提交
143
	RootCoordDescribeSegmentCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
144
		prometheus.CounterOpts{
C
Cai Yudong 已提交
145 146
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
147 148 149 150
			Name:      "describe_segment_total",
			Help:      "Counter of describe segment",
		}, []string{"client_id", "type"})

151
	// RootCoordShowSegmentsCounter counts the num of calls of ShowSegments
C
Cai Yudong 已提交
152
	RootCoordShowSegmentsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
153
		prometheus.CounterOpts{
C
Cai Yudong 已提交
154 155
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
156 157 158 159 160 161 162
			Name:      "show_segments_total",
			Help:      "Counter of show segments",
		}, []string{"client_id", "type"})

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

163
	// RootCoordInsertChannelTimeTick counts the time tick num of insert channel in 24H
C
Cai Yudong 已提交
164
	RootCoordInsertChannelTimeTick = prometheus.NewGaugeVec(
C
Cai Yudong 已提交
165
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
166 167
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
168 169 170 171
			Name:      "insert_channel_time_tick",
			Help:      "Time tick of insert Channel in 24H",
		}, []string{"vchannel"})

172
	// RootCoordDDChannelTimeTick counts the time tick num of dd channel in 24H
C
Cai Yudong 已提交
173
	RootCoordDDChannelTimeTick = prometheus.NewGauge(
C
Cai Yudong 已提交
174
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
175 176
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
177 178 179 180 181
			Name:      "dd_channel_time_tick",
			Help:      "Time tick of dd Channel in 24H",
		})
)

182
//RegisterRootCoord registers RootCoord metrics
C
Cai Yudong 已提交
183
func RegisterRootCoord() {
184
	prometheus.MustRegister(RootCoordProxyLister)
C
Cai Yudong 已提交
185 186

	// for grpc
C
Cai Yudong 已提交
187 188 189 190 191 192 193 194 195 196 197 198 199 200
	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 已提交
201 202

	// for time tick
C
Cai Yudong 已提交
203 204
	prometheus.MustRegister(RootCoordInsertChannelTimeTick)
	prometheus.MustRegister(RootCoordDDChannelTimeTick)
Z
zwd1208 已提交
205 206 207
	//prometheus.MustRegister(PanicCounter)
}

D
dragondriver 已提交
208
var (
209
	// ProxyCreateCollectionCounter counts the num of calls of CreateCollection
D
dragondriver 已提交
210 211 212 213 214 215 216 217
	ProxyCreateCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"status"})

218
	// ProxyDropCollectionCounter counts the num of calls of DropCollection
D
dragondriver 已提交
219 220 221 222 223 224 225 226
	ProxyDropCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"status"})

227
	// ProxyHasCollectionCounter counts the num of calls of HasCollection
D
dragondriver 已提交
228 229 230 231 232 233 234 235
	ProxyHasCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"status"})

236
	// ProxyLoadCollectionCounter counts the num of calls of LoadCollection
D
dragondriver 已提交
237 238 239 240 241 242 243 244
	ProxyLoadCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "load_collection_total",
			Help:      "Counter of load collection",
		}, []string{"status"})

245
	// ProxyReleaseCollectionCounter counts the num of calls of ReleaseCollection
D
dragondriver 已提交
246 247 248 249 250 251 252 253
	ProxyReleaseCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_collection_total",
			Help:      "Counter of release collection",
		}, []string{"status"})

254
	// ProxyDescribeCollectionCounter counts the num of calls of DescribeCollection
D
dragondriver 已提交
255 256 257 258 259 260 261 262
	ProxyDescribeCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"status"})

263
	// ProxyGetCollectionStatisticsCounter counts the num of calls of GetCollectionStatistics
D
dragondriver 已提交
264 265 266 267 268 269 270 271
	ProxyGetCollectionStatisticsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_collection_statistics_total",
			Help:      "Counter of get collection statistics",
		}, []string{"status"})

272
	// ProxyShowCollectionsCounter counts the num of calls of ShowCollections
D
dragondriver 已提交
273 274 275 276 277 278 279 280
	ProxyShowCollectionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"status"})

281
	// ProxyCreatePartitionCounter counts the num of calls of CreatePartition
D
dragondriver 已提交
282 283 284 285 286 287 288 289
	ProxyCreatePartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"status"})

290
	// ProxyDropPartitionCounter counts the num of calls of DropPartition
D
dragondriver 已提交
291 292 293 294 295 296 297 298
	ProxyDropPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"status"})

299
	// ProxyHasPartitionCounter counts the num of calls of HasPartition
D
dragondriver 已提交
300 301 302 303 304 305 306 307
	ProxyHasPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"status"})

308
	// ProxyLoadPartitionsCounter counts the num of calls of LoadPartitions
D
dragondriver 已提交
309 310 311 312 313 314 315 316
	ProxyLoadPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "load_partitions_total",
			Help:      "Counter of load partitions",
		}, []string{"status"})

317
	// ProxyReleasePartitionsCounter counts the num of calls of ReleasePartitions
D
dragondriver 已提交
318 319 320 321 322 323 324 325
	ProxyReleasePartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_partitions_total",
			Help:      "Counter of release partitions",
		}, []string{"status"})

326
	// ProxyGetPartitionStatisticsCounter counts the num of calls of GetPartitionStatistics
D
dragondriver 已提交
327 328 329 330 331 332 333 334
	ProxyGetPartitionStatisticsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_partition_statistics_total",
			Help:      "Counter of get partition statistics",
		}, []string{"status"})

335
	// ProxyShowPartitionsCounter counts the num of calls of ShowPartitions
D
dragondriver 已提交
336 337 338 339 340 341 342 343
	ProxyShowPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"status"})

344
	// ProxyCreateIndexCounter counts the num of calls of CreateIndex
D
dragondriver 已提交
345 346 347 348 349 350 351 352
	ProxyCreateIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_index_counter",
			Help:      "Counter of create index",
		}, []string{"status"})

353
	// ProxyDescribeIndexCounter counts the num of calls of DescribeIndex
D
dragondriver 已提交
354 355 356 357 358 359 360 361
	ProxyDescribeIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "describe_index_counter",
			Help:      "Counter of describe index",
		}, []string{"status"})

362
	// ProxyGetIndexStateCounter counts the num of calls of GetIndexState
D
dragondriver 已提交
363 364 365 366 367 368 369 370
	ProxyGetIndexStateCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_index_state_counter",
			Help:      "Counter of get index state",
		}, []string{"status"})

371
	// ProxyGetIndexBuildProgressCounter counts the num of calls of GetIndexBuildProgress
D
dragondriver 已提交
372 373 374 375 376 377 378 379
	ProxyGetIndexBuildProgressCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_index_build_progress_total",
			Help:      "Counter of get index build progress",
		}, []string{"status"})

380
	// ProxyDropIndexCounter counts the num of calls of DropIndex
D
dragondriver 已提交
381 382 383 384 385 386 387 388
	ProxyDropIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"status"})

389
	// ProxyInsertCounter counts the num of calls of Insert
D
dragondriver 已提交
390 391 392 393 394 395 396 397
	ProxyInsertCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "insert_total",
			Help:      "Counter of insert",
		}, []string{"status"})

398
	// ProxySearchCounter counts the num of calls of Search
D
dragondriver 已提交
399 400 401 402 403 404 405 406
	ProxySearchCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "search_total",
			Help:      "Counter of search",
		}, []string{"status"})

407
	// ProxyRetrieveCounter counts the num of calls of Retrieve
D
dragondriver 已提交
408 409 410 411 412 413 414 415
	ProxyRetrieveCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "retrieve_total",
			Help:      "Counter of retrieve",
		}, []string{"status"})

416
	// ProxyFlushCounter counts the num of calls of Flush
D
dragondriver 已提交
417 418 419 420 421 422 423 424
	ProxyFlushCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "flush_total",
			Help:      "Counter of flush",
		}, []string{"status"})

425
	// ProxyQueryCounter counts the num of calls of Query
D
dragondriver 已提交
426 427 428 429 430 431 432 433
	ProxyQueryCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "query_total",
			Help:      "Counter of query",
		}, []string{"status"})

434
	// ProxyGetPersistentSegmentInfoCounter counts the num of calls of GetPersistentSegmentInfo
D
dragondriver 已提交
435 436 437 438 439 440 441 442
	ProxyGetPersistentSegmentInfoCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_persistent_segment_info_total",
			Help:      "Counter of get persistent segment info",
		}, []string{"status"})

443
	// ProxyGetQuerySegmentInfoCounter counts the num of calls of GetQuerySegmentInfo
D
dragondriver 已提交
444 445 446 447 448 449 450 451
	ProxyGetQuerySegmentInfoCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_query_segment_info_total",
			Help:      "Counter of get query segment info",
		}, []string{"status"})

452
	// ProxyDummyCounter counts the num of calls of Dummy
D
dragondriver 已提交
453 454 455 456 457 458 459 460
	ProxyDummyCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "dummy_total",
			Help:      "Counter of dummy",
		}, []string{"status"})

461
	// ProxyRegisterLinkCounter counts the num of calls of RegisterLink
D
dragondriver 已提交
462 463 464 465 466 467 468 469
	ProxyRegisterLinkCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "register_link_total",
			Help:      "Counter of register link",
		}, []string{"status"})

470
	// ProxyGetComponentStatesCounter counts the num of calls of GetComponentStates
D
dragondriver 已提交
471 472 473 474 475 476 477 478
	ProxyGetComponentStatesCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_component_states_total",
			Help:      "Counter of get component states",
		}, []string{"status"})

479
	// ProxyGetStatisticsChannelCounter counts the num of calls of GetStatisticsChannel
D
dragondriver 已提交
480 481 482 483 484 485 486 487
	ProxyGetStatisticsChannelCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_statistics_channel_total",
			Help:      "Counter of get statistics channel",
		}, []string{"status"})

488
	// ProxyInvalidateCollectionMetaCacheCounter counts the num of calls of InvalidateCollectionMetaCache
D
dragondriver 已提交
489 490 491 492 493 494 495 496
	ProxyInvalidateCollectionMetaCacheCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "invalidate_collection_meta_cache_total",
			Help:      "Counter of invalidate collection meta cache",
		}, []string{"status"})

497
	// ProxyGetDdChannelCounter counts the num of calls of GetDdChannel
D
dragondriver 已提交
498 499 500 501 502 503 504 505
	ProxyGetDdChannelCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_dd_channel_total",
			Help:      "Counter of get dd channel",
		}, []string{"status"})

506
	// ProxyReleaseDQLMessageStreamCounter counts the num of calls of ReleaseDQLMessageStream
D
dragondriver 已提交
507 508 509 510 511 512 513
	ProxyReleaseDQLMessageStreamCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_dql_message_stream_total",
			Help:      "Counter of release dql message stream",
		}, []string{"status"})
514

515
	// ProxyDmlChannelTimeTick counts the time tick value of dml channels
516 517 518 519 520 521 522
	ProxyDmlChannelTimeTick = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "dml_channels_time_tick",
			Help:      "Time tick of dml channels",
		}, []string{"pchan"})
D
dragondriver 已提交
523
)
Z
zwd1208 已提交
524

525
//RegisterProxy registers Proxy metrics
D
dragondriver 已提交
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 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
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)
570 571

	prometheus.MustRegister(ProxyDmlChannelTimeTick)
Z
zwd1208 已提交
572 573
}

C
Cai Yudong 已提交
574 575
//RegisterQueryCoord register QueryCoord metrics
func RegisterQueryCoord() {
Z
zwd1208 已提交
576 577 578 579 580 581 582 583

}

//RegisterQueryNode register QueryNode metrics
func RegisterQueryNode() {

}

584
var (
C
Cai Yudong 已提交
585 586
	//DataCoordDataNodeList records the num of regsitered data nodes
	DataCoordDataNodeList = prometheus.NewGaugeVec(
587 588
		prometheus.GaugeOpts{
			Namespace: milvusNamespace,
C
Cai Yudong 已提交
589
			Subsystem: subSystemDataCoord,
590
			Name:      "list_of_data_node",
D
dragondriver 已提交
591
			Help:      "List of data nodes registered within etcd",
592 593 594 595
		}, []string{"status"},
	)
)

596
//RegisterDataCoord register DataCoord metrics
C
Cai Yudong 已提交
597
func RegisterDataCoord() {
C
congqixia 已提交
598
	prometheus.MustRegister(DataCoordDataNodeList)
Z
zwd1208 已提交
599 600
}

X
XuanYang-cn 已提交
601 602 603 604 605 606 607 608 609 610
var (
	// DataNodeFlushSegmentsCounter used to count the num of calls of FlushSegments
	DataNodeFlushSegmentsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemDataNode,
			Name:      "flush_segments_total",
			Help:      "Counter of flush segments",
		}, []string{"type"})

611
	// DataNodeWatchDmChannelsCounter used to count the num of calls of WatchDmChannels
X
XuanYang-cn 已提交
612 613 614 615 616 617 618 619 620
	DataNodeWatchDmChannelsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemDataNode,
			Name:      "watch_dm_channels_total",
			Help:      "Counter of watch dm channel",
		}, []string{"type"})
)

Z
zwd1208 已提交
621 622
//RegisterDataNode register DataNode metrics
func RegisterDataNode() {
C
congqixia 已提交
623 624
	prometheus.MustRegister(DataNodeFlushSegmentsCounter)
	prometheus.MustRegister(DataNodeWatchDmChannelsCounter)
Z
zwd1208 已提交
625 626
}

C
Cai Yudong 已提交
627 628
//RegisterIndexCoord register IndexCoord metrics
func RegisterIndexCoord() {
Z
zwd1208 已提交
629 630 631 632 633 634 635 636

}

//RegisterIndexNode register IndexNode metrics
func RegisterIndexNode() {

}

C
Cai Yudong 已提交
637 638
//RegisterMsgStreamCoord register MsgStreamCoord metrics
func RegisterMsgStreamCoord() {
Z
zwd1208 已提交
639 640 641 642 643 644 645 646 647 648 649 650

}

//ServeHTTP serve prometheus http service
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))
		}
	}()
}