update cluster api, add metrics page

This commit is contained in:
medcl 2021-02-22 23:33:27 +08:00
parent ca177ebfb9
commit 0015bd49b1
10 changed files with 4604 additions and 42 deletions

View File

@ -1,13 +1,14 @@
package api
import (
log "github.com/cihub/seelog"
"infini.sh/framework/core/api"
"infini.sh/framework/core/task"
"infini.sh/framework/core/ui"
"infini.sh/search-center/api/index_management"
"infini.sh/search-center/api/system"
"infini.sh/search-center/config"
log "github.com/cihub/seelog"
"path"
)
func Init(cfg *config.AppConfig) {
@ -16,27 +17,26 @@ func Init(cfg *config.AppConfig) {
}
var pathPrefix = "/_search-center/"
//ui.HandleUIMethod(api.POST, "/api/get_indices",index_management.API1)
ui.HandleUIMethod(api.GET, pathPrefix+"dict/_search", handler.GetDictListAction)
ui.HandleUIMethod(api.POST, pathPrefix+"dict/*id", handler.CreateDictItemAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "dict/_search"), handler.GetDictListAction)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "dict/*id"), handler.CreateDictItemAction)
//ui.HandleUIMethod(api.GET, "/api/dict/:id",handler.GetDictItemAction)
ui.HandleUIMethod(api.DELETE, pathPrefix+"dict/:id", handler.DeleteDictItemAction)
ui.HandleUIMethod(api.PUT, pathPrefix+"dict/:id", handler.UpdateDictItemAction)
ui.HandleUIMethod(api.POST, pathPrefix+"doc/:index/_search", handler.HandleSearchDocumentAction)
ui.HandleUIMethod(api.POST, pathPrefix+"doc/:index/_create", handler.HandleAddDocumentAction)
ui.HandleUIMethod(api.PUT, pathPrefix+"doc/:index/:id", handler.HandleUpdateDocumentAction)
ui.HandleUIMethod(api.DELETE, pathPrefix+"doc/:index/:id", handler.HandleDeleteDocumentAction)
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "dict/:id"), handler.DeleteDictItemAction)
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "dict/:id"), handler.UpdateDictItemAction)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "doc/:index/_search"), handler.HandleSearchDocumentAction)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "doc/:index/_create"), handler.HandleAddDocumentAction)
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "doc/:index/:id"), handler.HandleUpdateDocumentAction)
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "doc/:index/:id"), handler.HandleDeleteDocumentAction)
ui.HandleUIMethod(api.POST, pathPrefix+"rebuild/*id", handler.HandleReindexAction)
ui.HandleUIMethod(api.GET, pathPrefix+"rebuild/_search", handler.HandleGetRebuildListAction)
ui.HandleUIMethod(api.DELETE, pathPrefix+"rebuild/:id", handler.HandleDeleteRebuildAction)
ui.HandleUIMethod(api.GET, pathPrefix+"_cat/indices", handler.HandleGetIndicesAction)
ui.HandleUIMethod(api.GET, pathPrefix+"index/:index/_mappings", handler.HandleGetMappingsAction)
ui.HandleUIMethod(api.GET, pathPrefix+"index/:index/_settings", handler.HandleGetSettingsAction)
ui.HandleUIMethod(api.PUT, pathPrefix+"index/:index/_settings", handler.HandleUpdateSettingsAction)
ui.HandleUIMethod(api.DELETE, pathPrefix+"index/:index", handler.HandleDeleteIndexAction)
ui.HandleUIMethod(api.POST, pathPrefix+"index/:index", handler.HandleCreateIndexAction)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "rebuild/*id"), handler.HandleReindexAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "rebuild/_search"), handler.HandleGetRebuildListAction)
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "rebuild/:id"), handler.HandleDeleteRebuildAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "_cat/indices"), handler.HandleGetIndicesAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "index/:index/_mappings"), handler.HandleGetMappingsAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "index/:index/_settings"), handler.HandleGetSettingsAction)
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "index/:index/_settings"), handler.HandleUpdateSettingsAction)
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "index/:index"), handler.HandleDeleteIndexAction)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "index/:index"), handler.HandleCreateIndexAction)
ui.HandleUIMethod(api.GET, pathPrefix+"cluster/:cluster/version", handler.GetClusterVersion)
task.RegisterScheduleTask(task.ScheduleTask{
Description: "sync reindex task result",
@ -51,10 +51,10 @@ func Init(cfg *config.AppConfig) {
shdl := system.APIHandler{
Config: cfg,
}
ui.HandleUIMethod(api.POST, pathPrefix + "system/cluster", shdl.HandleCreateClusterAction)
ui.HandleUIMethod(api.PUT, pathPrefix + "system/cluster/:id", shdl.HandleUpdateClusterAction)
ui.HandleUIMethod(api.DELETE, pathPrefix + "system/cluster/:id", shdl.HandleDeleteClusterAction)
ui.HandleUIMethod(api.GET, pathPrefix + "system/cluster/_search", shdl.HandleSearchClusterAction)
ui.HandleUIMethod(api.POST, pathPrefix + "system/cluster/_search", shdl.HandleSearchClusterAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "/cluster/:cluster/version"), handler.GetClusterVersion)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "/cluster"), shdl.HandleCreateClusterAction)
ui.HandleUIMethod(api.PUT, path.Join(pathPrefix, "/cluster/:id"), shdl.HandleUpdateClusterAction)
ui.HandleUIMethod(api.DELETE, path.Join(pathPrefix, "/cluster/:id"), shdl.HandleDeleteClusterAction)
ui.HandleUIMethod(api.GET, path.Join(pathPrefix, "/cluster/_search"), shdl.HandleSearchClusterAction)
ui.HandleUIMethod(api.POST, path.Join(pathPrefix, "/cluster/_search"), shdl.HandleSearchClusterAction)
}

