[build] fix src/* imports (#27)
[build] fix src/* imports Co-authored-by: Kassian Sun <kassiansun@outlook.com>
This commit is contained in:
parent
34feba31a6
commit
fc8a47373a
|
@ -6,14 +6,15 @@ package alerting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
"infini.sh/console/model/alerting"
|
"infini.sh/console/model/alerting"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
"net/http"
|
|
||||||
log "src/github.com/cihub/seelog"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *AlertAPI) createChannel(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *AlertAPI) createChannel(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
@ -140,7 +141,7 @@ func (h *AlertAPI) deleteChannel(w http.ResponseWriter, req *http.Request, ps ht
|
||||||
}
|
}
|
||||||
|
|
||||||
h.WriteJSON(w, util.MapStr{
|
h.WriteJSON(w, util.MapStr{
|
||||||
"ids": reqBody.ChannelIDs ,
|
"ids": reqBody.ChannelIDs,
|
||||||
"result": "deleted",
|
"result": "deleted",
|
||||||
}, 200)
|
}, 200)
|
||||||
}
|
}
|
||||||
|
@ -148,7 +149,7 @@ func (h *AlertAPI) deleteChannel(w http.ResponseWriter, req *http.Request, ps ht
|
||||||
func (h *AlertAPI) searchChannel(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *AlertAPI) searchChannel(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||||
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
|
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
|
||||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||||
|
|
|
@ -5,13 +5,14 @@
|
||||||
package insight
|
package insight
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/insight"
|
"infini.sh/framework/core/insight"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
"net/http"
|
|
||||||
log "src/github.com/cihub/seelog"
|
|
||||||
"strconv"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *InsightAPI) createDashboard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *InsightAPI) createDashboard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
@ -145,10 +146,10 @@ func (h *InsightAPI) deleteDashboard(w http.ResponseWriter, req *http.Request, p
|
||||||
|
|
||||||
func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
var (
|
var (
|
||||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||||
clusterID = h.GetParameter(req, "cluster_id")
|
clusterID = h.GetParameter(req, "cluster_id")
|
||||||
)
|
)
|
||||||
size, _ := strconv.Atoi(strSize)
|
size, _ := strconv.Atoi(strSize)
|
||||||
if size <= 0 {
|
if size <= 0 {
|
||||||
|
@ -163,8 +164,8 @@ func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, p
|
||||||
if keyword != "" {
|
if keyword != "" {
|
||||||
must = append(must, util.MapStr{
|
must = append(must, util.MapStr{
|
||||||
"query_string": util.MapStr{
|
"query_string": util.MapStr{
|
||||||
"default_field":"*",
|
"default_field": "*",
|
||||||
"query": keyword,
|
"query": keyword,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,14 +6,15 @@ package insight
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
httprouter "infini.sh/framework/core/api/router"
|
httprouter "infini.sh/framework/core/api/router"
|
||||||
"infini.sh/framework/core/insight"
|
"infini.sh/framework/core/insight"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
"net/http"
|
|
||||||
log "src/github.com/cihub/seelog"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h *InsightAPI) createVisualization(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *InsightAPI) createVisualization(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
@ -131,7 +132,7 @@ func (h *InsightAPI) deleteVisualization(w http.ResponseWriter, req *http.Reques
|
||||||
func (h *InsightAPI) searchVisualization(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *InsightAPI) searchVisualization(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||||
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
|
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
|
||||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||||
|
|
|
@ -5,12 +5,13 @@
|
||||||
package alerting
|
package alerting
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
log "github.com/cihub/seelog"
|
||||||
"infini.sh/console/model/alerting"
|
"infini.sh/console/model/alerting"
|
||||||
"infini.sh/framework/core/orm"
|
"infini.sh/framework/core/orm"
|
||||||
"infini.sh/framework/core/task"
|
"infini.sh/framework/core/task"
|
||||||
"infini.sh/framework/core/util"
|
"infini.sh/framework/core/util"
|
||||||
log "src/github.com/cihub/seelog"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitTasks() error {
|
func InitTasks() error {
|
||||||
|
@ -36,10 +37,10 @@ func InitTasks() error {
|
||||||
}
|
}
|
||||||
eng := GetEngine(rule.Resource.Type)
|
eng := GetEngine(rule.Resource.Type)
|
||||||
task.RegisterScheduleTask(task.ScheduleTask{
|
task.RegisterScheduleTask(task.ScheduleTask{
|
||||||
ID: rule.ID,
|
ID: rule.ID,
|
||||||
Interval: rule.Schedule.Interval,
|
Interval: rule.Schedule.Interval,
|
||||||
Description: rule.Metrics.Expression,
|
Description: rule.Metrics.Expression,
|
||||||
Task: eng.GenerateTask(*rule),
|
Task: eng.GenerateTask(*rule),
|
||||||
})
|
})
|
||||||
task.StartTask(rule.ID)
|
task.StartTask(rule.ID)
|
||||||
}
|
}
|
||||||
|
@ -68,8 +69,8 @@ func getRuleLastTermTime() (map[string]time.Time, error) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
q := &orm.Query{
|
q := &orm.Query{
|
||||||
RawQuery: util.MustToJSONBytes(query),
|
RawQuery: util.MustToJSONBytes(query),
|
||||||
Size: 1000,
|
Size: 1000,
|
||||||
WildcardIndex: true,
|
WildcardIndex: true,
|
||||||
}
|
}
|
||||||
err, result := orm.Search(alerting.Alert{}, q)
|
err, result := orm.Search(alerting.Alert{}, q)
|
||||||
|
@ -93,5 +94,5 @@ func getRuleLastTermTime() (map[string]time.Time, error) {
|
||||||
|
|
||||||
type ruleTime struct {
|
type ruleTime struct {
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
RuleID string `json:"rule_id"`
|
RuleID string `json:"rule_id"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue