From 718b029b85ec03ef7c569ccbd8f05c389b7600d5 Mon Sep 17 00:00:00 2001 From: Hardy Date: Fri, 10 Jan 2025 12:20:04 +0800 Subject: [PATCH] feat: add rollup template to setup, add rollup permission (#71) * feat: add rollup template to setup, add rollup permission * fix: easysearch version check * chore: add noop.tpl * chore: reflactor the code * chore: only one permission.json --- .gitignore | 1 + config/permission.json | 487 ------------------ config/setup/common/noop.tpl | 1 + config/setup/easysearch/template_rollup.tpl | 304 +++++++++++ .../realm/authc/native/permission.json | 38 +- plugin/setup/setup.go | 17 +- .../components/Initialization/index.js | 3 + 7 files changed, 355 insertions(+), 496 deletions(-) delete mode 100644 config/permission.json create mode 100644 config/setup/common/noop.tpl create mode 100644 config/setup/easysearch/template_rollup.tpl diff --git a/.gitignore b/.gitignore index 0a5e324b..d36e7c1d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ coverage/ .idea/ run/ .DS_Store +__debug_bin* *.sw* *.un~ diff --git a/config/permission.json b/config/permission.json deleted file mode 100644 index 37882a7c..00000000 --- a/config/permission.json +++ /dev/null @@ -1,487 +0,0 @@ -{ - - "cat": [ - {"name": "cat.*", "methods": ["get"], - "path": "_cat/*" - }, - {"name": "cat.indices", "methods": ["get"], - "path": "_cat/indices" - }, - {"name": "cat.indices", "methods": ["get"], - "path": "_cat/indices/:target" - }, - {"name": "cat.help", "methods": ["get"], - "path": "_cat/help" - }, - {"name": "cat.repositories", "methods": ["get"], - "path": "_cat/repositories" - }, - {"name": "cat.pending_tasks", "methods": ["get"], - "path": "_cat/pending_tasks" - }, - {"name": "cat.tasks", "methods": ["get"], - "path": "_cat/tasks" - }, - {"name": "cat.allocation", "methods": ["get"], - "path": "_cat/allocation" - }, - {"name": "cat.count", "methods": ["get"], - "path": "_cat/count" - }, - {"name": "cat.shards", "methods": ["get"], - "path": "_cat/shards" - }, - {"name": "cat.shards", "methods": ["get"], - "path": "_cat/shards/:target" - }, - {"name": "cat.aliases", "methods": ["get"], - "path": "_cat/aliases" - }, - {"name": "cat.aliases", "methods": ["get"], - "path": "_cat/aliases/:name" - }, - {"name": "cat.nodeattrs", "methods": ["get"], - "path": "_cat/nodeattrs" - }, - {"name": "cat.templates", "methods": ["get"], - "path": "_cat/templates" - }, - {"name": "cat.thread_pool", "methods": ["get"], - "path": "_cat/thread_pool" - }, - {"name": "cat.health", "methods": ["get"], - "path": "_cat/health" - }, - {"name": "cat.recovery", "methods": ["get"], - "path": "_cat/recovery" - }, - {"name": "cat.fielddata", "methods": ["get"], - "path": "_cat/fielddata" - }, - {"name": "cat.nodes", "methods": ["get"], - "path": "_cat/nodes" - }, - {"name": "cat.plugins", "methods": ["get"], - "path": "_cat/plugins" - }, - {"name": "cat.segments", "methods": ["get"], - "path": "_cat/segments" - }, - {"name": "cat.snapshots", "methods": ["get"], - "path": "_cat/snapshots" - }, - {"name": "cat.master", "methods": ["get"], - "path": "_cat/master" - } - ], - "cluster": [ - {"name": "cluster.*", "methods": ["*"], - "path": "_cluster/*" - }, - {"name": "cluster.info", "methods": ["get"], - "path": "/" - }, - {"name": "cluster.health", "methods": ["get"], - "path": "_cluster/health" - }, - {"name": "cluster.get_settings", "methods":["get"], - "path": "_cluster/settings" - }, - {"name": "cluster.pending_tasks", "methods": ["get"], - "path": "_cluster/pending_tasks" - }, - {"name": "cluster.stats", "methods": ["get"], - "path": "_cluster/stats" - }, - {"name": "cluster.remote_info", "methods": ["get"], - "path": "_remote/info" - }, - {"name": "cluster.allocation_explain", "methods": ["get"], - "path": "_cluster/allocation/explain" - }, - {"name": "cluster.put_settings", "methods": ["put"], - "path": "_cluster/settings" - }, - {"name": "cluster.reroute", "methods": ["post"], - "path": "_cluster/reroute" - }, - {"name": "cluster.count", "methods": ["get"], - "path": "_count" - }, - {"name": "cluster.state", "methods": ["get"], - "path": "_cluster/state" - }, - {"name": "cluster.bulk", "methods": ["put", "post"], - "path": "_bulk" - }, - {"name": "cluster.mget", "methods": ["get", "post"], - "path": "_mget" - }, - {"name": "cluster.ping", "methods": ["head"], - "path": "/" - }, - {"name": "cluster.msearch", "methods": ["get", "post"], - "path": "_msearch" - }, - {"name": "cluster.msearch_template", "methods": ["get", "post"], - "path": "_msearch/template" - }, - {"name": "cluster.mtermvectors", "methods": ["get", "post"], - "path": "_mtermvectors" - }, - {"name": "cluster.rank_eval", "methods": ["get", "post"], - "path": "_rank_eval" - }, - {"name": "cluster.search", "methods": ["get", "post"], - "path": "_search" - }, - {"name": "cluster.search_shards", "methods": ["get", "post"], - "path": "_search_shards" - }, - {"name": "cluster.exists_alias", "methods": ["head"], - "path": "_alias/:alias" - }, - {"name": "cluster.get_alias", "methods": ["get"], - "path": "_alias/:alias" - } - ], - "indices": [ - {"name": "indices.*", "methods": ["*"], - "path": "/*" - }, - {"name": "indices.exists_alias", "methods": ["head"], - "path": "/:index_name/_alias/:alias" - }, - {"name": "indices.get_alias", "methods": ["get"], - "path": "/:index_name/_alias/:alias" - }, - {"name": "indices.recovery", "methods": ["get"], - "path": "/:index_name/_recovery" - }, - {"name": "indices.delete", "methods": ["delete"], - "path": "/:index_name" - }, - {"name": "indices.put", "methods": ["put"], - "path": "/:index_name" - }, - {"name": "indices.clear_cache", "methods": ["post"], - "path": "/:index_name/_cache/clear" - }, - {"name": "indices.update_by_query", "methods": ["post"], - "path": "/:index_name/_update_by_query" - }, - {"name": "indices.shrink", "methods": ["post"], - "path": "/:index_name/_shrink" - }, - {"name": "indices.forcemerge", "methods": ["post"], - "path": "/:index_name/_forcemerge" - }, - {"name": "indices.put_alias", "methods": ["put"], - "path": "/:index_name/_alias/:alias" - }, - {"name": "indices.create", "methods": ["post"], - "path": "/:index_name" - }, - {"name": "indices.split", "methods": ["post"], - "path": "/:index_name/_split" - }, - {"name": "indices.flush", "methods": ["post"], - "path": "/:index_name/_flush" - }, - {"name": "indices.get_mapping", "methods": ["get"], - "path": "/:index_name/_mapping" - }, - {"name": "indices.upgrade", "methods": ["post"], - "path": "/:index_name/_upgrade" - }, - {"name": "indices.validate_query", "methods": ["get", "post"], - "path": "/:index_name/_validate/query" - }, - {"name": "indices.analyze", "methods": ["post"], - "path": "/:index_name/analyze" - }, - {"name": "indices.exists", "methods": ["head"], - "path": "/:index_name" - }, - {"name": "indices.close", "methods": ["post"], - "path": "/:index_name/_close" - }, - {"name": "indices.get_field_mapping", "methods": ["get"], - "path": "/:index_name/_mapping/:fields" - }, - {"name": "indices.delete_alias", "methods": ["delete"], - "path": "/:index_name/_alias/:alias" - }, - {"name": "indices.refresh", "methods": ["get", "post"], - "path": "/:index_name/_refresh" - }, - {"name": "indices.segments", "methods": ["get"], - "path": "/:index_name/_segments" - }, - {"name": "indices.termvectors", "methods": ["get"], - "path": "/:index_name/_termvectors" - }, - {"name": "indices.flush_synced", "methods": ["get", "post"], - "path": "/:index_name/_flush/synced" - }, - {"name": "indices.put_mapping", "methods": ["put"], - "path": "/:index_name/_mapping" - }, - {"name": "indices.get", "methods": ["get"], - "path": "/:index_name" - }, - {"name": "indices.get_settings", "methods": ["get"], - "path": "/:index_name/_settings" - }, - {"name": "indices.open", "methods": ["post"], - "path": "/:index_name/_open" - }, - {"name": "indices.put_settings", "methods": ["put"], - "path": "/:index_name/_settings" - }, - {"name": "indices.stats", "methods": ["get"], - "path": "/:index_name/_stats" - }, - {"name": "indices.delete_by_query", "methods": ["post"], - "path": "/:index_name/_delete_by_query" - }, - {"name": "indices.rollover", "methods": ["post"], - "path": "/:index_name/_rollover" - }, - {"name": "indices.count", "methods": ["get"], - "path": "/:index_name/_count" - }, - {"name": "indices.shard_stores", "methods": ["get"], - "path": "/:index_name/_shard_stores" - }, - {"name": "indices.bulk", "methods": ["post"], - "path": "/:index_name/_bulk" - }, - {"name": "indices.mget", "methods": ["get", "post"], - "path": "/:index_name/_mget" - }, - {"name": "indices.msearch", "methods": ["get", "post"], - "path": "/:index_name/_msearch" - }, - {"name": "indices.msearch_template", "methods": ["get", "post"], - "path": "/:index_name/_msearch/template" - }, - {"name": "indices.mtermvectors", "methods": ["get"], - "path": "/:index_name/_mtermvectors" - }, - {"name": "indices.rank_eval", "methods": ["get"], - "path": "/:index_name/_rank_eval" - }, - {"name": "indices.search", "methods": ["get", "post"], - "path": "/:index_name/_search" - }, - {"name": "indices.search_shards", "methods": ["get", "post"], - "path": "/:index_name/_search_shards" - }, - {"name": "indices.field_caps", "methods":["get", "post"], - "path": "/:index_name/_field_caps" - }, - {"name": "indices.exists_template", "methods":["get"], - "path": "/_template/:name" - }, - {"name": "indices.field_usage_stats", "methods":["get"], - "path": "/:index_name/_field_usage_stats" - }, - {"name": "doc.*", "methods": ["*"], - "path": "/:index_name/:doctype" - }, - {"name": "doc.update", "methods": ["put"], - "path": "/:index_name/:doctype/:doc_id" - }, - {"name": "doc.update", "methods": ["post"], - "path": "/:index_name/_update/:doc_id" - }, - {"name": "doc.create", "methods": ["post"], - "path": "/:index_name/:doctype" - }, - {"name": "doc.create", "methods": ["post", "put"], - "path": "/:index_name/_create/:doc_id" - }, - - {"name": "doc.delete", "methods": ["delete"], - "path": "/:index_name/:doctype/:doc_id" - }, - {"name": "doc.get", "methods": ["get"], - "path": "/:index_name/:doctype/:doc_id" - }, - {"name": "doc.get", "methods": ["get"], - "path": "/:index_name/_source/:doc_id" - }, - {"name": "doc.exists", "methods": ["head"], - "path": "/:index_name/:doctype/:doc_id" - }, - {"name": "doc.exists_source", "methods": ["head"], - "path": "/:index_name/_source/:doc_id" - }, - {"name": "doc.explain", "methods": ["get"], - "path": "/:index_name/_explain/:doc_id" - } - ], - - "ingest": [ - {"name": "ingest.*", "methods": ["*"], - "path": "/_ingest/*" - }, - {"name": "ingest.delete_pipeline", "methods": ["delete"], - "path": "/_ingest/pipeline" - }, - {"name": "ingest.put_pipeline", "methods": ["put"], - "path": "/_ingest/pipeline" - }, - {"name": "ingest.simulate", "methods": ["get", "post"], - "path": "/_ingest/pipeline/_simulate" - }, - {"name": "ingest.put_pipeline", "methods": ["get"], - "path": "/_ingest/pipeline" - }, - {"name": "ingest.processor_grok", "methods": ["get"], - "path": "/_ingest/processor/grok" - } - ], - - "nodes": [ - {"name": "nodes.*", "methods": ["*"], - "path": "/_nodes/*" - }, - {"name": "nodes.info", "methods": ["get"], - "path": "/_nodes" - }, - {"name": "nodes.info", "methods": ["get"], - "path": "/_nodes/:node_id" - }, - {"name": "nodes.stats", "methods": ["get"], - "path": "/_nodes/stats" - }, - {"name": "nodes.reload_secure_settings", "methods": ["post"], - "path": "/_nodes/reload_secure_settings" - }, - {"name": "nodes.usage", "methods": ["get"], - "path": "/_nodes/usage" - }, - {"name": "nodes.hot_threads", "methods": ["get"], - "path": "/_nodes/hot_threads" - } - ], - - "reindex": [ - {"name": "reindex.*", "methods": ["*"], - "path": "/_reindex/*" - }, - {"name": "reindex", "methods": ["post"], - "path": "/_reindex" - }, - {"name": "reindex.rethrottle", "methods": ["post"], - "path": "/_reindex/:rid/_rethrottle" - } - ], - - "render_search_template": [ - {"name": "render_search_template.*", "methods": ["*"], - "path": "/_render/template" - }, - {"name": "render_search_template", "methods": ["post", "get"], - "path": "/_render/template" - }, - {"name": "render_search_template_by_id", "methods": ["post", "get"], - "path": "/_render/template/:tid" - } - ], - "scripts": [ - {"name": "scripts.*", "methods": ["*"], - "path": "/_scripts/:sid" - }, - {"name": "scripts.get", "methods": ["get"], - "path": "/_scripts/:sid" - }, - {"name": "scripts.put", "methods": ["put"], - "path": "/_scripts/:sid" - }, - {"name": "scripts.delete", "methods": ["delete"], - "path": "/_scripts/:sid" - }, - {"name": "scripts.painless_execute", "methods": ["get", "post"], - "path": "_scripts/painless/_execute" - } - ], - - "scroll": [ - {"name": "scroll.*", "methods": ["*"], - "path": "/_search/scroll*" - }, - {"name": "scroll.search", "methods": ["get", "post"], - "path": "/_search/scroll" - }, - {"name": "scroll.delete", "methods": ["delete"], - "path": "/_search/scroll/:scroll_id" - }, - {"name": "scroll.get", "methods": ["get"], - "path": "/_search/scroll/:scroll_id" - }, - {"name": "scroll.create", "methods": ["post"], - "path": "/_search/scroll/:scroll_id" - } - ], - - "snapshot": [ - {"name": "snapshot.*", "methods": ["*"], - "path": "/_snapshot/*" - }, - {"name": "snapshot.get_repository", "methods": ["get"], - "path": "/_snapshot/:repo_name" - }, - {"name": "snapshot.create_repository", "methods": ["post"], - "path": "/_snapshot/:repo_name" - }, - {"name": "snapshot.create", "methods": ["post"], - "path": "/_snapshot/:repo_name/:snapshot_name" - }, - {"name": "snapshot.restore", "methods": ["post"], - "path": "/_snapshot/:repo_name/:snapshot_name/_restore" - }, - {"name": "snapshot.status", "methods": ["get"], - "path": "/_snapshot/_status" - }, - {"name": "snapshot.delete", "methods": ["delete"], - "path": "/_snapshot/:repo_name/:snapshot_name" - }, - {"name": "snapshot.delete_repository", "methods": ["delete"], - "path": "/_snapshot/:repo_name" - }, - {"name": "snapshot.verify_repository", "methods": ["post"], - "path": "/_snapshot/:repo_name/_verify" - }, - {"name": "snapshot.get", "methods": ["get"], - "path": "/_snapshot/:repo_name/:snapshot_name" - } - ], - - "tasks": [ - {"name": "tasks.*", "methods": ["*"], - "path": "/_tasks/*" - }, - {"name": "tasks.list", "methods": ["get"], - "path": "/_tasks" - }, - {"name": "tasks.cancel", "methods": ["post"], - "path": "/_tasks/:task_id/_cancel" - }, - {"name": "tasks.get", "methods": ["get"], - "path": "/_tasks/:task_id" - } - ], - "sql": [ - {"name": "sql.*", "methods": ["*"], "path": "/_sql/*"}, - {"name": "sql.clear", "methods": ["post"], "path": "/_sql/close"}, - {"name": "sql.get_async", "methods": ["get"], "path": "/_sql/async/:search_id"}, - {"name": "sql.delete_async", "methods": ["delete"], "path": "/_sql/async/delete/:search_id"}, - {"name": "sql.get_async_status", "methods": ["get"], "path": "/_sql/async/status/:search_id"}, - {"name": "sql.search", "methods": ["get", "post"], "path": "/_sql"}, - {"name": "sql.search", "methods": ["post"], "path": "/_plugins/_sql"}, - {"name": "sql.translate", "methods": ["get", "post"], "path": "/_sql/translate"} - ] -} \ No newline at end of file diff --git a/config/setup/common/noop.tpl b/config/setup/common/noop.tpl new file mode 100644 index 00000000..d9d15e1d --- /dev/null +++ b/config/setup/common/noop.tpl @@ -0,0 +1 @@ +GET / \ No newline at end of file diff --git a/config/setup/easysearch/template_rollup.tpl b/config/setup/easysearch/template_rollup.tpl new file mode 100644 index 00000000..2254f048 --- /dev/null +++ b/config/setup/easysearch/template_rollup.tpl @@ -0,0 +1,304 @@ +PUT /.easysearch-ilm-config/_settings +{ + "index": { + "mapping": { + "nested_fields": { + "limit": 1000 + }, + "nested_objects": { + "limit": 20000 + }, + "total_fields": { + "limit": 30000 + } + } + } +} + +DELETE _rollup/jobs/rollup_index_stats +PUT _rollup/jobs/rollup_index_stats?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_index_stats_{{ctx.source_index}}", + "timestamp": "timestamp", + "continuous": true, + "page_size": 100, + "cron": "*/10 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "value_count": {} + } + ], + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.labels.index_id", + "metadata.labels.index_name", + "metadata.category", + "payload.elasticsearch.index_stats.index_info.health" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "metrics": [ + "payload.elasticsearch.index_stats.*" + ], + "filter": { + "metadata.name": "index_stats" + } + } +} + +DELETE _rollup/jobs/rollup_index_health +PUT _rollup/jobs/rollup_index_health?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_index_health_{{ctx.source_index}}", + "timestamp": "timestamp", + "continuous": true, + "page_size": 100, + "cron": "*/10 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "value_count": {} + } + ], + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.labels.index_name", + "metadata.category", + "payload.elasticsearch.index_health.status" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "metrics": [ + "payload.elasticsearch.index_health.*" + ], + "filter": { + "metadata.name": "index_health" + } + } +} + +DELETE _rollup/jobs/rollup_cluster_stats +PUT _rollup/jobs/rollup_cluster_stats?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_cluster_stats_{{ctx.source_index}}", + "page_size": 100, + "continuous": true, + "cron": "*/10 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "value_count": {} + } + ], + "timestamp": "timestamp", + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.category", + "payload.elasticsearch.cluster_stats.status" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "metrics": [ + "payload.elasticsearch.cluster_stats.indices.*", + "payload.elasticsearch.cluster_stats.nodes.*" + ], + "filter": { + "metadata.name": "cluster_stats" + } + } +} + +DELETE _rollup/jobs/rollup_cluster_health +PUT _rollup/jobs/rollup_cluster_health?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_cluster_health_{{ctx.source_index}}", + "continuous": true, + "page_size": 100, + "cron": "*/10 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "value_count": {} + } + ], + "timestamp": "timestamp", + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.category", + "payload.elasticsearch.cluster_health.status" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "filter": { + "metadata.name": "cluster_health" + }, + "metrics": [ + "payload.elasticsearch.cluster_health.*" + ] + } +} + +# 高级 节点 +DELETE _rollup/jobs/rollup_node_stats +PUT _rollup/jobs/rollup_node_stats?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_node_stats_{{ctx.source_index}}", + "timestamp": "timestamp", + "continuous": true, + "page_size": 100, + "cron": "*/10 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "min": {} + }, + { + "value_count": {} + } + ], + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.category", + "metadata.labels.node_id", + "metadata.labels.transport_address" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "filter": { + "metadata.name": "node_stats" + }, + "exclude": [ + "payload.elasticsearch.node_stats.http.routes.*" + ], + "metrics": [ + "payload.elasticsearch.node_stats.*" + ] + } +} + +DELETE _rollup/jobs/rollup_shard_stats_metrics +PUT _rollup/jobs/rollup_shard_stats_metrics?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_shard_stats_metrics_{{ctx.source_index}}", + "timestamp": "timestamp", + "continuous": true, + "page_size": 100, + "cron": "*/5 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "value_count": {} + } + ], + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.labels.index_id", + "metadata.labels.index_name", + "metadata.category", + "metadata.labels.shard_id" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "metrics": [ + "payload.elasticsearch.shard_stats.*" + ], + "filter": { + "metadata.name": "shard_stats", + "payload.elasticsearch.shard_stats.routing.primary": true + + } + } +} + +DELETE _rollup/jobs/rollup_shard_stats_state +PUT _rollup/jobs/rollup_shard_stats_state?replace +{ + "rollup": { + "source_index": ".infini_metrics", + "target_index": "rollup_shard_stats_state_{{ctx.source_index}}", + "timestamp": "timestamp", + "continuous": true, + "page_size": 100, + "cron": "*/5 1-23 * * *", + "timezone": "UTC", + "stats": [ + { + "max": {} + }, + { + "value_count": {} + } + ], + "interval": "1m", + "identity": [ + "metadata.labels.cluster_id", + "metadata.labels.cluster_uuid", + "metadata.labels.index_name", + "metadata.category", + "payload.elasticsearch.shard_stats.routing.state", + "metadata.labels.node_id" + ], + "attributes": [ + "agent.*", + "metadata.*" + ], + "filter": { + "metadata.name": "shard_stats" + } + } +} \ No newline at end of file diff --git a/modules/security/realm/authc/native/permission.json b/modules/security/realm/authc/native/permission.json index 37882a7c..3df1b7ed 100644 --- a/modules/security/realm/authc/native/permission.json +++ b/modules/security/realm/authc/native/permission.json @@ -1,5 +1,4 @@ { - "cat": [ {"name": "cat.*", "methods": ["get"], "path": "_cat/*" @@ -143,6 +142,12 @@ }, {"name": "cluster.get_alias", "methods": ["get"], "path": "_alias/:alias" + }, + {"name": "cluster.mapping", "methods": ["get"], + "path": "_mapping" + }, + {"name": "cluster.aliases", "methods": ["get"], + "path": "_aliases" } ], "indices": [ @@ -281,8 +286,8 @@ {"name": "indices.field_caps", "methods":["get", "post"], "path": "/:index_name/_field_caps" }, - {"name": "indices.exists_template", "methods":["get"], - "path": "/_template/:name" + {"name": "indices.exists_template", "methods":["head"], + "path": "/_template/:template_name" }, {"name": "indices.field_usage_stats", "methods":["get"], "path": "/:index_name/_field_usage_stats" @@ -367,7 +372,6 @@ "path": "/_nodes/hot_threads" } ], - "reindex": [ {"name": "reindex.*", "methods": ["*"], "path": "/_reindex/*" @@ -379,7 +383,31 @@ "path": "/_reindex/:rid/_rethrottle" } ], - + "template": [ + {"name": "template.*", "methods": ["*"], + "path": "/_template/*" + }, + {"name": "template.put", "methods": ["put"], + "path": "/_template/:template_name" + }, + {"name": "template.delete", "methods": ["delete"], + "path": "/_template/:template_name" + } + ], + "rollup": [ + { "name": "rollup.*","methods": ["*"], + "path": "/_rollup/*" + }, + { "name": "rollup.get.explain","methods": ["get"], + "path": "/_rollup/jobs/:rollup_name/_explain" + }, + { "name": "rollup.put","methods": ["put"], + "path": "/_rollup/jobs/:rollup_name" + }, + { "name": "rollup.delete","methods": ["delete"], + "path": "/_rollup/jobs/:rollup_name" + } + ], "render_search_template": [ {"name": "render_search_template.*", "methods": ["*"], "path": "/_render/template" diff --git a/plugin/setup/setup.go b/plugin/setup/setup.go index dbae6fc2..05b827bd 100644 --- a/plugin/setup/setup.go +++ b/plugin/setup/setup.go @@ -30,9 +30,6 @@ import ( "crypto/md5" "encoding/hex" "fmt" - "infini.sh/console/core/security" - "infini.sh/framework/lib/go-ucfg" - elastic2 "infini.sh/framework/modules/elastic" "io" "io/ioutil" "net/http" @@ -42,6 +39,10 @@ import ( "strings" "time" + "infini.sh/console/core/security" + "infini.sh/framework/lib/go-ucfg" + elastic2 "infini.sh/framework/modules/elastic" + log "github.com/cihub/seelog" "github.com/valyala/fasttemplate" "golang.org/x/crypto/bcrypt" @@ -696,7 +697,7 @@ func (module *Module) initializeTemplate(w http.ResponseWriter, r *http.Request, } baseDir := path.Join(global.Env().GetConfigDir(), "setup") var ( - dslTplFileName = "" + dslTplFileName = "noop.tpl" useCommon = true ) switch request.InitializeTemplate { @@ -704,6 +705,13 @@ func (module *Module) initializeTemplate(w http.ResponseWriter, r *http.Request, useCommon = false dslTplFileName = "template_ilm.tpl" elastic2.InitTemplate(true) + case "rollup": + if ver.Distribution == elastic.Easysearch { + if large, _ := util.VersionCompare(ver.Number, "1.9.2"); large > 0 { + useCommon = false + dslTplFileName = "template_rollup.tpl" + } + } case "alerting": dslTplFileName = "alerting.tpl" case "insight": @@ -715,6 +723,7 @@ func (module *Module) initializeTemplate(w http.ResponseWriter, r *http.Request, default: panic(fmt.Sprintf("unsupport template name [%s]", request.InitializeTemplate)) } + if useCommon { baseDir = path.Join(baseDir, "common") } else { diff --git a/web/src/pages/Guide/Initialization/components/Initialization/index.js b/web/src/pages/Guide/Initialization/components/Initialization/index.js index 52a1f78f..9567dcde 100644 --- a/web/src/pages/Guide/Initialization/components/Initialization/index.js +++ b/web/src/pages/Guide/Initialization/components/Initialization/index.js @@ -16,6 +16,9 @@ const errorReason = { const initialTasks = [{ name: "template_ilm", desc: "Initialize template and ilm" +},{ + name: "rollup", + desc: "Initialize rollup template" },{ name: "insight", desc: "Initialize dashboard template and chart template"