fixed merge master conflicts
This commit is contained in:
parent
3dedda4e62
commit
516e7462ac
|
@ -2,6 +2,7 @@
|
||||||
elasticsearch:
|
elasticsearch:
|
||||||
- id: $[[CLUSTER_ID]]
|
- id: $[[CLUSTER_ID]]
|
||||||
name: $[[CLUSTER_ID]]
|
name: $[[CLUSTER_ID]]
|
||||||
|
version: $[[CLUSTER_VER]]
|
||||||
enabled: true
|
enabled: true
|
||||||
monitored: true
|
monitored: true
|
||||||
reserved: true
|
reserved: true
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
path.configs: "config"
|
path.configs: "config"
|
||||||
|
configs.auto_reload: true
|
||||||
|
|
||||||
web:
|
web:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
19
main.go
19
main.go
|
@ -81,7 +81,7 @@ func main() {
|
||||||
module.RegisterSystemModule(&setup1.Module{})
|
module.RegisterSystemModule(&setup1.Module{})
|
||||||
module.RegisterSystemModule(uiModule)
|
module.RegisterSystemModule(uiModule)
|
||||||
|
|
||||||
var initFunc= func() {
|
if !global.Env().SetupRequired(){
|
||||||
module.RegisterSystemModule(&stats.SimpleStatsModule{})
|
module.RegisterSystemModule(&stats.SimpleStatsModule{})
|
||||||
module.RegisterSystemModule(&elastic2.ElasticModule{})
|
module.RegisterSystemModule(&elastic2.ElasticModule{})
|
||||||
module.RegisterSystemModule(&queue2.DiskQueue{})
|
module.RegisterSystemModule(&queue2.DiskQueue{})
|
||||||
|
@ -92,15 +92,10 @@ func main() {
|
||||||
module.RegisterSystemModule(&metrics.MetricsModule{})
|
module.RegisterSystemModule(&metrics.MetricsModule{})
|
||||||
module.RegisterSystemModule(&security.Module{})
|
module.RegisterSystemModule(&security.Module{})
|
||||||
module.RegisterSystemModule(&migration.MigrationModule{})
|
module.RegisterSystemModule(&migration.MigrationModule{})
|
||||||
}
|
|
||||||
|
|
||||||
if !global.Env().SetupRequired(){
|
|
||||||
initFunc()
|
|
||||||
}else{
|
}else{
|
||||||
for _, v := range modules {
|
for _, v := range modules {
|
||||||
v.Setup()
|
v.Setup()
|
||||||
}
|
}
|
||||||
setup1.RegisterSetupCallback(initFunc)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
api.RegisterAPI("")
|
api.RegisterAPI("")
|
||||||
|
@ -130,11 +125,7 @@ func main() {
|
||||||
module.Start()
|
module.Start()
|
||||||
|
|
||||||
var initFunc= func() {
|
var initFunc= func() {
|
||||||
if global.Env().SetupRequired() {
|
|
||||||
for _, v := range modules {
|
|
||||||
v.Start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
elastic2.InitTemplate(false)
|
elastic2.InitTemplate(false)
|
||||||
|
|
||||||
|
@ -153,6 +144,12 @@ func main() {
|
||||||
orm.RegisterSchemaWithIndexName(task1.Log{}, "task-log")
|
orm.RegisterSchemaWithIndexName(task1.Log{}, "task-log")
|
||||||
api.RegisterSchema()
|
api.RegisterSchema()
|
||||||
|
|
||||||
|
if global.Env().SetupRequired() {
|
||||||
|
for _, v := range modules {
|
||||||
|
v.Start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
task1.RunWithinGroup("initialize_alerting",func(ctx context.Context) error {
|
task1.RunWithinGroup("initialize_alerting",func(ctx context.Context) error {
|
||||||
err := alerting2.InitTasks()
|
err := alerting2.InitTasks()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -418,3 +418,53 @@ func (h *GatewayAPI) getExecutionNodes(w http.ResponseWriter, req *http.Request,
|
||||||
}
|
}
|
||||||
h.WriteJSON(w, nodes, http.StatusOK)
|
h.WriteJSON(w, nodes, http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *GatewayAPI) getExecutionNodesNew(w http.ResponseWriter, req *http.Request, ps httprouter.Params){
|
||||||
|
var (
|
||||||
|
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||||
|
strSize = h.GetParameterOrDefault(req, "size", "10")
|
||||||
|
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||||
|
)
|
||||||
|
size, _ := strconv.Atoi(strSize)
|
||||||
|
if size <= 0 {
|
||||||
|
size = 10
|
||||||
|
}
|
||||||
|
from, _ := strconv.Atoi(strFrom)
|
||||||
|
if from < 0 {
|
||||||
|
from = 0
|
||||||
|
}
|
||||||
|
query := util.MapStr{
|
||||||
|
"size": size,
|
||||||
|
"sort": []util.MapStr{
|
||||||
|
{
|
||||||
|
"created": util.MapStr{
|
||||||
|
"order": "desc",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"query": util.MapStr{
|
||||||
|
"bool": util.MapStr{
|
||||||
|
"must": []util.MapStr{
|
||||||
|
{
|
||||||
|
"term": util.MapStr{
|
||||||
|
"enrolled": util.MapStr{
|
||||||
|
"value": true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"term": util.MapStr{
|
||||||
|
"status": util.MapStr{
|
||||||
|
"value": "online",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
q := orm.Query{
|
||||||
|
RawQuery: util.MustToJSONBytes(query),
|
||||||
|
}
|
||||||
|
_ = q
|
||||||
|
}
|
|
@ -76,6 +76,11 @@ func GenerateQuery(metric *insight.Metric) (interface{}, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
targetESVersion := elastic.GetMetadata(metric.ClusterId).Config.Version
|
targetESVersion := elastic.GetMetadata(metric.ClusterId).Config.Version
|
||||||
|
|
||||||
|
if targetESVersion==""{
|
||||||
|
panic("invalid version")
|
||||||
|
}
|
||||||
|
|
||||||
intervalField, err := elastic.GetDateHistogramIntervalField(targetESVersion, metric.BucketSize)
|
intervalField, err := elastic.GetDateHistogramIntervalField(targetESVersion, metric.BucketSize)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get interval field error: %w", err)
|
return nil, fmt.Errorf("get interval field error: %w", err)
|
||||||
|
|
|
@ -80,6 +80,7 @@ type SetupRequest struct {
|
||||||
Password string `json:"password"`
|
Password string `json:"password"`
|
||||||
} `json:"cluster"`
|
} `json:"cluster"`
|
||||||
|
|
||||||
|
Skip bool `json:"skip"`
|
||||||
BootstrapUsername string `json:"bootstrap_username"`
|
BootstrapUsername string `json:"bootstrap_username"`
|
||||||
BootstrapPassword string `json:"bootstrap_password"`
|
BootstrapPassword string `json:"bootstrap_password"`
|
||||||
}
|
}
|
||||||
|
@ -249,15 +250,17 @@ func (module *Module) initTempClient(r *http.Request) (error, elastic.API,SetupR
|
||||||
|
|
||||||
cfg.ID = tempID
|
cfg.ID = tempID
|
||||||
cfg.Name = "INFINI_SYSTEM ("+util.PickRandomName()+")"
|
cfg.Name = "INFINI_SYSTEM ("+util.PickRandomName()+")"
|
||||||
elastic.InitMetadata(&cfg, true)
|
|
||||||
client, err := elastic1.InitClientWithConfig(cfg)
|
client, err := elastic1.InitClientWithConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err,nil,request
|
return err,nil,request
|
||||||
}
|
}
|
||||||
|
cfg.Version=client.GetVersion()
|
||||||
|
meta:=elastic.InitMetadata(&cfg, true)
|
||||||
|
meta.Config.Version=cfg.Version
|
||||||
|
elastic.SetMetadata(tempID,meta)
|
||||||
elastic.UpdateConfig(cfg)
|
elastic.UpdateConfig(cfg)
|
||||||
elastic.UpdateClient(cfg, client)
|
elastic.UpdateClient(cfg, client)
|
||||||
cfg.Version=client.GetVersion()
|
|
||||||
global.Register(elastic.GlobalSystemElasticsearchID,tempID)
|
global.Register(elastic.GlobalSystemElasticsearchID,tempID)
|
||||||
|
|
||||||
return err, client,request
|
return err, client,request
|
||||||
|
@ -336,6 +339,7 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
||||||
handler := elastic2.ElasticORM{Client: client, Config:cfg1 }
|
handler := elastic2.ElasticORM{Client: client, Config:cfg1 }
|
||||||
orm.Register("elastic_setup_"+util.GetUUID(), handler)
|
orm.Register("elastic_setup_"+util.GetUUID(), handler)
|
||||||
|
|
||||||
|
if !request.Skip{
|
||||||
//处理模版
|
//处理模版
|
||||||
elastic2.InitTemplate(true)
|
elastic2.InitTemplate(true)
|
||||||
|
|
||||||
|
@ -388,7 +392,6 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//处理索引
|
//处理索引
|
||||||
elastic2.InitSchema()
|
elastic2.InitSchema()
|
||||||
//init security
|
//init security
|
||||||
|
@ -426,27 +429,28 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//save to local file
|
|
||||||
file:=path.Join(global.Env().GetConfigDir(),"system_config.yml")
|
|
||||||
_,err=util.FilePutContent(file,fmt.Sprintf("configs.template:\n - name: \"system\"\n path: ./config/system_config.tpl\n variable:\n " +
|
|
||||||
"CLUSTER_ID: %v\n CLUSTER_ENDPINT: \"%v\"\n " +
|
|
||||||
"CLUSTER_USER: \"%v\"\n CLUSTER_PASS: \"%v\"\n INDEX_PREFIX: \"%v\"",
|
|
||||||
tempID,cfg.Endpoint,cfg.BasicAuth.Username,cfg.BasicAuth.Password,cfg1.IndexPrefix ))
|
|
||||||
if err!=nil{
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
//处理 ILM
|
|
||||||
|
|
||||||
//callback
|
|
||||||
InvokeSetupCallback()
|
|
||||||
|
|
||||||
//disable builtin auth
|
//disable builtin auth
|
||||||
err=api.DisableBuiltinUserAdmin()
|
err=api.DisableBuiltinUserAdmin()
|
||||||
if err!=nil{
|
if err!=nil{
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//save to local file
|
||||||
|
file:=path.Join(global.Env().GetConfigDir(),"system_config.yml")
|
||||||
|
_,err=util.FilePutContent(file,fmt.Sprintf("configs.template:\n - name: \"system\"\n path: ./config/system_config.tpl\n variable:\n " +
|
||||||
|
"CLUSTER_ID: %v\n CLUSTER_ENDPINT: \"%v\"\n " +
|
||||||
|
"CLUSTER_USER: \"%v\"\n CLUSTER_PASS: \"%v\"\n CLUSTER_VER: \"%v\"\n INDEX_PREFIX: \"%v\"",
|
||||||
|
tempID,cfg.Endpoint,cfg.BasicAuth.Username,cfg.BasicAuth.Password,cfg.Version,cfg1.IndexPrefix ))
|
||||||
|
if err!=nil{
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//callback
|
||||||
|
InvokeSetupCallback()
|
||||||
|
|
||||||
//place setup lock file
|
//place setup lock file
|
||||||
setupLock:=path.Join(global.Env().GetDataDir(),".setup_lock")
|
setupLock:=path.Join(global.Env().GetDataDir(),".setup_lock")
|
||||||
_,err=util.FilePutContent(setupLock,time.Now().String())
|
_,err=util.FilePutContent(setupLock,time.Now().String())
|
||||||
|
|
|
@ -62,6 +62,11 @@ func (engine *Engine) GenerateQuery(rule *alerting.Rule, filterParam *alerting.F
|
||||||
if filterParam != nil && filterParam.BucketSize != "" {
|
if filterParam != nil && filterParam.BucketSize != "" {
|
||||||
periodInterval = filterParam.BucketSize
|
periodInterval = filterParam.BucketSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if targetESVersion==""{
|
||||||
|
panic("invalid version")
|
||||||
|
}
|
||||||
|
|
||||||
intervalField, err := elastic.GetDateHistogramIntervalField(targetESVersion, periodInterval )
|
intervalField, err := elastic.GetDateHistogramIntervalField(targetESVersion, periodInterval )
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("get interval field error: %w", err)
|
return nil, fmt.Errorf("get interval field error: %w", err)
|
||||||
|
|
Loading…
Reference in New Issue