update for metric monitoring

This commit is contained in:
medcl 2021-03-31 13:29:33 +08:00
parent b9781eb545
commit 6af35863fb
5 changed files with 19 additions and 4 deletions

View File

@ -39,7 +39,7 @@ func (handler APIHandler) HandleGetMappingsAction(w http.ResponseWriter, req *ht
func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) { func (handler APIHandler) HandleGetIndicesAction(w http.ResponseWriter, req *http.Request, ps httprouter.Params) {
client := elastic.GetClient(handler.Config.Elasticsearch) client := elastic.GetClient(handler.Config.Elasticsearch)
catIndices, err := client.GetIndices() catIndices, err := client.GetIndices("")
for key, _ := range *catIndices { for key, _ := range *catIndices {
if strings.HasPrefix(key,".") || strings.HasPrefix(key, "infini-"){ if strings.HasPrefix(key,".") || strings.HasPrefix(key, "infini-"){
delete(*catIndices, key) delete(*catIndices, key)
@ -130,4 +130,4 @@ func (handler APIHandler) HandleCreateIndexAction(w http.ResponseWriter, req *ht
} }
resBody["payload"] = true resBody["payload"] = true
handler.WriteJSON(w, resBody, http.StatusOK) handler.WriteJSON(w, resBody, http.StatusOK)
} }

View File

@ -4,7 +4,6 @@ import (
"errors" "errors"
_ "expvar" _ "expvar"
"infini.sh/framework" "infini.sh/framework"
"infini.sh/framework/core/elastic"
"infini.sh/framework/core/env" "infini.sh/framework/core/env"
"infini.sh/framework/core/module" "infini.sh/framework/core/module"
"infini.sh/framework/core/orm" "infini.sh/framework/core/orm"
@ -71,7 +70,6 @@ func main() {
}, func() { }, func() {
orm.RegisterSchemaWithIndexName(model.Dict{}, "dict") orm.RegisterSchemaWithIndexName(model.Dict{}, "dict")
orm.RegisterSchemaWithIndexName(model.Reindex{}, "reindex") orm.RegisterSchemaWithIndexName(model.Reindex{}, "reindex")
orm.RegisterSchemaWithIndexName(elastic.ElasticsearchConfig{}, "cluster")
}) })
} }

View File

@ -23,6 +23,8 @@ modules:
enabled: true enabled: true
store: store:
enabled: true enabled: true
monitoring:
enabled: true
orm: orm:
enabled: true enabled: true
init_template: true init_template: true

View File

@ -22,6 +22,7 @@ export default {
"created": "2021-02-20T16:03:30.867084+08:00", "created": "2021-02-20T16:03:30.867084+08:00",
"description": "xx业务集群1", "description": "xx业务集群1",
"enabled": true, "enabled": true,
"monitored": true,
"endpoint": "http://localhost:9200", "endpoint": "http://localhost:9200",
"name": "cluster1", "name": "cluster1",
"updated": "2021-02-20T16:03:30.867084+08:00" "updated": "2021-02-20T16:03:30.867084+08:00"
@ -39,6 +40,7 @@ export default {
"created": "2021-02-20T16:03:30.867084+08:00", "created": "2021-02-20T16:03:30.867084+08:00",
"description": "xx业务集群2", "description": "xx业务集群2",
"enabled": true, "enabled": true,
"monitored": true,
"endpoint": "http://localhost:9201", "endpoint": "http://localhost:9201",
"name": "cluster2", "name": "cluster2",
"updated": "2021-02-20T16:03:30.867084+08:00" "updated": "2021-02-20T16:03:30.867084+08:00"
@ -71,6 +73,7 @@ export default {
"created": "2021-02-20T16:03:30.867084+08:00", "created": "2021-02-20T16:03:30.867084+08:00",
"description": "xx业务集群1", "description": "xx业务集群1",
"enabled": false, "enabled": false,
"monitored": true,
"endpoint": "http://localhost:9200", "endpoint": "http://localhost:9200",
"name": "cluster1", "name": "cluster1",
"updated": "2021-02-20T16:03:30.867084+08:00" "updated": "2021-02-20T16:03:30.867084+08:00"
@ -92,6 +95,7 @@ export default {
}, },
"description": "xx业务集群1", "description": "xx业务集群1",
"enabled": false, "enabled": false,
"monitored": true,
"created": "2021-02-20T15:12:50.984062+08:00", "created": "2021-02-20T15:12:50.984062+08:00",
"updated": "2021-02-20T15:12:50.984062+08:00" "updated": "2021-02-20T15:12:50.984062+08:00"
}, },
@ -110,6 +114,7 @@ export default {
"endpoint": "http://localhost:9201", "endpoint": "http://localhost:9201",
"name": "cluster2", "name": "cluster2",
"enabled": true, "enabled": true,
"monitored": true,
"updated": "2021-02-20T15:25:12.159789+08:00" "updated": "2021-02-20T15:25:12.159789+08:00"
}, },
"result": "updated" "result": "updated"

View File

@ -59,6 +59,7 @@ class ClusterForm extends React.Component{
}, },
description: values.description, description: values.description,
enabled: values.enabled, enabled: values.enabled,
monitored: values.monitored,
order: values.order, order: values.order,
} }
if(clusterConfig.editMode === 'NEW') { if(clusterConfig.editMode === 'NEW') {
@ -193,6 +194,15 @@ class ClusterForm extends React.Component{
unCheckedChildren={<Icon type="close" />} unCheckedChildren={<Icon type="close" />}
/>)} />)}
</Form.Item> </Form.Item>
<Form.Item label="启用监控">
{getFieldDecorator('monitored', {
valuePropName: 'checked',
initialValue: typeof editValue.monitored === 'undefined' ? true: editValue.monitored,
})(<Switch
checkedChildren={<Icon type="check" />}
unCheckedChildren={<Icon type="close" />}
/>)}
</Form.Item>
<Form.Item {...tailFormItemLayout}> <Form.Item {...tailFormItemLayout}>
<Button type="primary" onClick={this.handleSubmit}> <Button type="primary" onClick={this.handleSubmit}>
{editMode === 'NEW' ? 'Register': 'Save'} {editMode === 'NEW' ? 'Register': 'Save'}