mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-09 06:02:54 +08:00
Add GRPC and gin server monitoring logic2
This commit is contained in:
parent
4001fb17dd
commit
e6adaa7cda
@ -383,7 +383,7 @@ callback:
|
|||||||
# The number of Prometheus ports per service needs to correspond to rpcPort
|
# 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
|
# The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh
|
||||||
prometheus:
|
prometheus:
|
||||||
enable: false
|
enable: true
|
||||||
userPrometheusPort: [ 20110 ]
|
userPrometheusPort: [ 20110 ]
|
||||||
friendPrometheusPort: [ 20120 ]
|
friendPrometheusPort: [ 20120 ]
|
||||||
messagePrometheusPort: [ 20130 ]
|
messagePrometheusPort: [ 20130 ]
|
||||||
|
|||||||
@ -100,7 +100,7 @@ func Start(
|
|||||||
go func() {
|
go func() {
|
||||||
if config.Config.Prometheus.Enable && prometheusPort != 0 {
|
if config.Config.Prometheus.Enable && prometheusPort != 0 {
|
||||||
// Create a HTTP server for prometheus.
|
// 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 {
|
if err := httpServer.ListenAndServe(); err != nil {
|
||||||
log.Fatal("Unable to start a http server.")
|
log.Fatal("Unable to start a http server.")
|
||||||
}
|
}
|
||||||
@ -109,3 +109,28 @@ func Start(
|
|||||||
|
|
||||||
return utils.Wrap1(srv.Serve(listener))
|
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…
x
Reference in New Issue
Block a user