View File

@ -35,9 +35,9 @@ export default [
component: './Cluster/ClusterMonitor',
hideInMenu: true,
}, {
path: '/cluster/monitoring',
path: '/cluster/metrics',
name: 'monitoring',
component: './Cluster/ClusterList',
component: './Cluster/Metrics',
}, {
path: '/cluster/logging',
name: 'logging',

View File

@ -1,5 +1,5 @@
export default {
'GET /_search-center/system/cluster/_search': function(req, res){
'GET /_search-center/cluster/_search': function(req, res){
res.send({
"took": 0,
"timed_out": false,
@ -31,7 +31,7 @@ export default {
}
})
},
'POST /_search-center/system/cluster/_search': function(req, res){
'POST /_search-center/cluster/_search': function(req, res){
res.send({
"took": 0,
"timed_out": false,
@ -63,7 +63,7 @@ export default {
}
})
},
'POST /_search-center/system/cluster': function(req, res){
'POST /_search-center/cluster': function(req, res){
res.send({
"_id": "c0oc4kkgq9s8qss2uk50",
"_source": {
@ -81,7 +81,7 @@ export default {
"result": "created"
});
},
'PUT /_search-center/system/cluster/:id': function(req, res){
'PUT /_search-center/cluster/:id': function(req, res){
res.send({
"_id": "c0oc4kkgq9s8qss2uk50",
"_source": {
@ -98,7 +98,7 @@ export default {
"result": "updated"
});
},
'DELETE /_search-center/system/cluster/:id': function(req, res){
'DELETE /_search-center/cluster/:id': function(req, res){
res.send({
"_id": "c0oc4kkgq9s8qss2uk50",
"result": "deleted"

View File

@ -8,6 +8,7 @@
"@antv/data-set": "^0.9.6",
"@antv/g2-brush": "^0.0.2",
"@babel/runtime": "^7.1.2",
"@elastic/charts": "^25.0.1",
"@monaco-editor/react": "^3.7.4",
"@svgdotjs/svg.js": "^3.0.16",
"antd": "^3.26.18",
@ -24,9 +25,11 @@
"honeycomb-grid": "^3.1.7",
"lodash": "^4.17.10",
"lodash-decorators": "^6.0.0",
"luxon": "^1.26.0",
"memoize-one": "^4.0.0",
"module": "^1.2.5",
"moment": "^2.22.2",
"moment": "^2.29.1",
"moment-timezone": "^0.5.32",
"node-ssh": "^8.0.0",
"numeral": "^2.0.6",
"nzh": "^1.0.3",
@ -41,6 +44,7 @@
"react-document-title": "^2.0.3",
"react-dom": "^16.5.1",
"react-fittext": "^1.0.0",
"react-grid-layout": "^1.2.0",
"react-highlight-words": "^0.16.0",
"react-infinite-scroller": "^1.2.4",
"react-json-prettify": "^0.2.0",

View File

@ -102,12 +102,12 @@ class BasicLayout extends React.PureComponent {
dispatch({
type: 'setting/getSetting',
});
dispatch({
type: 'cluster/fetchClusterVersion',
payload: {
cluster: 'single-es'
}
});
// dispatch({
// type: 'cluster/fetchClusterVersion',
// payload: {
// cluster: 'single-es'
// }
// });
this.renderRef = requestAnimationFrame(() => {
this.setState({
rendering: false,

View File

@ -172,6 +172,13 @@ export default {
'menu.account.trigger': 'Trigger Error',
'menu.account.logout': 'Logout',
'dashboard.charts.title.cluster_throughput.axis.indexing':"Indexing Throughput",
'dashboard.charts.title.cluster_throughput.axis.searching':"Searching Throughput",
'dashboard.charts.title.cluster_latency.axis.indexing':"Indexing Latency",
'dashboard.charts.title.cluster_latency.axis.searching':"Searching Latency",
'app.login.message-invalid-credentials': 'Invalid username or passwordadmin/888888',
'app.login.message-invalid-verification-code': 'Invalid verification code',
'app.login.tab-login-credentials': 'Credentials',

View File

@ -178,6 +178,12 @@ export default {
'menu.account.trigger': '触发报错',
'menu.account.logout': '退出登录',
'dashboard.charts.title.cluster_throughput.axis.indexing':"索引吞吐",
'dashboard.charts.title.cluster_throughput.axis.searching':"查询吞吐",
'dashboard.charts.title.cluster_latency.axis.indexing':"索引延迟",
'dashboard.charts.title.cluster_latency.axis.searching':"查询延迟",
'app.login.message-invalid-credentials': '账户或密码错误admin/888888',
'app.login.message-invalid-verification-code': '验证码错误',
'app.login.tab-login-credentials': '账户密码登录',

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,17 @@
.vizChartContainer{
padding: 0px;
}
.vizChartItem{
background: white!important;
margin-bottom: 5px;
}
.vizChartTitle{
color: red;
position: absolute;
font-size: 14px;
fill-opacity: 50%;
padding-left: 5px;
}

View File

@ -11,21 +11,21 @@ export async function createClusterConfig(params) {
export async function updateClusterConfig(params) {
let id = params.id;
delete(params['id']);
return request(`${pathPrefix}/system/cluster/${id}`, {
return request(`${pathPrefix}/cluster/${id}`, {
method: 'PUT',
body: params,
});
}
export async function deleteClusterConfig(params) {
return request(`${pathPrefix}/system/cluster/${params.id}`, {
return request(`${pathPrefix}/cluster/${params.id}`, {
method: 'DELETE',
body: params,
});
}
export async function searchClusterConfig(params) {
let url = `${pathPrefix}/system/cluster/_search`;
let url = `${pathPrefix}/cluster/_search`;
let args = buildQueryArgs({
name: params.name,
enabled: params.enabled