| | |
| | | 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":{ |
| | |
| | | } |
| | | }` |
| | | buf, err := EsReq("POST",url,[]byte(DSLJson)) |
| | | if err != nil { |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | var info interface{} |
| | |
| | | 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!") |
| | |
| | | } |
| | | 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 |
| | | } |