metrics.go 8.1 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 13 14 15 16 17 18 19 20 21 22 23 24
	"github.com/prometheus/client_golang/prometheus/promhttp"

	"go.uber.org/zap"
)

/*
var (
	PanicCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "server",
			Name:      "panic_total",
			Help:      "Counter of panic.",
		}, []string{"type"})
)
*/

C
Cai Yudong 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
var (
	// MasterProxyNodeLister used to count the num of registered proxy nodes
	MasterProxyNodeLister = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "list_of_proxy_node",
			Help:      "List of proxy nodes which has register with etcd",
		}, []string{"client_id"})

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

	// MasterCreateCollectionCounter used to count the num of calls of CreateCollection
	MasterCreateCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "create_collection_total",
			Help:      "Counter of create collection",
		}, []string{"client_id", "type"})

	// MasterDropCollectionCounter used to count the num of calls of DropCollection
	MasterDropCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "drop_collection_total",
			Help:      "Counter of drop collection",
		}, []string{"client_id", "type"})

	// MasterHasCollectionCounter used to count the num of calls of HasCollection
	MasterHasCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "has_collection_total",
			Help:      "Counter of has collection",
		}, []string{"client_id", "type"})

	// MasterDescribeCollectionCounter used to count the num of calls of DescribeCollection
	MasterDescribeCollectionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "describe_collection_total",
			Help:      "Counter of describe collection",
		}, []string{"client_id", "type"})

	// MasterShowCollectionsCounter used to count the num of calls of ShowCollections
	MasterShowCollectionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "show_collections_total",
			Help:      "Counter of show collections",
		}, []string{"client_id", "type"})

	// MasterCreatePartitionCounter used to count the num of calls of CreatePartition
	MasterCreatePartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "create_partition_total",
			Help:      "Counter of create partition",
		}, []string{"client_id", "type"})

	// MasterDropPartitionCounter used to count the num of calls of DropPartition
	MasterDropPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "drop_partition_total",
			Help:      "Counter of drop partition",
		}, []string{"client_id", "type"})

	// MasterHasPartitionCounter used to count the num of calls of HasPartition
	MasterHasPartitionCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "has_partition_total",
			Help:      "Counter of has partition",
		}, []string{"client_id", "type"})

	// MasterShowPartitionsCounter used to count the num of calls of ShowPartitions
	MasterShowPartitionsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "show_partitions_total",
			Help:      "Counter of show partitions",
		}, []string{"client_id", "type"})

	// MasterCreateIndexCounter used to count the num of calls of CreateIndex
	MasterCreateIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "create_index_total",
			Help:      "Counter of create index",
		}, []string{"client_id", "type"})

	// MasterDropIndexCounter used to count the num of calls of DropIndex
	MasterDropIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "drop_index_total",
			Help:      "Counter of drop index",
		}, []string{"client_id", "type"})

	// MasterDescribeIndexCounter used to count the num of calls of DescribeIndex
	MasterDescribeIndexCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "describe_index_total",
			Help:      "Counter of describe index",
		}, []string{"client_id", "type"})

	// MasterDescribeSegmentCounter used to count the num of calls of DescribeSegment
	MasterDescribeSegmentCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "describe_segment_total",
			Help:      "Counter of describe segment",
		}, []string{"client_id", "type"})

	// MasterShowSegmentsCounter used to count the num of calls of ShowSegments
	MasterShowSegmentsCounter = prometheus.NewCounterVec(
		prometheus.CounterOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "show_segments_total",
			Help:      "Counter of show segments",
		}, []string{"client_id", "type"})

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

	// MasterInsertChannelTimeTick used to count the time tick num of insert channel in 24H
	MasterInsertChannelTimeTick = prometheus.NewGaugeVec(
		prometheus.GaugeOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "insert_channel_time_tick",
			Help:      "Time tick of insert Channel in 24H",
		}, []string{"vchannel"})

	// MasterDDChannelTimeTick used to count the time tick num of dd channel in 24H
	MasterDDChannelTimeTick = prometheus.NewGauge(
		prometheus.GaugeOpts{
			Namespace: "milvus",
			Subsystem: "master",
			Name:      "dd_channel_time_tick",
			Help:      "Time tick of dd Channel in 24H",
		})
)

Z
zwd1208 已提交
186 187
//RegisterMaster register Master metrics
func RegisterMaster() {
C
Cai Yudong 已提交
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
	prometheus.MustRegister(MasterProxyNodeLister)

	// for grpc
	prometheus.MustRegister(MasterCreateCollectionCounter)
	prometheus.MustRegister(MasterDropCollectionCounter)
	prometheus.MustRegister(MasterHasCollectionCounter)
	prometheus.MustRegister(MasterDescribeCollectionCounter)
	prometheus.MustRegister(MasterShowCollectionsCounter)
	prometheus.MustRegister(MasterCreatePartitionCounter)
	prometheus.MustRegister(MasterDropPartitionCounter)
	prometheus.MustRegister(MasterHasPartitionCounter)
	prometheus.MustRegister(MasterShowPartitionsCounter)
	prometheus.MustRegister(MasterCreateIndexCounter)
	prometheus.MustRegister(MasterDropIndexCounter)
	prometheus.MustRegister(MasterDescribeIndexCounter)
	prometheus.MustRegister(MasterDescribeSegmentCounter)
	prometheus.MustRegister(MasterShowSegmentsCounter)

	// for time tick
	prometheus.MustRegister(MasterInsertChannelTimeTick)
	prometheus.MustRegister(MasterDDChannelTimeTick)
Z
zwd1208 已提交
209 210 211 212 213 214 215 216 217 218 219 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
	//prometheus.MustRegister(PanicCounter)
}

//RegisterProxyService register ProxyService metrics
func RegisterProxyService() {

}

//RegisterProxyNode register ProxyNode metrics
func RegisterProxyNode() {

}

//RegisterQueryService register QueryService metrics
func RegisterQueryService() {

}

//RegisterQueryNode register QueryNode metrics
func RegisterQueryNode() {

}

//RegisterDataService register DataService metrics
func RegisterDataService() {

}

//RegisterDataNode register DataNode metrics
func RegisterDataNode() {

}

//RegisterIndexService register IndexService metrics
func RegisterIndexService() {

}

//RegisterIndexNode register IndexNode metrics
func RegisterIndexNode() {

}

//RegisterMsgStreamService register MsgStreamService metrics
func RegisterMsgStreamService() {

}

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