feat: log activity for cluster metric collection mode changes (#152)
* feat: log activity for cluster metric collection mode changes * chore: update release notes
This commit is contained in:
parent
932a2a46e1
commit
78cdd44e9c
|
@ -30,6 +30,7 @@ Information about release notes of INFINI Console is provided here.
|
||||||
### Features
|
### Features
|
||||||
- Support alerts based on bucket diff state (#119)
|
- Support alerts based on bucket diff state (#119)
|
||||||
- Add rollup ilm when use Easysearch (#128)
|
- Add rollup ilm when use Easysearch (#128)
|
||||||
|
- Log activity for cluster metric collection mode changes (#152)
|
||||||
|
|
||||||
### Bug fix
|
### Bug fix
|
||||||
- Fixed missing data when processing multiple time series in a group with insight data API (#127)
|
- Fixed missing data when processing multiple time series in a group with insight data API (#127)
|
||||||
|
|
|
@ -30,6 +30,7 @@ title: "版本历史"
|
||||||
### Features
|
### Features
|
||||||
- 告警功能支持根据桶之间文档数差值和内容差异告警 (#119)
|
- 告警功能支持根据桶之间文档数差值和内容差异告警 (#119)
|
||||||
- 当使用 Easysearch 存储指标时,增加 Rollup 索引生命周期 (#128)
|
- 当使用 Easysearch 存储指标时,增加 Rollup 索引生命周期 (#128)
|
||||||
|
- 增加集群指标采集模式变更事件 (#152)
|
||||||
|
|
||||||
### Bug fix
|
### Bug fix
|
||||||
- 修复 Insight API 处理多时间序列数据时数据丢失的问题 (#127)
|
- 修复 Insight API 处理多时间序列数据时数据丢失的问题 (#127)
|
||||||
|
|
|
@ -27,6 +27,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"infini.sh/framework/core/queue"
|
||||||
"math"
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -107,6 +108,9 @@ func (h *APIHandler) HandleCreateClusterAction(w http.ResponseWriter, req *http.
|
||||||
if conf.Distribution == "" {
|
if conf.Distribution == "" {
|
||||||
conf.Distribution = elastic.Elasticsearch
|
conf.Distribution = elastic.Elasticsearch
|
||||||
}
|
}
|
||||||
|
if conf.MetricCollectionMode == "" {
|
||||||
|
conf.MetricCollectionMode = elastic.ModeAgentless
|
||||||
|
}
|
||||||
err = orm.Create(ctx, conf)
|
err = orm.Create(ctx, conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
|
@ -183,6 +187,7 @@ func (h *APIHandler) HandleUpdateClusterAction(w http.ResponseWriter, req *http.
|
||||||
h.Error404(w)
|
h.Error404(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
var oldCollectionMode = originConf.MetricCollectionMode
|
||||||
buf := util.MustToJSONBytes(originConf)
|
buf := util.MustToJSONBytes(originConf)
|
||||||
source := map[string]interface{}{}
|
source := map[string]interface{}{}
|
||||||
util.MustFromJSONBytes(buf, &source)
|
util.MustFromJSONBytes(buf, &source)
|
||||||
|
@ -255,7 +260,10 @@ func (h *APIHandler) HandleUpdateClusterAction(w http.ResponseWriter, req *http.
|
||||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// record cluster metric collection mode change activity
|
||||||
|
if oldCollectionMode != newConf.MetricCollectionMode {
|
||||||
|
recordCollectionModeChangeActivity(newConf.ID, newConf.Name, oldCollectionMode, newConf.MetricCollectionMode)
|
||||||
|
}
|
||||||
basicAuth, err := common.GetBasicAuth(newConf)
|
basicAuth, err := common.GetBasicAuth(newConf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
h.WriteError(w, err.Error(), http.StatusInternalServerError)
|
||||||
|
@ -273,6 +281,47 @@ func (h *APIHandler) HandleUpdateClusterAction(w http.ResponseWriter, req *http.
|
||||||
h.WriteUpdatedOKJSON(w, id)
|
h.WriteUpdatedOKJSON(w, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func recordCollectionModeChangeActivity(clusterID, clusterName, oldMode, newMode string) {
|
||||||
|
activityInfo := &event.Activity{
|
||||||
|
ID: util.GetUUID(),
|
||||||
|
Timestamp: time.Now(),
|
||||||
|
Metadata: event.ActivityMetadata{
|
||||||
|
Category: "elasticsearch",
|
||||||
|
Group: "platform",
|
||||||
|
Name: "metric_collection_mode_change",
|
||||||
|
Type: "update",
|
||||||
|
Labels: util.MapStr{
|
||||||
|
"cluster_id": clusterID,
|
||||||
|
"cluster_name": clusterName,
|
||||||
|
"from": oldMode,
|
||||||
|
"to": newMode,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
queueConfig := queue.GetOrInitConfig("platform##activities")
|
||||||
|
if queueConfig.Labels == nil {
|
||||||
|
queueConfig.ReplaceLabels(util.MapStr{
|
||||||
|
"type": "platform",
|
||||||
|
"name": "activity",
|
||||||
|
"category": "elasticsearch",
|
||||||
|
"activity": true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
err := queue.Push(queueConfig, util.MustToJSONBytes(event.Event{
|
||||||
|
Timestamp: time.Now(),
|
||||||
|
Metadata: event.EventMetadata{
|
||||||
|
Category: "elasticsearch",
|
||||||
|
Name: "activity",
|
||||||
|
},
|
||||||
|
Fields: util.MapStr{
|
||||||
|
"activity": activityInfo,
|
||||||
|
}}))
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (h *APIHandler) HandleDeleteClusterAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
func (h *APIHandler) HandleDeleteClusterAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
|
||||||
resBody := map[string]interface{}{}
|
resBody := map[string]interface{}{}
|
||||||
id := ps.MustGetParameter("id")
|
id := ps.MustGetParameter("id")
|
||||||
|
|
|
@ -234,6 +234,20 @@ export default (props) => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
case "metric_collection_mode_change":
|
||||||
|
if (type == "update") {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
metric collection mode of cluster{" "}
|
||||||
|
<Link
|
||||||
|
to={`/resource/cluster/${hit._source.metadata.labels.cluster_id}/edit`}
|
||||||
|
>
|
||||||
|
{hit._source.metadata.labels.cluster_name}
|
||||||
|
</Link>{" "}
|
||||||
|
was <b>changed from {hit._source.metadata.labels.from} to {hit._source.metadata.labels.to}</b>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return <></>;
|
return <></>;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue