Add GRPC and gin server monitoring logic2

pull/1337/head
lin.huang 2 years ago
parent 4001fb17dd
commit e6adaa7cda

@ -383,7 +383,7 @@ callback:
# The number of Prometheus ports per service needs to correspond to rpcPort
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
prometheus:
enable: false
enable: true
userPrometheusPort: [ 20110 ]
friendPrometheusPort: [ 20120 ]
messagePrometheusPort: [ 20130 ]

@ -100,7 +100,7 @@ func Start(
go func() {
if config.Config.Prometheus.Enable && prometheusPort != 0 {
// Create a HTTP server for prometheus.
httpServer := &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", 90)}
httpServer := &http.Server{Handler: promhttp.HandlerFor(reg, promhttp.HandlerOpts{}), Addr: fmt.Sprintf("0.0.0.0:%d", getPromPort(rpcRegisterName))}
if err := httpServer.ListenAndServe(); err != nil {
log.Fatal("Unable to start a http server.")
}
@ -109,3 +109,28 @@ func Start(
return utils.Wrap1(srv.Serve(listener))
}
func getPromPort(name string) int {
switch name {
case "MessageGateway":
return config.Config.Prometheus.MessageGatewayPrometheusPort[0]
case "User":
return config.Config.Prometheus.UserPrometheusPort[0]
case "Msg":
return config.Config.Prometheus.MessagePrometheusPort[0]
case "Conversation":
return config.Config.Prometheus.ConversationPrometheusPort[0]
case "Friend":
return config.Config.Prometheus.FriendPrometheusPort[0]
case "Push":
return config.Config.Prometheus.PushPrometheusPort[0]
case "Group":
return config.Config.Prometheus.GroupPrometheusPort[0]
case "Auth":
return config.Config.Prometheus.AuthPrometheusPort[0]
case "Third":
return config.Config.Prometheus.ThirdPrometheusPort[0]
default:
fmt.Println("name not have correct prometheus port!!!")
return 9090
}
}

Loading…
Cancel
Save