sunty
2019-09-29 5b358a37ddfe575d4f7e9e29c4d2c36bc592d0cc
fix EsApi
1个文件已修改
17 ■■■■ 已修改文件
EsApi.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
EsApi.go
@@ -622,9 +622,9 @@
    return total,nil
}
//实时报警任务比率
func RealTimeAlarmTaskRate(serverIp string, serverPort string,indexName string) (sources map[string]int,err error){
func RealTimeAlarmTaskRate(serverIp string, serverPort string) (sources []map[string]interface{},err error){
    url := "http://" + serverIp + ":" + serverPort +
        "/"+indexName+"/_search"
        "/videopersons,personaction/_search"
    DSLJson := `{
    "size":0,
    "query":{
@@ -664,8 +664,9 @@
    if !ok {
        return nil, errors.New("first hits change error!")
    }
    var source = make(map[string]int,0)
    for _, in := range sdkName_status["buckets"].([]interface{}){
        var source = make(map[string]interface{},0)
        tmpbuf, ok := in.(map[string]interface{})
        if !ok {
            fmt.Println("change to source error!")
@@ -673,10 +674,10 @@
        }
        sdkName := tmpbuf["key"].(string)
        count := int(tmpbuf["doc_count"].(float64))
        source[sdkName] = count
        //fmt.Println("in",in)
        //sources[in["key"].(string)] = int(in["doc_count"].(float64))
        source["name"] = sdkName
        source["value"] = count
        sources = append(sources, source)
    }
    //fmt.Println("sources",source)
    return source,nil
    //fmt.Println("tmpSource",sources)
    return sources,nil
}