metrics.go 22.6 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
)

Z
zwd1208 已提交
21 22 23 24 25 26 27 28 29 30 31 32
/*
var (
	PanicCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "server",
			Name:      "panic_total",
			Help:      "Counter of panic.",
		}, []string{"type"})
)
*/

C
Cai Yudong 已提交
33
var (
34 35
	// RootCoordProxyLister used to count the num of registered proxy nodes
	RootCoordProxyLister = prometheus.NewGaugeVec(
C
Cai Yudong 已提交
36
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
37 38
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
39
			Name:      "list_of_proxy",
C
Cai Yudong 已提交
40 41 42 43 44 45
			Help:      "List of proxy nodes which has register with etcd",
		}, []string{"client_id"})

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

C
Cai Yudong 已提交
46 47
	// RootCoordCreateCollectionCounter used to count the num of calls of CreateCollection
	RootCoordCreateCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
48
		prometheus.CounterOpts{
C
Cai Yudong 已提交
49 50
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
51 52 53 54
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
55 56
	// RootCoordDropCollectionCounter used to count the num of calls of DropCollection
	RootCoordDropCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
57
		prometheus.CounterOpts{
C
Cai Yudong 已提交
58 59
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
60 61 62 63
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
64 65
	// RootCoordHasCollectionCounter used to count the num of calls of HasCollection
	RootCoordHasCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
66
		prometheus.CounterOpts{
C
Cai Yudong 已提交
67 68
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
69 70 71 72
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
73 74
	// RootCoordDescribeCollectionCounter used to count the num of calls of DescribeCollection
	RootCoordDescribeCollectionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
75
		prometheus.CounterOpts{
C
Cai Yudong 已提交
76 77
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
78 79 80 81
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
82 83
	// RootCoordShowCollectionsCounter used to count the num of calls of ShowCollections
	RootCoordShowCollectionsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
84
		prometheus.CounterOpts{
C
Cai Yudong 已提交
85 86
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
87 88 89 90
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
91 92
	// RootCoordCreatePartitionCounter used to count the num of calls of CreatePartition
	RootCoordCreatePartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
93
		prometheus.CounterOpts{
C
Cai Yudong 已提交
94 95
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
96 97 98 99
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
100 101
	// RootCoordDropPartitionCounter used to count the num of calls of DropPartition
	RootCoordDropPartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
102
		prometheus.CounterOpts{
C
Cai Yudong 已提交
103 104
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
105 106 107 108
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
109 110
	// RootCoordHasPartitionCounter used to count the num of calls of HasPartition
	RootCoordHasPartitionCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
111
		prometheus.CounterOpts{
C
Cai Yudong 已提交
112 113
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
114 115 116 117
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
118 119
	// RootCoordShowPartitionsCounter used to count the num of calls of ShowPartitions
	RootCoordShowPartitionsCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
120
		prometheus.CounterOpts{
C
Cai Yudong 已提交
121 122
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
123 124 125 126
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
127 128
	// RootCoordCreateIndexCounter used to count the num of calls of CreateIndex
	RootCoordCreateIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
129
		prometheus.CounterOpts{
C
Cai Yudong 已提交
130 131
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
132 133 134 135
			Name:      "create_index_total",
			Help:      "Counter of create index",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
136 137
	// RootCoordDropIndexCounter used to count the num of calls of DropIndex
	RootCoordDropIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
138
		prometheus.CounterOpts{
C
Cai Yudong 已提交
139 140
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
141 142 143 144
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
145 146
	// RootCoordDescribeIndexCounter used to count the num of calls of DescribeIndex
	RootCoordDescribeIndexCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
147
		prometheus.CounterOpts{
C
Cai Yudong 已提交
148 149
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
150 151 152 153
			Name:      "describe_index_total",
			Help:      "Counter of describe index",
		}, []string{"client_id", "type"})

C
Cai Yudong 已提交
154 155
	// RootCoordDescribeSegmentCounter used to count the num of calls of DescribeSegment
	RootCoordDescribeSegmentCounter = prometheus.NewCounterVec(
C
Cai Yudong 已提交
156
		prometheus.CounterOpts{
C
Cai Yudong 已提交
157 158
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
159 160 161 162
			Name:      "describe_segment_total",
			Help:      "Counter of describe segment",
		}, []string{"client_id", "type"})

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

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

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

C
Cai Yudong 已提交
184 185
	// RootCoordDDChannelTimeTick used to count the time tick num of dd channel in 24H
	RootCoordDDChannelTimeTick = prometheus.NewGauge(
C
Cai Yudong 已提交
186
		prometheus.GaugeOpts{
C
Cai Yudong 已提交
187 188
			Namespace: milvusNamespace,
			Subsystem: subSystemRootCoord,
C
Cai Yudong 已提交
189 190 191 192 193
			Name:      "dd_channel_time_tick",
			Help:      "Time tick of dd Channel in 24H",
		})
)

C
Cai Yudong 已提交
194 195
//RegisterRootCoord register RootCoord metrics
func RegisterRootCoord() {
196
	prometheus.MustRegister(RootCoordProxyLister)
C
Cai Yudong 已提交
197 198

	// for grpc
C
Cai Yudong 已提交
199 200 201 202 203 204 205 206 207 208 209 210 211 212
	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 已提交
213 214

	// for time tick
C
Cai Yudong 已提交
215 216
	prometheus.MustRegister(RootCoordInsertChannelTimeTick)
	prometheus.MustRegister(RootCoordDDChannelTimeTick)
Z
zwd1208 已提交
217 218 219
	//prometheus.MustRegister(PanicCounter)
}

D
dragondriver 已提交
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
var (
	// ProxyCreateCollectionCounter used to count the num of calls of CreateCollection
	ProxyCreateCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"status"})

	// ProxyDropCollectionCounter used to count the num of calls of DropCollection
	ProxyDropCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"status"})

	// ProxyHasCollectionCounter used to count the num of calls of HasCollection
	ProxyHasCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"status"})

	// ProxyLoadCollectionCounter used to count the num of calls of LoadCollection
	ProxyLoadCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "load_collection_total",
			Help:      "Counter of load collection",
		}, []string{"status"})

	// ProxyReleaseCollectionCounter used to count the num of calls of ReleaseCollection
	ProxyReleaseCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_collection_total",
			Help:      "Counter of release collection",
		}, []string{"status"})

	// ProxyDescribeCollectionCounter used to count the num of calls of DescribeCollection
	ProxyDescribeCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"status"})

	// ProxyGetCollectionStatisticsCounter used to count the num of calls of GetCollectionStatistics
	ProxyGetCollectionStatisticsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_collection_statistics_total",
			Help:      "Counter of get collection statistics",
		}, []string{"status"})

	// ProxyShowCollectionsCounter used to count the num of calls of ShowCollections
	ProxyShowCollectionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"status"})

	// ProxyCreatePartitionCounter used to count the num of calls of CreatePartition
	ProxyCreatePartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"status"})

	// ProxyDropPartitionCounter used to count the num of calls of DropPartition
	ProxyDropPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"status"})

	// ProxyHasPartitionCounter used to count the num of calls of HasPartition
	ProxyHasPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"status"})

	// ProxyLoadPartitionsCounter used to count the num of calls of LoadPartitions
	ProxyLoadPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "load_partitions_total",
			Help:      "Counter of load partitions",
		}, []string{"status"})

	// ProxyReleasePartitionsCounter used to count the num of calls of ReleasePartitions
	ProxyReleasePartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_partitions_total",
			Help:      "Counter of release partitions",
		}, []string{"status"})

	// ProxyGetPartitionStatisticsCounter used to count the num of calls of GetPartitionStatistics
	ProxyGetPartitionStatisticsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_partition_statistics_total",
			Help:      "Counter of get partition statistics",
		}, []string{"status"})

	// ProxyShowPartitionsCounter used to count the num of calls of ShowPartitions
	ProxyShowPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"status"})

	// ProxyCreateIndexCounter used to count the num of calls of CreateIndex
	ProxyCreateIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "create_index_counter",
			Help:      "Counter of create index",
		}, []string{"status"})

	// ProxyDescribeIndexCounter used to count the num of calls of DescribeIndex
	ProxyDescribeIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "describe_index_counter",
			Help:      "Counter of describe index",
		}, []string{"status"})

	// ProxyGetIndexStateCounter used to count the num of calls of GetIndexState
	ProxyGetIndexStateCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_index_state_counter",
			Help:      "Counter of get index state",
		}, []string{"status"})

	// ProxyGetIndexBuildProgressCounter used to count the num of calls of GetIndexBuildProgress
	ProxyGetIndexBuildProgressCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_index_build_progress_total",
			Help:      "Counter of get index build progress",
		}, []string{"status"})

	// ProxyDropIndexCounter used to count the num of calls of DropIndex
	ProxyDropIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"status"})

	// ProxyInsertCounter used to count the num of calls of Insert
	ProxyInsertCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "insert_total",
			Help:      "Counter of insert",
		}, []string{"status"})

	// ProxySearchCounter used to count the num of calls of Search
	ProxySearchCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "search_total",
			Help:      "Counter of search",
		}, []string{"status"})

	// ProxyRetrieveCounter used to count the num of calls of Retrieve
	ProxyRetrieveCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "retrieve_total",
			Help:      "Counter of retrieve",
		}, []string{"status"})

	// ProxyFlushCounter used to count the num of calls of Flush
	ProxyFlushCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "flush_total",
			Help:      "Counter of flush",
		}, []string{"status"})

	// ProxyQueryCounter used to count the num of calls of Query
	ProxyQueryCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "query_total",
			Help:      "Counter of query",
		}, []string{"status"})

	// ProxyGetPersistentSegmentInfoCounter used to count the num of calls of GetPersistentSegmentInfo
	ProxyGetPersistentSegmentInfoCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_persistent_segment_info_total",
			Help:      "Counter of get persistent segment info",
		}, []string{"status"})

	// ProxyGetQuerySegmentInfoCounter used to count the num of calls of GetQuerySegmentInfo
	ProxyGetQuerySegmentInfoCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_query_segment_info_total",
			Help:      "Counter of get query segment info",
		}, []string{"status"})

	// ProxyDummyCounter used to count the num of calls of Dummy
	ProxyDummyCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "dummy_total",
			Help:      "Counter of dummy",
		}, []string{"status"})

	// ProxyRegisterLinkCounter used to count the num of calls of RegisterLink
	ProxyRegisterLinkCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "register_link_total",
			Help:      "Counter of register link",
		}, []string{"status"})

	// ProxyGetComponentStatesCounter used to count the num of calls of GetComponentStates
	ProxyGetComponentStatesCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_component_states_total",
			Help:      "Counter of get component states",
		}, []string{"status"})

	// ProxyGetStatisticsChannelCounter used to count the num of calls of GetStatisticsChannel
	ProxyGetStatisticsChannelCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_statistics_channel_total",
			Help:      "Counter of get statistics channel",
		}, []string{"status"})

	// ProxyInvalidateCollectionMetaCacheCounter used to count the num of calls of InvalidateCollectionMetaCache
	ProxyInvalidateCollectionMetaCacheCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "invalidate_collection_meta_cache_total",
			Help:      "Counter of invalidate collection meta cache",
		}, []string{"status"})

	// ProxyGetDdChannelCounter used to count the num of calls of GetDdChannel
	ProxyGetDdChannelCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "get_dd_channel_total",
			Help:      "Counter of get dd channel",
		}, []string{"status"})

	// ProxyReleaseDQLMessageStreamCounter used to count the num of calls of ReleaseDQLMessageStream
	ProxyReleaseDQLMessageStreamCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemProxy,
			Name:      "release_dql_message_stream_total",
			Help:      "Counter of release dql message stream",
		}, []string{"status"})
)
Z
zwd1208 已提交
527

528
//RegisterProxy register Proxy metrics
D
dragondriver 已提交
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 570 571 572
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)
Z
zwd1208 已提交
573 574
}

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

}

//RegisterQueryNode register QueryNode metrics
func RegisterQueryNode() {

}

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

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

X
XuanYang-cn 已提交
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621
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"})

	// DataNodeWatchDmChannelCounter used to count the num of calls of WatchDmChannels
	DataNodeWatchDmChannelsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: milvusNamespace,
			Subsystem: subSystemDataNode,
			Name:      "watch_dm_channels_total",
			Help:      "Counter of watch dm channel",
		}, []string{"type"})
)

Z
zwd1208 已提交
622 623
//RegisterDataNode register DataNode metrics
func RegisterDataNode() {
X
XuanYang-cn 已提交
624 625
	prometheus.Register(DataNodeFlushSegmentsCounter)
	prometheus.Register(DataNodeWatchDmChannelsCounter)
Z
zwd1208 已提交
626 627
}

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

}

//RegisterIndexNode register IndexNode metrics
func RegisterIndexNode() {

}

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

}

//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))
		}
	}()
}