Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DiDi
nightingale
提交
a338b523
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 搜索 >>
提交
a338b523
编写于
6月 25, 2023
作者:
N
ning
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
code refactor
上级
ad26225f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
25 addition
and
20 deletion
+25
-20
center/center.go
center/center.go
+2
-1
models/migrate/migrate.go
models/migrate/migrate.go
+5
-1
models/recording_rule.go
models/recording_rule.go
+18
-18
未找到文件。
center/center.go
浏览文件 @
a338b523
...
...
@@ -13,6 +13,7 @@ import (
"github.com/ccfos/nightingale/v6/conf"
"github.com/ccfos/nightingale/v6/memsto"
"github.com/ccfos/nightingale/v6/models"
"github.com/ccfos/nightingale/v6/models/migrate"
"github.com/ccfos/nightingale/v6/pkg/ctx"
"github.com/ccfos/nightingale/v6/pkg/httpx"
"github.com/ccfos/nightingale/v6/pkg/i18nx"
...
...
@@ -49,7 +50,7 @@ func Initialize(configDir string, cryptoKey string) (func(), error) {
}
ctx
:=
ctx
.
NewContext
(
context
.
Background
(),
db
,
true
)
models
.
InitRoot
(
ctx
)
m
odels
.
Migrate
(
db
)
m
igrate
.
Migrate
(
db
)
redis
,
err
:=
storage
.
NewRedis
(
config
.
Redis
)
if
err
!=
nil
{
...
...
models/migrate.go
→
models/migrate
/migrate
.go
浏览文件 @
a338b523
package
m
odels
package
m
igrate
import
(
"github.com/toolkits/pkg/logger"
...
...
@@ -9,6 +9,10 @@ func Migrate(db *gorm.DB) {
MigrateRecordingTable
(
db
)
}
type
RecordingRule
struct
{
QueryConfigs
string
`gorm:"type:text;not null;column:query_configs"`
// query_configs
}
func
MigrateRecordingTable
(
db
*
gorm
.
DB
)
error
{
err
:=
db
.
AutoMigrate
(
&
RecordingRule
{})
if
err
!=
nil
{
...
...
models/recording_rule.go
浏览文件 @
a338b523
...
...
@@ -16,24 +16,24 @@ import (
// A RecordingRule records its vector expression into new timeseries.
type
RecordingRule
struct
{
Id
int64
`json:"id" gorm:"primary
_key;auto_increment;column:id
"`
GroupId
int64
`json:"group_id"
gorm:"type:bigint;not null;default:0;column:group_id"`
// busi group id
DatasourceIds
string
`json:"-" gorm:"
type:varchar(255);not null;default:'';column:datasource_ids"`
// datasource ids
DatasourceIdsJson
[]
int64
`json:"datasource_ids" gorm:"-"`
// for fe
Cluster
string
`json:"cluster"
gorm:"type:varchar(128);not null;column:cluster"`
// take effect by cluster, seperated by space
Name
string
`json:"name"
gorm:"type:varchar(255);not null;column:name"
`
// new metric name
Disabled
int
`json:"disabled"
gorm:"type:varchar(255);not null;column:note"
`
// 0: enabled, 1: disabled
PromQl
string
`json:"prom_ql"
gorm:"type:varchar(8192);not null;column:prom_ql"`
// just one ql for promql
QueryConfigs
string
`json:"-" gorm:"
type:text;not null;column:query_configs"`
// query_configs
QueryConfigsJson
[]
QueryConfig
`json:"query_configs" gorm:"-"`
// query_configs for fe
PromEvalInterval
int
`json:"prom_eval_interval"
gorm:"type:int;not null;column:prom_eval_interval"`
// unit:s
AppendTags
string
`json:"-"
gorm:"type:varchar(255);default:'';column:append_tags"`
// split by space: service=n9e mod=api
AppendTagsJSON
[]
string
`json:"append_tags" gorm:"-"`
// for fe
Note
string
`json:"note"
gorm:"type:varchar(255);not null;column:note"
`
// note
CreateAt
int64
`json:"create_at"
gorm:"type:bigint;default:0;column:create_at"
`
CreateBy
string
`json:"create_by"
gorm:"type:varchar(64);default:'';column:create_by"
`
UpdateAt
int64
`json:"update_at"
gorm:"type:bigint;default:0;column:update_at"
`
UpdateBy
string
`json:"update_by"
gorm:"type:varchar(64);default:'';column:update_by"
`
Id
int64
`json:"id" gorm:"primary
Key
"`
GroupId
int64
`json:"group_id"
`
// busi group id
DatasourceIds
string
`json:"-" gorm:"
datasource_ids"`
// datasource ids
DatasourceIdsJson
[]
int64
`json:"datasource_ids" gorm:"-"`
// for fe
Cluster
string
`json:"cluster"
`
// take effect by cluster, seperated by space
Name
string
`json:"name"`
// new metric name
Disabled
int
`json:"disabled"`
// 0: enabled, 1: disabled
PromQl
string
`json:"prom_ql"
`
// just one ql for promql
QueryConfigs
string
`json:"-" gorm:"
query_configs"`
// query_configs
QueryConfigsJson
[]
QueryConfig
`json:"query_configs" gorm:"-"`
// query_configs for fe
PromEvalInterval
int
`json:"prom_eval_interval"
`
// unit:s
AppendTags
string
`json:"-"
`
// split by space: service=n9e mod=api
AppendTagsJSON
[]
string
`json:"append_tags" gorm:"-"`
// for fe
Note
string
`json:"note"`
// note
CreateAt
int64
`json:"create_at"`
CreateBy
string
`json:"create_by"`
UpdateAt
int64
`json:"update_at"`
UpdateBy
string
`json:"update_by"`
}
type
QueryConfig
struct
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录