Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
6462c028
N
nightingale
项目概览
DiDi
/
nightingale
9 个月 前同步成功
通知
46
Star
7053
Fork
1161
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
nightingale
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
6462c028
编写于
7月 17, 2023
作者:
U
Ulric Qin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename obs to dumper
上级
c6571826
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
68 addition
and
68 deletion
+68
-68
alert/alert.go
alert/alert.go
+2
-2
center/center.go
center/center.go
+2
-2
cmd/edge/edge.go
cmd/edge/edge.go
+2
-2
dumper/dumper.go
dumper/dumper.go
+1
-1
dumper/sync.go
dumper/sync.go
+1
-1
memsto/alert_mute_cache.go
memsto/alert_mute_cache.go
+5
-5
memsto/alert_rule_cache.go
memsto/alert_rule_cache.go
+5
-5
memsto/alert_subscribe_cache.go
memsto/alert_subscribe_cache.go
+5
-5
memsto/busi_group_cache.go
memsto/busi_group_cache.go
+5
-5
memsto/datasource_cache.go
memsto/datasource_cache.go
+5
-5
memsto/notify_config.go
memsto/notify_config.go
+14
-14
memsto/recording_rule_cache.go
memsto/recording_rule_cache.go
+5
-5
memsto/target_cache.go
memsto/target_cache.go
+5
-5
memsto/user_cache.go
memsto/user_cache.go
+5
-5
memsto/user_group_cache.go
memsto/user_group_cache.go
+6
-6
未找到文件。
alert/alert.go
浏览文件 @
6462c028
...
...
@@ -15,9 +15,9 @@ import (
"github.com/ccfos/nightingale/v6/alert/router"
"github.com/ccfos/nightingale/v6/alert/sender"
"github.com/ccfos/nightingale/v6/conf"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/memsto"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/ccfos/nightingale/v6/pkg/httpx"
"github.com/ccfos/nightingale/v6/pkg/logx"
...
...
@@ -60,7 +60,7 @@ func Initialize(configDir string, cryptoKey string) (func(), error) {
r
:=
httpx
.
GinEngine
(
config
.
Global
.
RunMode
,
config
.
HTTP
)
rt
:=
router
.
New
(
config
.
HTTP
,
config
.
Alert
,
alertMuteCache
,
targetCache
,
busiGroupCache
,
alertStats
,
ctx
,
externalProcessors
)
rt
.
Config
(
r
)
obs
.
ConfigRouter
(
r
)
dumper
.
ConfigRouter
(
r
)
httpClean
:=
httpx
.
Init
(
config
.
HTTP
,
r
)
...
...
center/center.go
浏览文件 @
6462c028
...
...
@@ -11,10 +11,10 @@ import (
"github.com/ccfos/nightingale/v6/center/metas"
"github.com/ccfos/nightingale/v6/center/sso"
"github.com/ccfos/nightingale/v6/conf"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/memsto"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/models/migrate"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/ccfos/nightingale/v6/pkg/httpx"
"github.com/ccfos/nightingale/v6/pkg/i18nx"
...
...
@@ -93,7 +93,7 @@ func Initialize(configDir string, cryptoKey string) (func(), error) {
centerRouter
.
Config
(
r
)
alertrtRouter
.
Config
(
r
)
pushgwRouter
.
Config
(
r
)
obs
.
ConfigRouter
(
r
)
dumper
.
ConfigRouter
(
r
)
httpClean
:=
httpx
.
Init
(
config
.
HTTP
,
r
)
...
...
cmd/edge/edge.go
浏览文件 @
6462c028
...
...
@@ -8,8 +8,8 @@ import (
"github.com/ccfos/nightingale/v6/alert/astats"
"github.com/ccfos/nightingale/v6/alert/process"
"github.com/ccfos/nightingale/v6/conf"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/memsto"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/ccfos/nightingale/v6/pkg/httpx"
"github.com/ccfos/nightingale/v6/pkg/logx"
...
...
@@ -63,7 +63,7 @@ func Initialize(configDir string, cryptoKey string) (func(), error) {
alertrtRouter
.
Config
(
r
)
}
obs
.
ConfigRouter
(
r
)
dumper
.
ConfigRouter
(
r
)
httpClean
:=
httpx
.
Init
(
config
.
HTTP
,
r
)
return
func
()
{
...
...
obs/obs
.go
→
dumper/dumper
.go
浏览文件 @
6462c028
package
obs
package
dumper
import
"github.com/gin-gonic/gin"
...
...
obs
/sync.go
→
dumper
/sync.go
浏览文件 @
6462c028
package
obs
package
dumper
import
(
"fmt"
...
...
memsto/alert_mute_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -109,7 +109,7 @@ func (amc *AlertMuteCacheType) syncAlertMutes() error {
stat
,
err
:=
models
.
AlertMuteStatistics
(
amc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec AlertMuteStatistics"
)
}
...
...
@@ -117,13 +117,13 @@ func (amc *AlertMuteCacheType) syncAlertMutes() error {
amc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_alert_mutes"
)
.
Set
(
0
)
amc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_alert_mutes"
)
.
Set
(
0
)
logger
.
Debug
(
"alert mutes not changed"
)
obs
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
lst
,
err
:=
models
.
AlertMuteGetsAll
(
amc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec AlertMuteGetsByCluster"
)
}
...
...
@@ -144,7 +144,7 @@ func (amc *AlertMuteCacheType) syncAlertMutes() error {
amc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_alert_mutes"
)
.
Set
(
float64
(
ms
))
amc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_alert_mutes"
)
.
Set
(
float64
(
len
(
lst
)))
logger
.
Infof
(
"timer: sync mutes done, cost: %dms, number: %d"
,
ms
,
len
(
lst
))
obs
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
ms
,
len
(
lst
),
"success"
)
dumper
.
PutSyncRecord
(
"alert_mutes"
,
start
.
Unix
(),
ms
,
len
(
lst
),
"success"
)
return
nil
}
memsto/alert_rule_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -105,7 +105,7 @@ func (arc *AlertRuleCacheType) syncAlertRules() error {
start
:=
time
.
Now
()
stat
,
err
:=
models
.
AlertRuleStatistics
(
arc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec AlertRuleStatistics"
)
}
...
...
@@ -113,13 +113,13 @@ func (arc *AlertRuleCacheType) syncAlertRules() error {
arc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_alert_rules"
)
.
Set
(
0
)
arc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_alert_rules"
)
.
Set
(
0
)
logger
.
Debug
(
"alert rules not changed"
)
obs
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
lst
,
err
:=
models
.
AlertRuleGetsAll
(
arc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec AlertRuleGetsByCluster"
)
}
...
...
@@ -134,7 +134,7 @@ func (arc *AlertRuleCacheType) syncAlertRules() error {
arc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_alert_rules"
)
.
Set
(
float64
(
ms
))
arc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_alert_rules"
)
.
Set
(
float64
(
len
(
m
)))
logger
.
Infof
(
"timer: sync rules done, cost: %dms, number: %d"
,
ms
,
len
(
m
))
obs
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
dumper
.
PutSyncRecord
(
"alert_rules"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
return
nil
}
memsto/alert_subscribe_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -121,7 +121,7 @@ func (c *AlertSubscribeCacheType) syncAlertSubscribes() error {
start
:=
time
.
Now
()
stat
,
err
:=
models
.
AlertSubscribeStatistics
(
c
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec AlertSubscribeStatistics"
)
}
...
...
@@ -129,13 +129,13 @@ func (c *AlertSubscribeCacheType) syncAlertSubscribes() error {
c
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_alert_subscribes"
)
.
Set
(
0
)
c
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_alert_subscribes"
)
.
Set
(
0
)
logger
.
Debug
(
"alert subscribes not changed"
)
obs
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
lst
,
err
:=
models
.
AlertSubscribeGetsAll
(
c
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec AlertSubscribeGetsAll"
)
}
...
...
@@ -169,7 +169,7 @@ func (c *AlertSubscribeCacheType) syncAlertSubscribes() error {
c
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_alert_subscribes"
)
.
Set
(
float64
(
ms
))
c
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_alert_subscribes"
)
.
Set
(
float64
(
len
(
lst
)))
logger
.
Infof
(
"timer: sync subscribes done, cost: %dms, number: %d"
,
ms
,
len
(
lst
))
obs
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
ms
,
len
(
lst
),
"success"
)
dumper
.
PutSyncRecord
(
"alert_subscribes"
,
start
.
Unix
(),
ms
,
len
(
lst
),
"success"
)
return
nil
}
memsto/busi_group_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -84,7 +84,7 @@ func (c *BusiGroupCacheType) syncBusiGroups() error {
stat
,
err
:=
models
.
BusiGroupStatistics
(
c
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to call BusiGroupStatistics"
)
}
...
...
@@ -92,13 +92,13 @@ func (c *BusiGroupCacheType) syncBusiGroups() error {
c
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_busi_groups"
)
.
Set
(
0
)
c
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_busi_groups"
)
.
Set
(
0
)
logger
.
Debug
(
"busi_group not changed"
)
obs
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
m
,
err
:=
models
.
BusiGroupGetMap
(
c
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to call BusiGroupGetMap"
)
}
...
...
@@ -109,7 +109,7 @@ func (c *BusiGroupCacheType) syncBusiGroups() error {
c
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_busi_groups"
)
.
Set
(
float64
(
len
(
m
)))
logger
.
Infof
(
"timer: sync busi groups done, cost: %dms, number: %d"
,
ms
,
len
(
m
))
obs
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
dumper
.
PutSyncRecord
(
"busi_groups"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
return
nil
}
memsto/datasource_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -83,7 +83,7 @@ func (d *DatasourceCacheType) syncDatasources() error {
stat
,
err
:=
models
.
DatasourceStatistics
(
d
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to call DatasourceStatistics"
)
}
...
...
@@ -92,14 +92,14 @@ func (d *DatasourceCacheType) syncDatasources() error {
d
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_datasources"
)
.
Set
(
0
)
logger
.
Debug
(
"datasource not changed"
)
obs
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
m
,
err
:=
models
.
DatasourceGetMap
(
d
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to call DatasourceGetMap"
)
}
...
...
@@ -110,7 +110,7 @@ func (d *DatasourceCacheType) syncDatasources() error {
d
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_datasources"
)
.
Set
(
float64
(
len
(
m
)))
logger
.
Infof
(
"timer: sync datasources done, cost: %dms, number: %d"
,
ms
,
len
(
m
))
obs
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
dumper
.
PutSyncRecord
(
"datasources"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
return
nil
}
memsto/notify_config.go
浏览文件 @
6462c028
...
...
@@ -8,8 +8,8 @@ import (
"github.com/BurntSushi/toml"
"github.com/ccfos/nightingale/v6/alert/aconf"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/toolkits/pkg/logger"
)
...
...
@@ -76,37 +76,37 @@ func (w *NotifyConfigCacheType) syncNotifyConfigs() error {
cval
,
err
:=
models
.
ConfigsGet
(
w
.
ctx
,
models
.
WEBHOOKKEY
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"webhooks"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.webhook: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"webhooks"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.webhook: "
+
err
.
Error
())
return
err
}
if
strings
.
TrimSpace
(
cval
)
!=
""
{
err
=
json
.
Unmarshal
([]
byte
(
cval
),
&
w
.
webhooks
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"webhooks"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.webhook: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"webhooks"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.webhook: "
+
err
.
Error
())
logger
.
Errorf
(
"failed to unmarshal webhooks:%s error:%v"
,
cval
,
err
)
}
}
obs
.
PutSyncRecord
(
"webhooks"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
len
(
w
.
webhooks
),
"success, webhooks:
\n
"
+
cval
)
dumper
.
PutSyncRecord
(
"webhooks"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
len
(
w
.
webhooks
),
"success, webhooks:
\n
"
+
cval
)
logger
.
Debugf
(
"timer: sync wbhooks done number: %d"
,
len
(
w
.
webhooks
))
start
=
time
.
Now
()
cval
,
err
=
models
.
ConfigsGet
(
w
.
ctx
,
models
.
SMTP
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"smtp"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.smtp_config: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"smtp"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.smtp_config: "
+
err
.
Error
())
return
err
}
if
strings
.
TrimSpace
(
cval
)
!=
""
{
err
=
toml
.
Unmarshal
([]
byte
(
cval
),
&
w
.
smtp
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"smtp"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.smtp_config: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"smtp"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.smtp_config: "
+
err
.
Error
())
logger
.
Errorf
(
"failed to unmarshal smtp:%s error:%v"
,
cval
,
err
)
}
}
obs
.
PutSyncRecord
(
"smtp"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
1
,
"success, smtp_config:
\n
"
+
cval
)
dumper
.
PutSyncRecord
(
"smtp"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
1
,
"success, smtp_config:
\n
"
+
cval
)
var
tmp
aconf
.
SMTPConfig
toml
.
Unmarshal
([]
byte
(
cval
),
&
tmp
)
...
...
@@ -116,43 +116,43 @@ func (w *NotifyConfigCacheType) syncNotifyConfigs() error {
start
=
time
.
Now
()
cval
,
err
=
models
.
ConfigsGet
(
w
.
ctx
,
models
.
NOTIFYSCRIPT
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"notify_script"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.notify_script: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"notify_script"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.notify_script: "
+
err
.
Error
())
return
err
}
if
strings
.
TrimSpace
(
cval
)
!=
""
{
err
=
json
.
Unmarshal
([]
byte
(
cval
),
&
w
.
script
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"notify_script"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.notify_script: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"notify_script"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.notify_script: "
+
err
.
Error
())
logger
.
Errorf
(
"failed to unmarshal notify script:%s error:%v"
,
cval
,
err
)
}
}
obs
.
PutSyncRecord
(
"notify_script"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
1
,
"success, notify_script:
\n
"
+
cval
)
dumper
.
PutSyncRecord
(
"notify_script"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
1
,
"success, notify_script:
\n
"
+
cval
)
logger
.
Debug
(
"timer: sync notify script done"
)
start
=
time
.
Now
()
cval
,
err
=
models
.
ConfigsGet
(
w
.
ctx
,
models
.
IBEX
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.ibex_server: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query configs.ibex_server: "
+
err
.
Error
())
return
err
}
if
strings
.
TrimSpace
(
cval
)
!=
""
{
err
=
toml
.
Unmarshal
([]
byte
(
cval
),
&
w
.
ibex
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.ibex_server: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.ibex_server: "
+
err
.
Error
())
logger
.
Errorf
(
"failed to unmarshal ibex:%s error:%v"
,
cval
,
err
)
}
}
else
{
err
=
toml
.
Unmarshal
([]
byte
(
DefaultIbex
),
&
w
.
ibex
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.ibex_server: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to unmarshal configs.ibex_server: "
+
err
.
Error
())
logger
.
Errorf
(
"failed to unmarshal ibex:%s error:%v"
,
cval
,
err
)
}
}
obs
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
1
,
"success, ibex_server config:
\n
"
+
cval
)
dumper
.
PutSyncRecord
(
"ibex"
,
start
.
Unix
(),
time
.
Since
(
start
)
.
Milliseconds
(),
1
,
"success, ibex_server config:
\n
"
+
cval
)
logger
.
Debug
(
"timer: sync ibex done"
)
return
nil
...
...
memsto/recording_rule_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -106,21 +106,21 @@ func (rrc *RecordingRuleCacheType) syncRecordingRules() error {
stat
,
err
:=
models
.
RecordingRuleStatistics
(
rrc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec RecordingRuleStatistics"
)
}
if
!
rrc
.
StatChanged
(
stat
.
Total
,
stat
.
LastUpdated
)
{
rrc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_recording_rules"
)
.
Set
(
0
)
rrc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_recording_rules"
)
.
Set
(
0
)
obs
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
logger
.
Debug
(
"recoding rules not changed"
)
return
nil
}
lst
,
err
:=
models
.
RecordingRuleGetsByCluster
(
rrc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec RecordingRuleGetsByCluster"
)
}
...
...
@@ -135,7 +135,7 @@ func (rrc *RecordingRuleCacheType) syncRecordingRules() error {
rrc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_recording_rules"
)
.
Set
(
float64
(
ms
))
rrc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_recording_rules"
)
.
Set
(
float64
(
len
(
m
)))
logger
.
Infof
(
"timer: sync recording rules done, cost: %dms, number: %d"
,
ms
,
len
(
m
))
obs
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
dumper
.
PutSyncRecord
(
"recording_rules"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
return
nil
}
memsto/target_cache.go
浏览文件 @
6462c028
...
...
@@ -8,8 +8,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/ccfos/nightingale/v6/storage"
...
...
@@ -130,21 +130,21 @@ func (tc *TargetCacheType) syncTargets() error {
stat
,
err
:=
models
.
TargetStatistics
(
tc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to call TargetStatistics"
)
}
if
!
tc
.
StatChanged
(
stat
.
Total
,
stat
.
LastUpdated
)
{
tc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_targets"
)
.
Set
(
0
)
tc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_targets"
)
.
Set
(
0
)
obs
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
logger
.
Debug
(
"targets not changed"
)
return
nil
}
lst
,
err
:=
models
.
TargetGetsAll
(
tc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to call TargetGetsAll"
)
}
...
...
@@ -168,7 +168,7 @@ func (tc *TargetCacheType) syncTargets() error {
tc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_targets"
)
.
Set
(
float64
(
ms
))
tc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_targets"
)
.
Set
(
float64
(
len
(
lst
)))
logger
.
Infof
(
"timer: sync targets done, cost: %dms, number: %d"
,
ms
,
len
(
lst
))
obs
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
ms
,
len
(
lst
),
"success"
)
dumper
.
PutSyncRecord
(
"targets"
,
start
.
Unix
(),
ms
,
len
(
lst
),
"success"
)
return
nil
}
...
...
memsto/user_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -140,7 +140,7 @@ func (uc *UserCacheType) syncUsers() error {
stat
,
err
:=
models
.
UserStatistics
(
uc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec UserStatistics"
)
}
...
...
@@ -148,13 +148,13 @@ func (uc *UserCacheType) syncUsers() error {
uc
.
stats
.
GaugeCronDuration
.
WithLabelValues
(
"sync_users"
)
.
Set
(
0
)
uc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_users"
)
.
Set
(
0
)
logger
.
Debug
(
"users not changed"
)
obs
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
lst
,
err
:=
models
.
UserGetAll
(
uc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec UserGetAll"
)
}
...
...
@@ -170,7 +170,7 @@ func (uc *UserCacheType) syncUsers() error {
uc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_users"
)
.
Set
(
float64
(
len
(
m
)))
logger
.
Infof
(
"timer: sync users done, cost: %dms, number: %d"
,
ms
,
len
(
m
))
obs
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
dumper
.
PutSyncRecord
(
"users"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
return
nil
}
memsto/user_group_cache.go
浏览文件 @
6462c028
...
...
@@ -5,8 +5,8 @@ import (
"sync"
"time"
"github.com/ccfos/nightingale/v6/dumper"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/obs"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/pkg/errors"
...
...
@@ -111,7 +111,7 @@ func (ugc *UserGroupCacheType) syncUserGroups() error {
stat
,
err
:=
models
.
UserGroupStatistics
(
ugc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query statistics: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec UserGroupStatistics"
)
}
...
...
@@ -120,14 +120,14 @@ func (ugc *UserGroupCacheType) syncUserGroups() error {
ugc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_user_groups"
)
.
Set
(
0
)
logger
.
Debug
(
"user_group not changed"
)
obs
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
dumper
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"not changed"
)
return
nil
}
lst
,
err
:=
models
.
UserGroupGetAll
(
ugc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query records: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec UserGroupGetAll"
)
}
...
...
@@ -139,7 +139,7 @@ func (ugc *UserGroupCacheType) syncUserGroups() error {
// fill user ids
members
,
err
:=
models
.
UserGroupMemberGetAll
(
ugc
.
ctx
)
if
err
!=
nil
{
obs
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query members: "
+
err
.
Error
())
dumper
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
-
1
,
-
1
,
"failed to query members: "
+
err
.
Error
())
return
errors
.
WithMessage
(
err
,
"failed to exec UserGroupMemberGetAll"
)
}
...
...
@@ -163,7 +163,7 @@ func (ugc *UserGroupCacheType) syncUserGroups() error {
ugc
.
stats
.
GaugeSyncNumber
.
WithLabelValues
(
"sync_user_groups"
)
.
Set
(
float64
(
len
(
m
)))
logger
.
Infof
(
"timer: sync user groups done, cost: %dms, number: %d"
,
ms
,
len
(
m
))
obs
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
dumper
.
PutSyncRecord
(
"user_groups"
,
start
.
Unix
(),
ms
,
len
(
m
),
"success"
)
return
nil
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录