Skip to content

Commit

Permalink
fix(mongodb): 发送告警时添加appid #8298
Browse files Browse the repository at this point in the history
  • Loading branch information
cycker committed Nov 29, 2024
1 parent ad39cba commit 158a5ed
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 313 deletions.
23 changes: 4 additions & 19 deletions dbm-services/mongodb/db-tools/dbmon/cmd/dbmonheartbeat/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
package dbmonheartbeat

import (
"dbm-services/mongodb/db-tools/dbmon/cmd/mongojob"
"fmt"
"strconv"
"sync"

"dbm-services/mongodb/db-tools/dbmon/config"
"dbm-services/mongodb/db-tools/dbmon/mylog"
"dbm-services/mongodb/db-tools/dbmon/pkg/sendwarning"
)

const MongoDbmonHeartBeatMetricName = "mongo_dbmon_heart_beat"
Expand Down Expand Up @@ -53,25 +52,11 @@ func (job *Job) Run() {

// SendHeartBeat 发送心跳
func SendHeartBeat(conf *config.BkMonitorBeatConfig, serverConf *config.ConfServerItem) error {
msgH, err := sendwarning.NewBkMonitorEventSender(
conf.BeatPath,
conf.AgentAddress,
)
msgH, err := mongojob.GetBkMonitorBeatSender(conf, serverConf)
if err != nil {
return err
}
return msgH.SetBkBizID(strconv.Itoa(serverConf.BkBizID)).
SetBkCloudID(serverConf.BkCloudID).
SetApp(serverConf.App).
SetAppName(serverConf.AppName).
SetClusterDomain(serverConf.ClusterDomain).
SetClusterName(serverConf.ClusterName).
SetClusterType(serverConf.ClusterType).
SetInstanceRole(serverConf.MetaRole).
SendTimeSeriesMsg(conf.MetricConfig.DataID,
conf.MetricConfig.Token,
serverConf.IP,
MongoDbmonHeartBeatMetricName,
1)
return msgH.SendTimeSeriesMsg(conf.MetricConfig.DataID, conf.MetricConfig.Token,
serverConf.IP, MongoDbmonHeartBeatMetricName, 1)

}
16 changes: 6 additions & 10 deletions dbm-services/mongodb/db-tools/dbmon/cmd/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,18 @@ func sendmsgCmdMain() {
msgTargetIp = server.IP
}
beatConfig := &config.GlobalConf.BkMonitorBeat
msgH, err := mongojob.GetBkMonitorBeatSender(beatConfig, &server)
if err != nil {
fmt.Printf("fatal err %s", err)
os.Exit(1)
}
if msgType == "event" {
msgH, err := mongojob.GetBkMonitorEventSender(beatConfig, &server)
if err != nil {
fmt.Printf("fatal err %s", err)
os.Exit(1)
}
msgH.SendEventMsg(
beatConfig.EventConfig.DataID,
beatConfig.EventConfig.Token,
msgEventName, msgEventMsg, msgEventLevel, msgTargetIp)
} else if msgType == "ts" {
msgH, err := mongojob.GetBkMonitorMetricSender(beatConfig, &server)
if err != nil {
fmt.Printf("fatal err %s", err)
os.Exit(1)
}

msgH.SendTimeSeriesMsg(
beatConfig.MetricConfig.DataID,
beatConfig.MetricConfig.Token,
Expand Down
57 changes: 16 additions & 41 deletions dbm-services/mongodb/db-tools/dbmon/cmd/mongojob/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ import (
"fmt"
"strconv"

"github.com/pkg/errors"

"dbm-services/mongodb/db-tools/dbmon/config"
"dbm-services/mongodb/db-tools/dbmon/mylog"
"dbm-services/mongodb/db-tools/dbmon/pkg/sendwarning"
)

// GetBkMonitorEventSender Retrun a BkMonitorEventSender instance
func GetBkMonitorEventSender(beatConf *config.BkMonitorBeatConfig, serverConf *config.ConfServerItem) (msgH *sendwarning.BkMonitorEventSender, err error) {
// GetBkMonitorBeatSender Retrun a BkMonitorEventSender instance
func GetBkMonitorBeatSender(beatConf *config.BkMonitorBeatConfig, serverConf *config.ConfServerItem) (
msgH *sendwarning.BkMonitorEventSender, err error) {
msgH, err = sendwarning.NewBkMonitorEventSender(
beatConf.BeatPath,
beatConf.AgentAddress,
Expand All @@ -20,59 +23,31 @@ func GetBkMonitorEventSender(beatConf *config.BkMonitorBeatConfig, serverConf *c
}
msgH.SetBkBizID(strconv.Itoa(serverConf.BkBizID)).
SetBkCloudID(serverConf.BkCloudID).
SetBkTargetIp(serverConf.IP).
SetApp(serverConf.App).
SetAppName(serverConf.AppName).
SetClusterDomain(serverConf.ClusterDomain).
SetClusterName(serverConf.ClusterName).
SetClusterType(serverConf.ClusterType).
SetInstanceRole(serverConf.MetaRole)
return
}

// GetBkMonitorMetricSender Retrun a BkMonitorMetricSender instance
func GetBkMonitorMetricSender(conf *config.BkMonitorBeatConfig, serverConf *config.ConfServerItem) (
msgH *sendwarning.BkMonitorEventSender, err error) {
msgH, err = sendwarning.NewBkMonitorEventSender(
conf.BeatPath,
conf.AgentAddress,
)
if err != nil {
return
}
msgH.SetBkBizID(strconv.Itoa(serverConf.BkBizID)).
SetBkCloudID(serverConf.BkCloudID).
SetApp(serverConf.App).
SetAppName(serverConf.AppName).
SetClusterDomain(serverConf.ClusterDomain).
SetClusterName(serverConf.ClusterName).
SetClusterType(serverConf.ClusterType).
SetInstanceRole(serverConf.MetaRole)
SetInstanceRole(serverConf.MetaRole).
SetInstance(serverConf.Addr())
return
}

// SendEvent 发送告警消息
func SendEvent(conf *config.BkMonitorBeatConfig, serverConf *config.ConfServerItem,
eventName, warnLevel, warnMsg string) error {

msgH, err := sendwarning.NewBkMonitorEventSender(
conf.BeatPath,
conf.AgentAddress,
)

if msgH != nil && err == nil {
err = msgH.SetBkBizID(strconv.Itoa(serverConf.BkBizID)).
SetBkCloudID(serverConf.BkCloudID).
SetApp(serverConf.App).
SetAppName(serverConf.AppName).
SetClusterDomain(serverConf.ClusterDomain).
SetClusterName(serverConf.ClusterName).
SetClusterType(serverConf.ClusterType).
SetInstanceRole(serverConf.MetaRole).SendEventMsg(
conf.EventConfig.DataID,
conf.EventConfig.Token,
eventName, warnMsg, warnLevel, serverConf.IP)
msgH, err := GetBkMonitorBeatSender(conf, serverConf)
if err != nil {
return errors.Wrap(err, "NewBkMonitorEventSender failed")
}

err = msgH.SendEventMsg(
conf.EventConfig.DataID,
conf.EventConfig.Token,
eventName, warnMsg, warnLevel, serverConf.IP)

if err != nil {
mylog.Logger.Warn(
fmt.Sprintf("SendEvent failed,name:%s level:%s warnMsg:%q err: %+v",
Expand Down
9 changes: 0 additions & 9 deletions dbm-services/mongodb/db-tools/dbmon/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.15.0
go.mongodb.org/mongo-driver v1.10.6
go.uber.org/zap v1.26.0
golang.org/x/sys v0.7.0
gopkg.in/natefinch/lumberjack.v2 v2.2.1
Expand All @@ -27,19 +26,16 @@ require (
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/goccy/go-json v0.10.2 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.15.11 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/montanaflynn/stats v0.0.0-20180911141734-db72e6cae808 // indirect
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
Expand All @@ -49,15 +45,10 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
github.com/xdg-go/scram v1.1.1 // indirect
github.com/xdg-go/stringprep v1.0.3 // indirect
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/crypto v0.8.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sync v0.1.0 // indirect
golang.org/x/text v0.9.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
Expand Down
26 changes: 0 additions & 26 deletions dbm-services/mongodb/db-tools/dbmon/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,6 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
Expand Down Expand Up @@ -158,9 +155,6 @@ github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHm
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/klauspost/compress v1.15.11 h1:Lcadnb3RKGin4FYM/orgq0qde+nc15E5Cbqg4B9Sx9c=
github.com/klauspost/compress v1.15.11/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
Expand All @@ -186,9 +180,6 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
github.com/montanaflynn/stats v0.0.0-20171201202039-1bf9dbcd8cbe/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/montanaflynn/stats v0.0.0-20180911141734-db72e6cae808 h1:pmpDGKLw4n82EtrNiLqB+xSz/JQwFOaZuMALYUHwX5s=
github.com/montanaflynn/stats v0.0.0-20180911141734-db72e6cae808/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFWZD2D7SIkUc=
github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us=
github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down Expand Up @@ -225,7 +216,6 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
Expand All @@ -234,26 +224,14 @@ github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c=
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
github.com/xdg-go/scram v1.1.1 h1:VOMT+81stJgXW3CpHyqHN3AXDYIMsx56mEFrB37Mb/E=
github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23ni57g=
github.com/xdg-go/stringprep v1.0.3 h1:kdwGpVNwPFtjs98xCGkHjQtGKh86rDcRZN17QEMCOIs=
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d h1:splanxYIlg+5LfHAM6xpdFEAYOk8iySO56hMFq6uLyA=
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
go.mongodb.org/mongo-driver v1.10.6 h1:d/XGSUi/++VkvvU7+QpFqJZzuccp+rUSYMJ5Q3rjx8I=
go.mongodb.org/mongo-driver v1.10.6/go.mod h1:z4XpeoU6w+9Vht+jAFyLgVrD+jGSQQe0+CBWFHNiHt8=
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
Expand All @@ -275,7 +253,6 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
Expand Down Expand Up @@ -365,9 +342,6 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
46 changes: 0 additions & 46 deletions dbm-services/mongodb/db-tools/dbmon/models/mymongo/mymongo.go

This file was deleted.

2 changes: 1 addition & 1 deletion dbm-services/mongodb/db-tools/dbmon/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

repoVersion=0.0.1
respGitHash=$(git rev-parse --short HEAD)
respGitDate=$(date +"%Y%m%d%H%M%S")
respGitDate=$(date +"%Y%m%d%H%M.%S")

# 解析传入的 --version=xxx 和 --git-hash=xxx --git-date="yyyymmdd hhmmss"参数
while [ $# -gt 0 ]; do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ func NewBkMonitorEventSender(beatPath, agentAddress string) (ret *BkMonitorEvent
}

// SendEventMsg 发送告警消息
func (bm *BkMonitorEventSender) SendEventMsg(dataId int64, token string, eventName, warnmsg, warnLevel, targetIP string) (err error) {
func (bm *BkMonitorEventSender) SendEventMsg(dataId int64, token string, eventName,
warnmsg, warnLevel, targetIP string) (err error) {
bm.newDimenSion()
bm.DataID = dataId
bm.AccessToken = token
Expand All @@ -82,7 +83,8 @@ func (bm *BkMonitorEventSender) SendEventMsg(dataId int64, token string, eventNa
}

// SendTimeSeriesMsg dbmon心跳上报. "mongo_dbmon_heart_beat"
func (bm *BkMonitorEventSender) SendTimeSeriesMsg(dataId int64, token string, targetIP string, metricName string, val float64) (err error) {
func (bm *BkMonitorEventSender) SendTimeSeriesMsg(dataId int64, token string, targetIP string,
metricName string, val float64) (err error) {
bm.newDimenSion()
bm.DataID = dataId
bm.AccessToken = token
Expand Down Expand Up @@ -145,7 +147,7 @@ func (bm *BkMonitorEventSender) SetBkBizID(bkBizID string) *BkMonitorEventSender

// SetBkCloudID set bk_cloud_id
func (bm *BkMonitorEventSender) SetBkCloudID(bkCloudID int64) *BkMonitorEventSender {
return bm.set("bk_cloud_id", bkCloudID)
return bm.set("bk_cloud_id", bkCloudID).set("bk_target_cloud_id", bkCloudID)
}

// set key value
Expand All @@ -160,8 +162,12 @@ func (bm *BkMonitorEventSender) SetApp(app string) *BkMonitorEventSender {
return bm.set("app", app)
}

// SetBkTargetIp TODO
func (bm *BkMonitorEventSender) SetBkTargetIp(bkTargetIp string) *BkMonitorEventSender {
return bm.set("bk_target_ip", bkTargetIp)
}

// SetAppName TODO
// SetApp set app
func (bm *BkMonitorEventSender) SetAppName(appname string) *BkMonitorEventSender {
return bm.set("app_name", appname)
}
Expand Down
Loading

0 comments on commit 158a5ed

Please sign in to comment.