Feat metrics (#2429)

* feat: register and alert

* feat: grafana
pull/2432/head
icey-yu 2 months ago committed by GitHub
parent d945a07549
commit 6c8ac45137
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -11,11 +11,20 @@ templates:
- /etc/alertmanager/email.tmpl
route:
group_by: ['alertname']
group_by: [ 'alertname' ]
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
routes:
- matchers:
- alertname = "XXX"
group_by: [ 'instance' ]
group_wait: 5s
group_interval: 5s
repeat_interval: 5m
receiver: email
receivers:
- name: email
email_configs:

File diff suppressed because it is too large Load Diff

@ -20,3 +20,25 @@ groups:
annotations:
summary: "Increase in MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter detected"
description: "Either MsgInsertRedisFailedCounter or MsgInsertMongoFailedCounter has increased in the last 5 minutes, indicating failures in message insert operations to Redis or MongoDB,maybe the redis or mongodb is crash."
- name: registrations_few
rules:
- alert: RegistrationsFew
expr: increase(user_login_total[1h]) == 0
for: 1m
labels:
severity: info
annotations:
summary: "Too few registrations within the time frame"
description: "The number of registrations in the last hour is 0. There might be some issues."
- name: messages_few
rules:
- alert: MessagesFew
expr: (increase(single_chat_msg_process_success_total[1h])+increase(group_chat_msg_process_success_total[1h])) == 0
for: 1m
labels:
severity: info
annotations:
summary: "Too few messages within the time frame"
description: "The number of messages sent in the last hour is 0. There might be some issues."

@ -19,6 +19,7 @@ import (
"errors"
"github.com/openimsdk/open-im-server/v3/internal/rpc/friend"
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
"github.com/openimsdk/open-im-server/v3/pkg/common/prommetrics"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/cache/redis"
"github.com/openimsdk/open-im-server/v3/pkg/common/storage/database/mgo"
@ -310,6 +311,8 @@ func (s *userServer) UserRegister(ctx context.Context, req *pbuser.UserRegisterR
return nil, err
}
prommetrics.UserRegisterCounter.Add(float64(len(users)))
s.webhookAfterUserRegister(ctx, &s.config.WebhooksConfig.AfterUserRegister, req)
return resp, nil
}

@ -0,0 +1,10 @@
package prommetrics
import "github.com/prometheus/client_golang/prometheus"
var (
UserRegisterCounter = prometheus.NewCounter(prometheus.CounterOpts{
Name: "user_register_total",
Help: "The number of user login",
})
)

@ -52,6 +52,8 @@ func GetGrpcCusMetrics(registerName string, share *config.Share) []prometheus.Co
return []prometheus.Collector{MsgOfflinePushFailedCounter}
case share.RpcRegisterName.Auth:
return []prometheus.Collector{UserLoginCounter}
case share.RpcRegisterName.User:
return []prometheus.Collector{UserRegisterCounter}
default:
return nil
}

Loading…
Cancel
Save