docker-compose

pull/351/head
wangchuxiao 2 years ago
parent 4af9d88771
commit aebcd1db2e

@ -2,8 +2,10 @@ package main
import (
"Open_IM/internal/msg_transfer/logic"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
"flag"
"fmt"
"sync"
)
@ -11,9 +13,10 @@ import (
func main() {
var wg sync.WaitGroup
wg.Add(1)
rpcPort := flag.Int("port", config.Config.Prometheus.MessageTransferPrometheusPort[0], "MessageTransferPrometheusPort default listen port")
log.NewPrivateLog(constant.LogFileName)
logic.Init()
fmt.Println("start msg_transfer server")
logic.Run()
logic.Run(*rpcPort)
wg.Wait()
}

@ -88,9 +88,7 @@ endpoints:
rpc_group: openim_rpc_group
rpc_msg: openim_rpc_msg
rpc_user: openim_rpc_user
rpc_statistic: openim_rpc_statistic
rpc_admin_cms: openim_rpc_admin_cms
rpc_message_cms: openim_rpc_admin_cms
rpc_office: openim_rpc_office
api:
@ -155,8 +153,6 @@ rpcport: #rpc服务端口 默认即可
openImGroupPort: [ 10150 ]
openImAuthPort: [ 10160 ]
openImPushPort: [ 10170 ]
openImStatisticsPort: [ 10180 ]
openImMessageCmsPort: [ 10190 ]
openImAdminCmsPort: [ 10200 ]
openImOfficePort: [ 10210 ]
openImOrganizationPort: [ 10220 ]
@ -181,8 +177,6 @@ rpcregistername: #rpc注册服务名默认即可
openImRelayName: Relay
openImGroupName: Group
openImAuthName: Auth
openImStatisticsName: Statistics
openImMessageCMSName: MessageCMS
openImAdminCMSName: AdminCMS
openImOfficeName: Office
openImOrganizationName: Organization
@ -758,3 +752,19 @@ demo:
rtc:
signalTimeout: 35
prometheus:
enable: false
userPrometheusPort: [ 20110 ]
friendPrometheusPort: [ 20120 ]
messagePrometheusPort: [ 20130 ]
messageGatewayPrometheusPort: [ 20140 ]
groupPrometheusPort: [ 20150 ]
authPrometheusPort: [ 20160 ]
pushPrometheusPort: [ 20170 ]
adminCmsPrometheusPort: [ 20200 ]
officePrometheusPort: [ 20210 ]
organizationPrometheusPort: [ 20220 ]
conversationPrometheusPort: [ 20230 ]
cachePrometheusPort: [ 20240 ]
realTimeCommPrometheusPort: [ 21300 ]
messageTransferPrometheusPort: [ 21400 ]

@ -157,7 +157,7 @@ services:
# - ./grafana/provisioning/dashboard.yaml:/etc/grafana/provisioning/dashboards/dashboard.yaml
- ./docker-compose_cfg/datasource-compose.yaml:/etc/grafana/provisioning/datasources/datasource.yaml
- ./docker-compose_cfg/grafana.ini:/etc/grafana/grafana.ini
# - ./components/grafana_data:/var/lib/grafana
- ./docker-compose_cfg/node-exporter-full_rev1.json:/var/lib/grafana/dashboards/node-exporter-full_rev1.json
container_name: grafana
ports:
- 10007:10007
@ -170,4 +170,5 @@ services:
container_name: node-exporter
restart: always
ports:
- "9100:9100"
- "9100:9100"
command: --collector.ENTER-THE-NAME-OF-COLLECTOR

File diff suppressed because it is too large Load Diff

@ -2,15 +2,26 @@
global:
scrape_interval: 15s
evaluation_interval: 15s
external_labels:
monitor: 'openIM-monitor'
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9091']
- job_name: 'openIM-server'
metrics_path: /cms/prometheus/metrics
static_configs:
- targets: ['localhost:10006']
- targets: ['localhost:10006']
metrics_path: /cms/prometheus/metrics
labels:
group: 'cms-api'
- targets: ['localhost:21400']
metrics_path: /metrics
labels:
group: 'msg-transfer'
- job_name: 'node'
scrape_interval: 8s
static_configs:

@ -9,6 +9,7 @@ import (
"Open_IM/internal/cms_api/statistics"
"Open_IM/internal/cms_api/user"
"Open_IM/internal/demo/register"
"Open_IM/pkg/common/config"
"github.com/gin-gonic/gin"
)
@ -18,9 +19,11 @@ func NewGinRouter() *gin.Engine {
baseRouter := gin.Default()
router := baseRouter.Group("/cms")
router.Use(middleware.CorsHandler())
prometheusRouterGroup := router.Group("/prometheus")
{
prometheusRouterGroup.GET("/metrics", prometheusHandler())
if config.Config.Prometheus.Enable {
prometheusRouterGroup := router.Group("/prometheus")
{
prometheusRouterGroup.GET("/metrics", prometheusHandler())
}
}
adminRouterGroup := router.Group("/admin")
{

@ -6,7 +6,11 @@ import (
"Open_IM/pkg/common/kafka"
"Open_IM/pkg/statistics"
"fmt"
"net/http"
"strconv"
"sync"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
const OnlineTopicBusy = 1
@ -46,7 +50,7 @@ func Init() {
producer = kafka.NewKafkaProducer(config.Config.Kafka.Ms2pschat.Addr, config.Config.Kafka.Ms2pschat.Topic)
producerToMongo = kafka.NewKafkaProducer(config.Config.Kafka.MsgToMongo.Addr, config.Config.Kafka.MsgToMongo.Topic)
}
func Run() {
func Run(promethuesPort int) {
//register mysqlConsumerHandler to
if config.Config.ChatPersistenceMysql {
go persistentCH.persistentConsumerGroup.RegisterHandleAndConsumer(&persistentCH)
@ -56,6 +60,10 @@ func Run() {
go historyCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyCH)
go historyMongoCH.historyConsumerGroup.RegisterHandleAndConsumer(&historyMongoCH)
//go offlineHistoryCH.historyConsumerGroup.RegisterHandleAndConsumer(&offlineHistoryCH)
if config.Config.Prometheus.Enable {
http.Handle("/metrics", promhttp.Handler())
http.ListenAndServe(":"+strconv.Itoa(promethuesPort), nil)
}
}
func SetOnlineTopicStatus(status int) {
w.Lock()

@ -14,8 +14,16 @@ import (
"Open_IM/pkg/common/log"
pbMsg "Open_IM/pkg/proto/msg"
"Open_IM/pkg/utils"
"github.com/Shopify/sarama"
"github.com/golang/protobuf/proto"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
var (
msgInsertMysqlProcessed prometheus.Counter
)
type PersistentConsumerHandler struct {
@ -29,7 +37,12 @@ func (pc *PersistentConsumerHandler) Init() {
pc.persistentConsumerGroup = kfk.NewMConsumerGroup(&kfk.MConsumerGroupConfig{KafkaVersion: sarama.V2_0_0_0,
OffsetsInitial: sarama.OffsetNewest, IsReturnErr: false}, []string{config.Config.Kafka.Ws2mschat.Topic},
config.Config.Kafka.Ws2mschat.Addr, config.Config.Kafka.ConsumerGroupID.MsgToMySql)
if config.Config.Prometheus.Enable {
msgInsertMysqlProcessed = promauto.NewCounter(prometheus.CounterOpts{
Name: "insert_mysql_msg_total",
Help: "The total number of msg insert mysql events",
})
}
}
func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMessage, msgKey string, _ sarama.ConsumerGroupSession) {
@ -65,6 +78,9 @@ func (pc *PersistentConsumerHandler) handleChatWs2Mysql(cMsg *sarama.ConsumerMes
log.NewError(msgFromMQ.OperationID, "Message insert failed", "err", err.Error(), "msg", msgFromMQ.String())
return
}
if config.Config.Prometheus.Enable {
msgInsertMysqlProcessed.Inc()
}
}
}

@ -131,8 +131,6 @@ type config struct {
OpenImGroupPort []int `yaml:"openImGroupPort"`
OpenImAuthPort []int `yaml:"openImAuthPort"`
OpenImPushPort []int `yaml:"openImPushPort"`
OpenImStatisticsPort []int `yaml:"openImStatisticsPort"`
OpenImMessageCmsPort []int `yaml:"openImMessageCmsPort"`
OpenImAdminCmsPort []int `yaml:"openImAdminCmsPort"`
OpenImOfficePort []int `yaml:"openImOfficePort"`
OpenImOrganizationPort []int `yaml:"openImOrganizationPort"`
@ -150,8 +148,6 @@ type config struct {
OpenImRelayName string `yaml:"openImRelayName"`
OpenImGroupName string `yaml:"openImGroupName"`
OpenImAuthName string `yaml:"openImAuthName"`
OpenImMessageCMSName string `yaml:"openImMessageCMSName"`
OpenImAdminCMSName string `yaml:"openImAdminCMSName"`
OpenImOfficeName string `yaml:"openImOfficeName"`
OpenImOrganizationName string `yaml:"openImOrganizationName"`
OpenImConversationName string `yaml:"openImConversationName"`
@ -513,6 +509,24 @@ type config struct {
Rtc struct {
SignalTimeout string `yaml:"signalTimeout"`
} `yaml:"rtc"`
Prometheus struct {
Enable bool `yaml:"enable"`
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"`
AdminCmsPrometheusPort []int `yaml:"adminCmsPrometheusPort"`
OfficePrometheusPort []int `yaml:"officePrometheusPort"`
OrganizationPrometheusPort []int `yaml:"organizationPrometheusPort"`
ConversationPrometheusPort []int `yaml:"conversationPrometheusPort"`
CachePrometheusPort []int `yaml:"cachePrometheusPort"`
RealTimeCommPrometheusPort []int `yaml:"realTimeCommPrometheusPort"`
MessageTransferPrometheusPort []int `yaml:"messageTransferPrometheusPort"`
} `yaml:"prometheus"`
}
type PConversation struct {
ReliabilityLevel int `yaml:"reliabilityLevel"`

Loading…
Cancel
Save