[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 (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
log "github.com/cihub/seelog"
|
||||
"infini.sh/console/model/alerting"
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"infini.sh/framework/core/orm"
|
||||
"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) {
|
||||
|
@ -140,7 +141,7 @@ func (h *AlertAPI) deleteChannel(w http.ResponseWriter, req *http.Request, ps ht
|
|||
}
|
||||
|
||||
h.WriteJSON(w, util.MapStr{
|
||||
"ids": reqBody.ChannelIDs ,
|
||||
"ids": reqBody.ChannelIDs,
|
||||
"result": "deleted",
|
||||
}, 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) {
|
||||
|
||||
var (
|
||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
|
||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||
|
|
|
@ -5,13 +5,14 @@
|
|||
package insight
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
log "github.com/cihub/seelog"
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"infini.sh/framework/core/insight"
|
||||
"infini.sh/framework/core/orm"
|
||||
"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) {
|
||||
|
@ -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) {
|
||||
var (
|
||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||
clusterID = h.GetParameter(req, "cluster_id")
|
||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||
clusterID = h.GetParameter(req, "cluster_id")
|
||||
)
|
||||
size, _ := strconv.Atoi(strSize)
|
||||
if size <= 0 {
|
||||
|
@ -163,8 +164,8 @@ func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, p
|
|||
if keyword != "" {
|
||||
must = append(must, util.MapStr{
|
||||
"query_string": util.MapStr{
|
||||
"default_field":"*",
|
||||
"query": keyword,
|
||||
"default_field": "*",
|
||||
"query": keyword,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -199,4 +200,4 @@ func (h *InsightAPI) searchDashboard(w http.ResponseWriter, req *http.Request, p
|
|||
return
|
||||
}
|
||||
h.Write(w, res.Raw)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,15 @@ package insight
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
log "github.com/cihub/seelog"
|
||||
httprouter "infini.sh/framework/core/api/router"
|
||||
"infini.sh/framework/core/insight"
|
||||
"infini.sh/framework/core/orm"
|
||||
"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) {
|
||||
|
@ -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) {
|
||||
|
||||
var (
|
||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||
keyword = h.GetParameterOrDefault(req, "keyword", "")
|
||||
queryDSL = `{"query":{"bool":{"must":[%s]}}, "size": %d, "from": %d}`
|
||||
strSize = h.GetParameterOrDefault(req, "size", "20")
|
||||
strFrom = h.GetParameterOrDefault(req, "from", "0")
|
||||
|
@ -160,4 +161,4 @@ func (h *InsightAPI) searchVisualization(w http.ResponseWriter, req *http.Reques
|
|||
return
|
||||
}
|
||||
h.Write(w, res.Raw)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,12 +5,13 @@
|
|||
package alerting
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
log "github.com/cihub/seelog"
|
||||
"infini.sh/console/model/alerting"
|
||||
"infini.sh/framework/core/orm"
|
||||
"infini.sh/framework/core/task"
|
||||
"infini.sh/framework/core/util"
|
||||
log "src/github.com/cihub/seelog"
|
||||
"time"
|
||||
)
|
||||
|
||||
func InitTasks() error {
|
||||
|
@ -36,10 +37,10 @@ func InitTasks() error {
|
|||
}
|
||||
eng := GetEngine(rule.Resource.Type)
|
||||
task.RegisterScheduleTask(task.ScheduleTask{
|
||||
ID: rule.ID,
|
||||
Interval: rule.Schedule.Interval,
|
||||
ID: rule.ID,
|
||||
Interval: rule.Schedule.Interval,
|
||||
Description: rule.Metrics.Expression,
|
||||
Task: eng.GenerateTask(*rule),
|
||||
Task: eng.GenerateTask(*rule),
|
||||
})
|
||||
task.StartTask(rule.ID)
|
||||
}
|
||||
|
@ -68,8 +69,8 @@ func getRuleLastTermTime() (map[string]time.Time, error) {
|
|||
},
|
||||
}
|
||||
q := &orm.Query{
|
||||
RawQuery: util.MustToJSONBytes(query),
|
||||
Size: 1000,
|
||||
RawQuery: util.MustToJSONBytes(query),
|
||||
Size: 1000,
|
||||
WildcardIndex: true,
|
||||
}
|
||||
err, result := orm.Search(alerting.Alert{}, q)
|
||||
|
@ -93,5 +94,5 @@ func getRuleLastTermTime() (map[string]time.Time, error) {
|
|||
|
||||
type ruleTime struct {
|
||||
Created time.Time `json:"created"`
|
||||
RuleID string `json:"rule_id"`
|
||||
RuleID string `json:"rule_id"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue