diff --git a/config/config.yaml b/config/config.yaml index 9597fa1f8..e375118f7 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -383,6 +383,7 @@ callback: # The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh prometheus: enable: true + prometheusUrl: "https://openim.prometheus" apiPrometheusPort: [20100] userPrometheusPort: [ 20110 ] friendPrometheusPort: [ 20120 ] diff --git a/deployments/templates/openim.yaml b/deployments/templates/openim.yaml index 947e2e4d5..44a28adff 100644 --- a/deployments/templates/openim.yaml +++ b/deployments/templates/openim.yaml @@ -383,6 +383,7 @@ callback: # The number of ports needs to be consistent with msg_transfer_service_num in script/path_info.sh prometheus: enable: ${PROMETHEUS_ENABLE} + prometheusUrl: ${PROMETHEUS_URL} apiPrometheusPort: [${API_PROM_PORT}] userPrometheusPort: [ ${USER_PROM_PORT} ] friendPrometheusPort: [ ${FRIEND_PROM_PORT} ] diff --git a/internal/api/route.go b/internal/api/route.go index 73ddb4bd4..7a331d643 100644 --- a/internal/api/route.go +++ b/internal/api/route.go @@ -143,6 +143,7 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive // Third service thirdGroup := r.Group("/third", ParseToken) { + thirdGroup.GET("/prometheus", GetPrometheus) t := NewThirdApi(*thirdRpc) thirdGroup.POST("/fcm_update_token", t.FcmUpdateToken) thirdGroup.POST("/set_app_badge", t.SetAppBadge) diff --git a/internal/api/third.go b/internal/api/third.go index cdb059cc0..fca133ea9 100644 --- a/internal/api/third.go +++ b/internal/api/third.go @@ -15,6 +15,7 @@ package api import ( + config2 "github.com/openimsdk/open-im-server/v3/pkg/common/config" "math/rand" "net/http" "strconv" @@ -118,3 +119,7 @@ func (o *ThirdApi) DeleteLogs(c *gin.Context) { func (o *ThirdApi) SearchLogs(c *gin.Context) { a2r.Call(third.ThirdClient.SearchLogs, o.Client, c) } + +func GetPrometheus(c *gin.Context) { + c.Redirect(http.StatusFound, config2.Config.Prometheus.PrometheusUrl) +} diff --git a/pkg/common/config/config.go b/pkg/common/config/config.go index 96343f9a0..d7cecc616 100644 --- a/pkg/common/config/config.go +++ b/pkg/common/config/config.go @@ -262,19 +262,20 @@ type configStruct struct { } `yaml:"callback"` Prometheus struct { - Enable bool `yaml:"enable"` - ApiPrometheusPort []int `yaml:"apiPrometheusPort"` - UserPrometheusPort []int `yaml:"userPrometheusPort"` - FriendPrometheusPort []int `yaml:"friendPrometheusPort"` - MessagePrometheusPort []int `yaml:"messagePrometheusPort"` - MessageGatewayPrometheusPort []int `yaml:"messageGatewayPrometheusPort"` - GroupPrometheusPort []int `yaml:"groupPrometheusPort"` - AuthPrometheusPort []int `yaml:"authPrometheusPort"` - PushPrometheusPort []int `yaml:"pushPrometheusPort"` - ConversationPrometheusPort []int `yaml:"conversationPrometheusPort"` - RtcPrometheusPort []int `yaml:"rtcPrometheusPort"` - MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"` - ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"` + Enable bool `yaml:"enable"` + PrometheusUrl string `yaml:"prometheusUrl"` + ApiPrometheusPort []int `yaml:"apiPrometheusPort"` + UserPrometheusPort []int `yaml:"userPrometheusPort"` + FriendPrometheusPort []int `yaml:"friendPrometheusPort"` + MessagePrometheusPort []int `yaml:"messagePrometheusPort"` + MessageGatewayPrometheusPort []int `yaml:"messageGatewayPrometheusPort"` + GroupPrometheusPort []int `yaml:"groupPrometheusPort"` + AuthPrometheusPort []int `yaml:"authPrometheusPort"` + PushPrometheusPort []int `yaml:"pushPrometheusPort"` + ConversationPrometheusPort []int `yaml:"conversationPrometheusPort"` + RtcPrometheusPort []int `yaml:"rtcPrometheusPort"` + MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"` + ThirdPrometheusPort []int `yaml:"thirdPrometheusPort"` } `yaml:"prometheus"` Notification notification `yaml:"notification"` } diff --git a/scripts/install/environment.sh b/scripts/install/environment.sh index 750eb1ec2..7d9beb5b3 100755 --- a/scripts/install/environment.sh +++ b/scripts/install/environment.sh @@ -338,6 +338,7 @@ def "IOS_PRODUCTION" "false" # IOS生产 ###################### Prometheus 配置信息 ###################### def "PROMETHEUS_ENABLE" "false" # 是否启用 Prometheus +def "PROMETHEUS_URL" "/prometheus" # Api 服务的 Prometheus 端口 readonly API_PROM_PORT=${API_PROM_PORT:-'20100'} # User 服务的 Prometheus 端口