update overview api

This commit is contained in:
liugq 2022-02-16 10:34:32 +08:00
parent e1559b0e85
commit dd6edb7c2b
1 changed files with 28 additions and 6 deletions

View File

@ -25,14 +25,14 @@ func (handler APIHandler) ElasticsearchOverviewAction(w http.ResponseWriter, req
if err != nil{ if err != nil{
log.Error(err) log.Error(err)
} }
val, err := data.GetValue("cluster_stats.nodes.count.total") val, err := data.GetValue("payload.elasticsearch.cluster_stats.nodes.count.total")
if err != nil { if err != nil {
log.Warn(err) log.Warn(err)
} }
if num, ok := val.(float64); ok { if num, ok := val.(float64); ok {
totalNode += int(num) totalNode += int(num)
} }
val, err = data.GetValue("index_stats._all.total.store.size_in_bytes") val, err = data.GetValue("payload.elasticsearch.cluster_stats.indices.store.size_in_bytes")
if err != nil { if err != nil {
log.Warn(err) log.Warn(err)
} }
@ -63,14 +63,36 @@ func (handler APIHandler) getLatestClusterMonitorData(clusterID interface{}) (ut
client := elastic.GetClient(handler.Config.Elasticsearch) client := elastic.GetClient(handler.Config.Elasticsearch)
queryDSLTpl := `{ queryDSLTpl := `{
"size": 1, "size": 1,
"query": { "query": {
"match": { "bool": {
"elasticsearch": "%s" "must": [
{
"term": {
"metadata.labels.cluster_id": {
"value": "%s"
}
}
},
{
"term": {
"metadata.name": {
"value": "cluster_stats"
}
}
},
{
"term": {
"metadata.category": {
"value": "elasticsearch"
}
}
}
]
} }
}, },
"sort": [ "sort": [
{ {
"cluster_stats.timestamp": { "timestamp": {
"order": "desc" "order": "desc"
} }
} }