refactor: setup wizard (#250)

Co-authored-by: liugq <silenceqi@hotmail.com>
Reviewed-on: https://git.infini.ltd/infini/console/pulls/250
This commit is contained in:
medcl 2023-12-15 11:22:03 +08:00
parent 0f8ee4fbdd
commit c434d3fb76
23 changed files with 8937 additions and 18519 deletions

View File

@ -1,89 +0,0 @@
#TODO, need to replace cleartext password to keystore, and ingest endpoint
POST .infini_configs/_doc/system_ingest_config_yml
{
"id": "system_ingest_config_yml",
"updated": "2023-10-18T14:49:56.768754+08:00",
"metadata": {
"category": "app_settings",
"name": "agent",
"labels": {
"instance": "_all"
}
},
"payload": {
"name": "system_ingest_config.yml",
"location": "system_ingest_config.yml",
"content": """
metrics:
enabled: true
queue: metrics
network:
enabled: true
summary: true
sockets: true
#throughput: true
details: true
memory:
metrics:
- swap
- memory
disk:
metrics:
- iops
- usage
cpu:
metrics:
- idle
- system
- user
- iowait
- load
instance:
enabled: true
elastic:
availability_check:
enabled: false
pipeline:
- name: replicate_message_to_gateway
enabled: true
auto_start: true
keep_running: true
processor:
- consumer:
max_worker_size: 3
queue_selector:
keys:
- metrics
- logs
consumer:
group: replication
processor:
- http:
max_sending_qps: 100
method: POST
path: /$[[queue_name]]/_doc/
headers:
Content-Type: application/json
body: $[[message]]
basic_auth:
username: ingest
password: password
# tls: #for mTLS connection with config servers
# enabled: true
# ca_file: /Users/medcl/Desktop/ca.crt
# cert_file: /Users/medcl/Desktop/client.crt
# key_file: /Users/medcl/Desktop/client.key
# skip_insecure_verify: false
schema: "http"
hosts: # receiver endpoint, fallback in order
- "192.168.3.185:8888"
valid_status_code: [200,201] #panic on other status code
""",
"version": 3
}
}

View File

@ -1,73 +0,0 @@
#agent
POST .infini_configs/_doc/task_config_tpl
{
"id": "task_config_tpl",
"updated": "2023-10-19T14:49:56.768754+08:00",
"metadata": {
"category": "app_settings",
"name": "agent",
"labels": {
"instance": "_all"
}
},
"payload": {
"name": "task_config.tpl",
"location": "task_config.tpl",
"content": """
env:
CLUSTER_PASSWORD: $[[keystore.$[[CLUSTER_ID]]_password]]
elasticsearch:
- id: $[[TASK_ID]]
name: $[[TASK_ID]]
cluster_uuid: $[[CLUSTER_UUID]]
enabled: true
endpoints: $[[CLUSTER_ENDPOINT]]
discovery:
enabled: false
basic_auth:
username: $[[CLUSTER_USERNAME]]
password: $[[CLUSTER_PASSWORD]]
traffic_control:
enabled: true
max_qps_per_node: 100
max_bytes_per_node: 10485760
max_connection_per_node: 5
pipeline:
#node level metrics
- auto_start: $[[NODE_LEVEL_TASKS_ENABLED]]
enabled: $[[NODE_LEVEL_TASKS_ENABLED]]
keep_running: true
name: collect_$[[TASK_ID]]_es_node_stats
retry_delay_in_ms: 10000
processor:
- es_node_stats:
elasticsearch: $[[TASK_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
when:
cluster_available: ["$[[TASK_ID]]"]
#node logs
- auto_start: $[[NODE_LEVEL_TASKS_ENABLED]]
enabled: $[[NODE_LEVEL_TASKS_ENABLED]]
keep_running: true
name: collect_$[[TASK_ID]]_es_logs
retry_delay_in_ms: 10000
processor:
- es_logs_processor:
elasticsearch: $[[TASK_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
logs_path: $[[NODE_LOGS_PATH]]
queue_name: logs
when:
cluster_available: ["$[[TASK_ID]]"]
""",
"version": 1
}
}

View File

@ -1,110 +0,0 @@
POST .infini_configs/_doc/agent_relay_gateway_config_yml
{
"id": "agent_relay_gateway_config_yml",
"updated": "2023-10-19T14:49:56.768754+08:00",
"metadata": {
"category": "app_settings",
"name": "gateway",
"labels": {
"instance": "_all"
}
},
"payload": {
"name": "agent_relay_gateway_config.yml",
"location": "agent_relay_gateway_config.yml",
"content": """
path.data: data
path.logs: log
configs.auto_reload: false
entry:
- name: my_es_entry
enabled: true
router: my_router
max_concurrency: 200000
network:
binding: 0.0.0.0:8888
# tls: #for mTLS connection with config servers
# enabled: true
# ca_file: /Users/medcl/Desktop/ca.crt
# cert_file: /Users/medcl/Desktop/server.crt
# key_file: /Users/medcl/Desktop/server.key
# skip_insecure_verify: false
flow:
- name: deny_flow
filter:
- set_response:
body: "request not allowed"
status: 500
- name: ingest_flow
filter:
- basic_auth:
valid_users:
ingest: password
- rewrite_to_bulk:
type_removed: false
- bulk_request_mutate:
fix_null_id: true
generate_enhanced_id: true
# fix_null_type: true
# default_type: m-type
# default_index: m-index
index_rename:
metrics: ".infini_metrics"
logs: ".infini_logs"
- bulk_reshuffle:
when:
contains:
_ctx.request.path: /_bulk
elasticsearch: prod
level: node
partition_size: 1
fix_null_id: true
router:
- name: my_router
default_flow: deny_flow
rules:
- method:
- "POST"
enabled: true
pattern:
- "/{any_index}/_doc/"
flow:
- ingest_flow
elasticsearch:
- name: prod
enabled: true
basic_auth:
username: admin
password: admin
endpoints:
- https://10.0.0.3:9200
pipeline:
- name: bulk_request_ingest
auto_start: true
keep_running: true
retry_delay_in_ms: 1000
processor:
- bulk_indexing:
max_connection_per_node: 100
num_of_slices: 3
max_worker_size: 30
idle_timeout_in_seconds: 10
bulk:
compress: false
batch_size_in_mb: 10
batch_size_in_docs: 10000
consumer:
fetch_max_messages: 100
queue_selector:
labels:
type: bulk_reshuffle
""",
"version": 1
}
}

View File

@ -1,24 +0,0 @@
-----BEGIN CERTIFICATE-----
MIID+zCCAuOgAwIBAgIUEctl/ds6wIoJGTW3PQc5L/0VlQ4wDQYJKoZIhvcNAQEL
BQAwgYwxCzAJBgNVBAYTAkNOMQ4wDAYDVQQIDAVodW5hbjERMA8GA1UEBwwIY2hh
bmdzaGExEzARBgNVBAoMCmluZmluaWxhYnMxCzAJBgNVBAsMAml0MRcwFQYDVQQD
DA5pbmZpbmlsYWJzLmNvbTEfMB0GA1UEAwwWcmVsZWFzZS5pbmZpbmlsYWJzLmNv
bTAeFw0yMzA2MDgwNTI1MzVaFw0zMzA2MDUwNTI1MzVaMIGMMQswCQYDVQQGEwJD
TjEOMAwGA1UECAwFaHVuYW4xETAPBgNVBAcMCGNoYW5nc2hhMRMwEQYDVQQKDApp
bmZpbmlsYWJzMQswCQYDVQQLDAJpdDEXMBUGA1UEAwwOaW5maW5pbGFicy5jb20x
HzAdBgNVBAMMFnJlbGVhc2UuaW5maW5pbGFicy5jb20wggEiMA0GCSqGSIb3DQEB
AQUAA4IBDwAwggEKAoIBAQD43Co0NROYEeeZWWH4O3m+V7U+1/4DVuAm+9u1bxqi
OnliE24wm9+gk3HEwdr6pMGTfMWS8BMmqUpjjgFVK4Tcur87Cqjq7XDe8j7h5Ipi
8yVUAgqF4wesIZpGtxXRZwwGWwRu38zX5CAa9n9Xbp0Y7tDdINRk0vLCp7VQbd2N
VbMXgqygJAaAImdNfrddAmojWJ92LCT5HKcDNq8Z62VwtLqOUePiEJxm1sUts9tT
sX8XlyLljz2aoWcX+Gzin8HkOftnpYeHptDL26Q2FyW7TYZR4oFuhU6FQ/YPfCsE
m/sxVC7BIBWal4DF29ZiivWvWk+wBNq03LxR1/TvJtOdAgMBAAGjUzBRMB0GA1Ud
DgQWBBSsTKk1fbAbRxPIydDSatzKh+YaGzAfBgNVHSMEGDAWgBSsTKk1fbAbRxPI
ydDSatzKh+YaGzAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAl
0p1/QMgdahq22SY+shvvxH9AbtyQo3XFZjWXd0+rMbt0uci640NDhaZxBeMgDWaJ
jRe+K7sw+AhnIWzH9RbaYQfVAXxjFb7kHSb93bezXjA3m21O5KpwiQyaXCbsIVSf
n59pd3+EV/Q96EclNMoixpDUVtqI7i046/3imZ4XyBDpQPWCajaKpp8rkypCvykK
KQ7BGF8lr3WyAgfsoHi9UrWcN1n3ynyy9T9qr1CFmopQiwSQo+036a8F/3Y9KIFM
nhQWTBVcXkbmZtxpRRaD9rC6p+2aqfVNmjCDuYxjuGmTqL/0eayRefk0QwT5S51L
ea5WlmQtUbCpewnNiNrz
-----END CERTIFICATE-----

View File

@ -1,28 +0,0 @@
-----BEGIN PRIVATE KEY-----
MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQD43Co0NROYEeeZ
WWH4O3m+V7U+1/4DVuAm+9u1bxqiOnliE24wm9+gk3HEwdr6pMGTfMWS8BMmqUpj
jgFVK4Tcur87Cqjq7XDe8j7h5Ipi8yVUAgqF4wesIZpGtxXRZwwGWwRu38zX5CAa
9n9Xbp0Y7tDdINRk0vLCp7VQbd2NVbMXgqygJAaAImdNfrddAmojWJ92LCT5HKcD
Nq8Z62VwtLqOUePiEJxm1sUts9tTsX8XlyLljz2aoWcX+Gzin8HkOftnpYeHptDL
26Q2FyW7TYZR4oFuhU6FQ/YPfCsEm/sxVC7BIBWal4DF29ZiivWvWk+wBNq03LxR
1/TvJtOdAgMBAAECggEAHfFKQq3VhbPhzIRXUqlqpImjt8P/6XbyfBOhroWHttfs
8u1TkhWvJSrtwrbFxOfol/j97LK7cH4TV+x7dzvykycFC0g6ZXSG4sxS30Btm3+V
5jMOARNSllYUsfLQH+STgHrttZ7H5CdWlZKYZR9crOX5y3a/whcqOQbkvKCmH522
CUWeoabELLFGh6sGkQ6dXMFMS/fzT9MK3gxoLYYoTum5vJN2HYxMBerTbc3wXPtN
/BY8gStkv9BtbovPqsHUWeWK1fXphqysfKE79k9zS9PPz8ErEPhhT44blIo0BKCp
akw4DjHXbHhFq8Onh+3NemTLIhx++8z0FgL+6jYdIQKBgQD7BnNhHSxRm/smvyVm
L3fOX22fL1ZruY9sV4h3pK7KEqMLoUfrOpBN1AiQd/Xb/XNGMrHSPdZGL+tSS7vJ
2ibcSJWGuvuhA8HXpSPRUE9ao5cdRtEOTpy0FncMYaa7XYFoi1NOH/xl0uhd2u2i
uqL122tafZ9cP8fzvrOICa9ydwKBgQD9yrq3D3m5oIj596jDUsX2jxCKRzdnGLu3
/qRnnfsN07524Ydqo8lpQMU+u2ljJhNFjcBqTOjSsRnnd1qQHqxZ18ABgOteAws5
FlfLNQ7nupZu0IMd3b2WoCqoUOzLBsofUnMUPGRZLI2QCxfS1gzgp57IpY1egHe9
1HL2Ht/7iwKBgCCeYffIlq20GxqZ0/5HRMYoWFJLEGvHHP/zD+ScHapcaZtlRbcn
UQEMAGDldak0cfo5NCohpupP58A13x0Hn+0X8XYkbfYqStH+v3y/dtBMWaKQRTIa
vPoZwTZ2qffG2r3+/MA2H9ILae5oOGDg57QS4wxLLp4KG61spl+TAp1ZAoGAbtG8
UD0gsO6pgUUkWw3kxXHZDhhk187UAVbe4SP5wSLpsy1tnSIhy6TtvCPHs/SnS6LH
F2O38nBE2G6ki/Po3F46SC3MGMQJfYcFFQV5GbS/BWplJoBxzbjoh5C2pTy0u5Kc
D4UDaHDs6638XCL9goeO7RxlK5O7NZf0DwaSVVsCgYB6JQoVjob9kRIkko1ob63W
idsWNZtG3Py1gx61lBPk/Lz/bxJKlsnWgvInjGgFQ0o0g98hnd4H3O89BPwyAgKa
dIKfW/2k7SG0B+wB1xhnaBtHvJ3tWdqcH9wcTbOQ4LbT1OlvEQYc2B7cYicS22oZ
1lUUI2e9WKSTzwHk+nZQEw==
-----END PRIVATE KEY-----

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,60 @@
#agent_config.tpl
#TODO, need to replace cleartext password to keystore, and ingest endpoint
POST $[[SETUP_INDEX_PREFIX]]configs/$[[SETUP_DOC_TYPE]]/system_ingest_config_yml
{
"payload": {
"content": "\n\nmetrics:\n enabled: true\n queue: metrics\n network:\n enabled: true\n summary: true\n sockets: true\n #throughput: true\n details: true\n memory:\n metrics:\n - swap\n - memory\n disk:\n metrics:\n - iops\n - usage\n cpu:\n metrics:\n - idle\n - system\n - user\n - iowait\n - load\n instance:\n enabled: true\n\nelastic:\n availability_check:\n enabled: false\n\npipeline:\n - name: replicate_message_to_gateway\n enabled: true\n auto_start: true\n keep_running: true\n processor:\n - consumer:\n max_worker_size: 3\n queue_selector:\n keys:\n - metrics\n - logs\n consumer:\n group: replication\n processor:\n - http:\n max_sending_qps: 100\n method: POST\n path: /$[[queue_name]]/_doc/\n headers:\n Content-Type: application/json\n body: $[[message]]\n basic_auth:\n username: ingest\n password: password\n# tls: #for mTLS connection with config servers\n# enabled: true\n# ca_file: /xxx/ca.crt\n# cert_file: /xxx/client.crt\n# key_file: /xxx/client.key\n# skip_insecure_verify: false\n schema: \"http\"\n hosts: # receiver endpoint, fallback in order\n - \"10.0.0.3:8081\"\n valid_status_code: [200,201] #panic on other status code\n\n",
"version": 1,
"location": "system_ingest_config.yml",
"name": "system_ingest_config.yml"
},
"updated": "2023-10-18T14:49:56.768754+08:00",
"metadata": {
"labels": {
"instance": "_all"
},
"category": "app_settings",
"name": "agent"
},
"id": "system_ingest_config_yml"
}
#init_agent_config.tpl
POST $[[SETUP_INDEX_PREFIX]]configs/$[[SETUP_DOC_TYPE]]/task_config_tpl
{
"payload": {
"content": "\n\nenv:\n CLUSTER_PASSWORD: $[[keystore.$[[CLUSTER_ID]]_password]]\n\nelasticsearch:\n - id: $[[TASK_ID]]\n name: $[[TASK_ID]]\n cluster_uuid: $[[CLUSTER_UUID]]\n enabled: true\n endpoints: $[[CLUSTER_ENDPOINT]]\n discovery:\n enabled: false\n basic_auth:\n username: $[[CLUSTER_USERNAME]]\n password: $[[CLUSTER_PASSWORD]]\n traffic_control:\n enabled: true\n max_qps_per_node: 100\n max_bytes_per_node: 10485760\n max_connection_per_node: 5\n\npipeline:\n\n#node level metrics\n- auto_start: $[[NODE_LEVEL_TASKS_ENABLED]]\n enabled: $[[NODE_LEVEL_TASKS_ENABLED]]\n keep_running: true\n name: collect_$[[TASK_ID]]_es_node_stats\n retry_delay_in_ms: 10000\n processor:\n - es_node_stats:\n elasticsearch: $[[TASK_ID]]\n labels:\n cluster_id: $[[CLUSTER_ID]]\n when:\n cluster_available: [\"$[[TASK_ID]]\"]\n\n#node logs\n- auto_start: $[[NODE_LEVEL_TASKS_ENABLED]]\n enabled: $[[NODE_LEVEL_TASKS_ENABLED]]\n keep_running: true\n name: collect_$[[TASK_ID]]_es_logs\n retry_delay_in_ms: 10000\n processor:\n - es_logs_processor:\n elasticsearch: $[[TASK_ID]]\n labels:\n cluster_id: $[[CLUSTER_ID]]\n logs_path: $[[NODE_LOGS_PATH]]\n queue_name: logs\n when:\n cluster_available: [\"$[[TASK_ID]]\"]\n",
"version": 1,
"location": "task_config.tpl",
"name": "task_config.tpl"
},
"updated": "2023-10-19T14:49:56.768754+08:00",
"metadata": {
"labels": {
"instance": "_all"
},
"category": "app_settings",
"name": "agent"
},
"id": "task_config_tpl"
}
#init_gateway_config.tpl
POST $[[SETUP_INDEX_PREFIX]]configs/$[[SETUP_DOC_TYPE]]/agent_relay_gateway_config_yml
{
"payload": {
"content": "\n\npath.data: data\npath.logs: log\n\nallow_multi_instance: true\nconfigs.auto_reload: false\n\nentry:\n - name: my_es_entry\n enabled: true\n router: my_router\n max_concurrency: 200000\n network:\n binding: 0.0.0.0:8081\n# tls: #for mTLS connection with config servers\n# enabled: true\n# ca_file: /xxx/ca.crt\n# cert_file: /xxx/server.crt\n# key_file: /xxx/server.key\n# skip_insecure_verify: false\n\nflow:\n - name: deny_flow\n filter:\n - set_response:\n body: \"request not allowed\"\n status: 500\n - name: ingest_flow\n filter:\n - basic_auth:\n valid_users:\n ingest: n\n - rewrite_to_bulk:\n type_removed: false\n - bulk_request_mutate:\n fix_null_id: true\n generate_enhanced_id: true\n# fix_null_type: true\n# default_type: m-type\n# default_index: m-index\n index_rename:\n metrics: \".infini_metrics\"\n logs: \".infini_logs\"\n - bulk_reshuffle:\n when:\n contains:\n _ctx.request.path: /_bulk\n elasticsearch: prod\n level: node\n partition_size: 1\n fix_null_id: true\n\nrouter:\n - name: my_router\n default_flow: deny_flow\n rules:\n - method:\n - \"POST\"\n enabled: true\n pattern:\n - \"/{any_index}/_doc/\"\n flow:\n - ingest_flow\nelasticsearch:\n - name: prod\n enabled: true\n basic_auth:\n username: ingest\n password: password\n endpoints:\n - http://10.0.0.3:9020\n\npipeline:\n - name: bulk_request_ingest\n auto_start: true\n keep_running: true\n retry_delay_in_ms: 1000\n processor:\n - bulk_indexing:\n max_connection_per_node: 100\n num_of_slices: 3\n max_worker_size: 30\n idle_timeout_in_seconds: 10\n bulk:\n compress: false\n batch_size_in_mb: 10\n batch_size_in_docs: 10000\n consumer:\n fetch_max_messages: 100\n queue_selector:\n labels:\n type: bulk_reshuffle\n",
"version": 1,
"location": "agent_relay_gateway_config.yml",
"name": "agent_relay_gateway_config.yml"
},
"updated": "2023-10-19T14:49:56.768754+08:00",
"metadata": {
"labels": {
"instance": "_all"
},
"category": "app_settings",
"name": "gateway"
},
"id": "agent_relay_gateway_config_yml"
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,604 @@
PUT _template/$[[SETUP_TEMPLATE_NAME]]
{
"order": 0,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]*"
],
"settings": {
"index": {
"max_result_window": "10000000",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
},
"number_of_shards": "1"
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
]
},
"aliases": {}
}
PUT _ilm/policy/ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_age": "30d",
"max_size": "50gb"
},
"set_priority": {
"priority": 100
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {
}
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]metrics-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]metrics*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]metrics"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async",
"mapping.coerce": false,
"mapping.ignore_malformed": true
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]metrics-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]metrics"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]metrics":{
"is_write_index":true
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"timestamp": {
"type": "date"
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]logs-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]logs*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]logs"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"payload.message": {
"type": "text"
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]logs-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]logs"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]logs":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]requests_logging-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]requests_logging*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]requests_logging"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]requests_logging-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]requests_logging"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]requests_logging":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]async_bulk_results-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]async_bulk_results*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]async_bulk_results"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]async_bulk_results-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]async_bulk_results"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]async_bulk_results":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]alert-history-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]alert-history*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]alert-history"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]alert-history-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]alert-history"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]alert-history":{
"is_write_index":true
}
},
"mappings": {
"properties" : {
"condition" : {
"properties" : {
"items" : {
"properties" : {
"expression" : {
"type" : "keyword",
"ignore_above" : 256
},
"minimum_period_match" : {
"type" : "long"
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
},
"severity" : {
"type" : "keyword",
"ignore_above" : 256
},
"values" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"condition_result" : {
"type" : "object",
"enabled" : false
},
"context" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"created" : {
"type" : "date"
},
"expression" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"id" : {
"type" : "keyword"
},
"is_escalated" : {
"type" : "boolean"
},
"is_notified" : {
"type" : "boolean"
},
"message" : {
"type" : "keyword",
"ignore_above" : 256
},
"objects" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"resource_id" : {
"type" : "keyword"
},
"resource_name" : {
"type" : "keyword"
},
"rule_id" : {
"type" : "keyword"
},
"rule_name" : {
"type" : "keyword"
},
"search_text" : {
"type" : "text",
"analyzer" : "suggest_text_search",
"index_prefixes" : {
"min_chars" : 2,
"max_chars" : 5
},
"index_phrases" : true
},
"severity" : {
"type" : "keyword"
},
"state" : {
"type" : "keyword",
"ignore_above" : 256
},
"title" : {
"type" : "keyword"
},
"updated" : {
"type" : "date"
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]activities-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]activities*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]activities"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]activities-00001
{
"mappings": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"changelog": {
"type": "object",
"enabled": false
},
"id": {
"type": "keyword"
},
"metadata": {
"properties": {
"category": {
"type": "keyword",
"ignore_above": 256
},
"group": {
"type": "keyword",
"ignore_above": 256
},
"name": {
"type": "keyword",
"ignore_above": 256
},
"type": {
"type": "keyword",
"ignore_above": 256
}
}
},
"payload": {
"type": "object",
"enabled": false
},
"timestamp": {
"type": "date"
}
}
},
"settings": {
"index": {
"lifecycle.rollover_alias": "$[[SETUP_INDEX_PREFIX]]activities",
"refresh_interval": "5s",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"max_result_window": "10000000",
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
}
}
},
"aliases": {
"$[[SETUP_INDEX_PREFIX]]activities": {
"is_write_index": true
}
}
}

View File

@ -0,0 +1,604 @@
PUT _template/$[[SETUP_TEMPLATE_NAME]]
{
"order": 0,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]*"
],
"settings": {
"index": {
"max_result_window": "10000000",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
},
"number_of_shards": "1"
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
]
},
"aliases": {}
}
PUT _ilm/policy/ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_age": "30d",
"max_size": "50gb"
},
"set_priority": {
"priority": 100
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {
}
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]metrics-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]metrics*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]metrics"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async",
"mapping.coerce": false,
"mapping.ignore_malformed": true
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]metrics-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]metrics"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]metrics":{
"is_write_index":true
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"timestamp": {
"type": "date"
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]logs-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]logs*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]logs"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"payload.message": {
"type": "text"
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]logs-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]logs"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]logs":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]requests_logging-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]requests_logging*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]requests_logging"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]requests_logging-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]requests_logging"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]requests_logging":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]async_bulk_results-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]async_bulk_results*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]async_bulk_results"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]async_bulk_results-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]async_bulk_results"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]async_bulk_results":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]alert-history-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]alert-history*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]alert-history"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]alert-history-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]alert-history"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]alert-history":{
"is_write_index":true
}
},
"mappings": {
"properties" : {
"condition" : {
"properties" : {
"items" : {
"properties" : {
"expression" : {
"type" : "keyword",
"ignore_above" : 256
},
"minimum_period_match" : {
"type" : "long"
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
},
"severity" : {
"type" : "keyword",
"ignore_above" : 256
},
"values" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"condition_result" : {
"type" : "object",
"enabled" : false
},
"context" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"created" : {
"type" : "date"
},
"expression" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"id" : {
"type" : "keyword"
},
"is_escalated" : {
"type" : "boolean"
},
"is_notified" : {
"type" : "boolean"
},
"message" : {
"type" : "keyword",
"ignore_above" : 256
},
"objects" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"resource_id" : {
"type" : "keyword"
},
"resource_name" : {
"type" : "keyword"
},
"rule_id" : {
"type" : "keyword"
},
"rule_name" : {
"type" : "keyword"
},
"search_text" : {
"type" : "text",
"analyzer" : "suggest_text_search",
"index_prefixes" : {
"min_chars" : 2,
"max_chars" : 5
},
"index_phrases" : true
},
"severity" : {
"type" : "keyword"
},
"state" : {
"type" : "keyword",
"ignore_above" : 256
},
"title" : {
"type" : "keyword"
},
"updated" : {
"type" : "date"
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]activities-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]activities*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]activities"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]activities-00001
{
"mappings": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"changelog": {
"type": "object",
"enabled": false
},
"id": {
"type": "keyword"
},
"metadata": {
"properties": {
"category": {
"type": "keyword",
"ignore_above": 256
},
"group": {
"type": "keyword",
"ignore_above": 256
},
"name": {
"type": "keyword",
"ignore_above": 256
},
"type": {
"type": "keyword",
"ignore_above": 256
}
}
},
"payload": {
"type": "object",
"enabled": false
},
"timestamp": {
"type": "date"
}
}
},
"settings": {
"index": {
"lifecycle.rollover_alias": "$[[SETUP_INDEX_PREFIX]]activities",
"refresh_interval": "5s",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"max_result_window": "10000000",
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
}
}
},
"aliases": {
"$[[SETUP_INDEX_PREFIX]]activities": {
"is_write_index": true
}
}
}

View File

@ -0,0 +1,546 @@
PUT _template/$[[SETUP_TEMPLATE_NAME]]
{
"order": 0,
"template": "$[[SETUP_INDEX_PREFIX]]*",
"settings": {
"index": {
"max_result_window": "10000000",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
},
"number_of_shards": "1"
}
},
"mappings": {
"doc": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
]
}
},
"aliases": {}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]metrics-rollover
{
"order" : 100000,
"template" : "$[[SETUP_INDEX_PREFIX]]metrics*",
"settings" : {
"index" : {
"format" : "7",
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"doc": {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
}
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]metrics-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]metrics":{
"is_write_index":true
}
},
"mappings": {
"doc":{
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"timestamp": {
"type": "date"
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]logs-rollover
{
"order": 100000,
"template": "$[[SETUP_INDEX_PREFIX]]logs*",
"settings": {
"index": {
"format": "7",
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"doc": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"payload.message": {
"type": "text"
},
"timestamp": {
"type": "date"
}
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]logs-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]logs":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]requests_logging-rollover
{
"order": 100000,
"template": "$[[SETUP_INDEX_PREFIX]]requests_logging*",
"settings": {
"index": {
"format": "7",
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"doc":{
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]requests_logging-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]requests_logging":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]async_bulk_results-rollover
{
"order": 100000,
"template": "$[[SETUP_INDEX_PREFIX]]async_bulk_results*",
"settings": {
"index": {
"format": "7",
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"doc": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]async_bulk_results-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]async_bulk_results":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]alert-history-rollover
{
"order" : 100000,
"template" : "$[[SETUP_INDEX_PREFIX]]alert-history*",
"settings" : {
"index" : {
"format" : "7",
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"doc":{
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
}
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]alert-history-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]alert-history":{
"is_write_index":true
}
},
"mappings": {
"doc":{
"properties" : {
"condition" : {
"properties" : {
"items" : {
"properties" : {
"expression" : {
"type" : "keyword",
"ignore_above" : 256
},
"minimum_period_match" : {
"type" : "long"
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
},
"severity" : {
"type" : "keyword",
"ignore_above" : 256
},
"values" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"condition_result" : {
"type" : "object",
"enabled" : false
},
"context" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"created" : {
"type" : "date"
},
"expression" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"id" : {
"type" : "keyword"
},
"is_escalated" : {
"type" : "boolean"
},
"is_notified" : {
"type" : "boolean"
},
"message" : {
"type" : "keyword",
"ignore_above" : 256
},
"objects" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"resource_id" : {
"type" : "keyword"
},
"resource_name" : {
"type" : "keyword"
},
"rule_id" : {
"type" : "keyword"
},
"rule_name" : {
"type" : "keyword"
},
"search_text" : {
"type" : "text",
"analyzer" : "suggest_text_search"
},
"severity" : {
"type" : "keyword"
},
"state" : {
"type" : "keyword",
"ignore_above" : 256
},
"title" : {
"type" : "keyword"
},
"updated" : {
"type" : "date"
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]activities-rollover
{
"order" : 100000,
"template" : "$[[SETUP_INDEX_PREFIX]]activities*",
"settings" : {
"index" : {
"format" : "7",
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"doc":{
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
}
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]activities-00001
{
"mappings": {
"doc":{
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"changelog": {
"type": "object",
"enabled": false
},
"id": {
"type": "keyword"
},
"metadata": {
"properties": {
"category": {
"type": "keyword",
"ignore_above": 256
},
"group": {
"type": "keyword",
"ignore_above": 256
},
"name": {
"type": "keyword",
"ignore_above": 256
},
"type": {
"type": "keyword",
"ignore_above": 256
}
}
},
"payload": {
"type": "object",
"enabled": false
},
"timestamp": {
"type": "date"
}
}
}
},
"settings": {
"index": {
"refresh_interval": "5s",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"max_result_window": "10000000",
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
}
}
},
"aliases": {
"$[[SETUP_INDEX_PREFIX]]activities": {
"is_write_index": true
}
}
}

View File

@ -0,0 +1,622 @@
PUT _template/$[[SETUP_TEMPLATE_NAME]]
{
"order": 0,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]*"
],
"settings": {
"index": {
"max_result_window": "10000000",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
},
"number_of_shards": "1"
}
},
"mappings": {
"doc": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
]
}
},
"aliases": {}
}
PUT _ilm/policy/ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention
{
"policy": {
"phases": {
"hot": {
"min_age": "0ms",
"actions": {
"rollover": {
"max_age": "30d",
"max_size": "50gb"
},
"set_priority": {
"priority": 100
}
}
},
"delete": {
"min_age": "30d",
"actions": {
"delete": {
}
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]metrics-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]metrics*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]metrics"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"doc": {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
}
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]metrics-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]metrics"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]metrics":{
"is_write_index":true
}
},
"mappings": {
"doc":{
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"timestamp": {
"type": "date"
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]logs-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]logs*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]logs"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"doc": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"payload.message": {
"type": "text"
},
"timestamp": {
"type": "date"
}
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]logs-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]logs"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]logs":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]requests_logging-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]requests_logging*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]requests_logging"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"doc":{
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]requests_logging-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]requests_logging"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]requests_logging":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]async_bulk_results-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]async_bulk_results*"
],
"settings": {
"index": {
"format": "7",
"lifecycle": {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]async_bulk_results"
},
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"doc": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]async_bulk_results-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]async_bulk_results"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]async_bulk_results":{
"is_write_index":true
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]alert-history-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]alert-history*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]alert-history"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"doc":{
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
}
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]alert-history-00001
{
"settings": {
"index.lifecycle.rollover_alias":"$[[SETUP_INDEX_PREFIX]]alert-history"
, "refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]alert-history":{
"is_write_index":true
}
},
"mappings": {
"doc":{
"properties" : {
"condition" : {
"properties" : {
"items" : {
"properties" : {
"expression" : {
"type" : "keyword",
"ignore_above" : 256
},
"minimum_period_match" : {
"type" : "long"
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
},
"severity" : {
"type" : "keyword",
"ignore_above" : 256
},
"values" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"condition_result" : {
"type" : "object",
"enabled" : false
},
"context" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"created" : {
"type" : "date"
},
"expression" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"id" : {
"type" : "keyword"
},
"is_escalated" : {
"type" : "boolean"
},
"is_notified" : {
"type" : "boolean"
},
"message" : {
"type" : "keyword",
"ignore_above" : 256
},
"objects" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"resource_id" : {
"type" : "keyword"
},
"resource_name" : {
"type" : "keyword"
},
"rule_id" : {
"type" : "keyword"
},
"rule_name" : {
"type" : "keyword"
},
"search_text" : {
"type" : "text",
"analyzer" : "suggest_text_search",
"index_prefixes" : {
"min_chars" : 2,
"max_chars" : 5
},
"index_phrases" : true
},
"severity" : {
"type" : "keyword"
},
"state" : {
"type" : "keyword",
"ignore_above" : 256
},
"title" : {
"type" : "keyword"
},
"updated" : {
"type" : "date"
}
}
}
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]activities-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]activities*"
],
"settings" : {
"index" : {
"format" : "7",
"lifecycle" : {
"name" : "ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention",
"rollover_alias" : "$[[SETUP_INDEX_PREFIX]]activities"
},
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"doc":{
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
}
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]activities-00001
{
"mappings": {
"doc":{
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"changelog": {
"type": "object",
"enabled": false
},
"id": {
"type": "keyword"
},
"metadata": {
"properties": {
"category": {
"type": "keyword",
"ignore_above": 256
},
"group": {
"type": "keyword",
"ignore_above": 256
},
"name": {
"type": "keyword",
"ignore_above": 256
},
"type": {
"type": "keyword",
"ignore_above": 256
}
}
},
"payload": {
"type": "object",
"enabled": false
},
"timestamp": {
"type": "date"
}
}
}
},
"settings": {
"index": {
"lifecycle.rollover_alias": "$[[SETUP_INDEX_PREFIX]]activities",
"refresh_interval": "5s",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"max_result_window": "10000000",
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
}
}
},
"aliases": {
"$[[SETUP_INDEX_PREFIX]]activities": {
"is_write_index": true
}
}
}

View File

@ -3,7 +3,7 @@
set -eo pipefail
function print_usage() {
echo "Usage: curl -sSL http://console_endpoint/instance/_get_install_script?token | sudo bash -s -- [-u url_for_download_program] [-v version_for_program ] [-t target_install_dir] [-o overwite_flag] [-s url_console_lan_adress]"
echo "Usage: curl -sSL http://$[[CLOUD_ENDPOINT]]/instance/_get_install_script?token | sudo bash -s -- [-u url_for_download_program] [-v version_for_program ] [-t target_install_dir] [-o overwite_flag] [-s url_console_lan_adress]"
echo "Options:"
echo " -u, --url <url> Install Agent download URL, format is schema://domain:port/stable/agent-platform-version.ext, can be manually specified"
echo " -v, --version <version> Install Agent version, default is to get latest version online, can be manually specified"
@ -263,7 +263,7 @@ disk_queue:
api:
enabled: true
tls:
enabled: true
enabled: false
cert_file: "config/client.crt"
key_file: "config/client.key"
ca_file: "config/ca.crt"
@ -287,7 +287,7 @@ configs:
soft_delete: false
max_backup_files: 5
tls: #for mTLS connection with config servers
enabled: true
enabled: false
cert_file: "config/client.crt"
key_file: "config/client.key"
ca_file: "config/ca.crt"

View File

@ -0,0 +1,827 @@
PUT _template/$[[SETUP_TEMPLATE_NAME]]
{
"order": 0,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]*"
],
"settings": {
"index": {
"max_result_window": "10000000",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
},
"number_of_shards": "1"
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
]
},
"aliases": {}
}
DELETE _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention
PUT _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]metrics-30days-retention
{
"policy": {
"description": "infini metrics hot delete workflow",
"default_state": "hot",
"ism_template": {
"index_patterns": ["$[[SETUP_INDEX_PREFIX]]metrics*"],
"priority": 100
},
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "30d",
"min_size": "50gb"
}
},
{
"index_priority": {
"priority": 100
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
]
}
]
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]metrics-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]metrics*"
],
"settings" : {
"index" : {
"format" : "7",
"plugins.index_state_management.rollover_alias": "$[[SETUP_INDEX_PREFIX]]metrics",
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]metrics-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]metrics":{
"is_write_index":true
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"timestamp": {
"type": "date"
}
}
}
}
DELETE _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]logs-30days-retention
PUT _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]logs-30days-retention
{
"policy": {
"description": "infini logs hot delete workflow",
"default_state": "hot",
"ism_template": {
"index_patterns": ["$[[SETUP_INDEX_PREFIX]]logs*"],
"priority": 100
},
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "30d",
"min_size": "50gb"
}
},
{
"index_priority": {
"priority": 100
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
]
}
]
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]logs-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]logs*"
],
"settings": {
"index": {
"format": "7",
"plugins.index_state_management.rollover_alias": "$[[SETUP_INDEX_PREFIX]]logs",
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"payload.message": {
"type": "text"
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]logs-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]logs":{
"is_write_index":true
}
}
}
DELETE _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]requests_logging-30days-retention
PUT _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]requests_logging-30days-retention
{
"policy": {
"description": "infini requests logging hot delete workflow",
"default_state": "hot",
"ism_template": {
"index_patterns": ["$[[SETUP_INDEX_PREFIX]]requests_logging*"],
"priority": 100
},
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "30d",
"min_size": "50gb"
}
},
{
"index_priority": {
"priority": 100
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
]
}
]
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]requests_logging-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]requests_logging*"
],
"settings": {
"index": {
"format": "7",
"plugins.index_state_management.rollover_alias": "$[[SETUP_INDEX_PREFIX]]requests_logging",
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]requests_logging-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]requests_logging":{
"is_write_index":true
}
}
}
DELETE _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]async_bulk_results-30days-retention
PUT _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]async_bulk_results-30days-retention
{
"policy": {
"description": "infini async bulk results hot delete workflow",
"default_state": "hot",
"ism_template": {
"index_patterns": ["$[[SETUP_INDEX_PREFIX]]async_bulk_results*"],
"priority": 100
},
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "30d",
"min_size": "50gb"
}
},
{
"index_priority": {
"priority": 100
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
]
}
]
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]async_bulk_results-rollover
{
"order": 100000,
"index_patterns": [
"$[[SETUP_INDEX_PREFIX]]async_bulk_results*"
],
"settings": {
"index": {
"format": "7",
"plugins.index_state_management.rollover_alias": "$[[SETUP_INDEX_PREFIX]]async_bulk_results",
"codec": "best_compression",
"number_of_shards": "1",
"translog": {
"durability": "async"
}
}
},
"mappings": {
"dynamic_templates": [
{
"strings": {
"mapping": {
"ignore_above": 256,
"type": "keyword"
},
"match_mapping_type": "string"
}
}
],
"properties": {
"request": {
"properties": {
"body": {
"type": "text"
}
}
},
"response": {
"properties": {
"body": {
"type": "text"
}
}
},
"timestamp": {
"type": "date"
}
}
},
"aliases": {}
}
PUT $[[SETUP_INDEX_PREFIX]]async_bulk_results-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]async_bulk_results":{
"is_write_index":true
}
}
}
DELETE _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]alert-history-30days-retention
PUT _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]alert-history-30days-retention
{
"policy": {
"description": "infini alert history hot delete workflow",
"default_state": "hot",
"ism_template": {
"index_patterns": ["$[[SETUP_INDEX_PREFIX]]alert-history*"],
"priority": 100
},
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "30d",
"min_size": "50gb"
}
},
{
"index_priority": {
"priority": 100
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
]
}
]
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]alert-history-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]alert-history*"
],
"settings" : {
"index" : {
"format" : "7",
"plugins.index_state_management.rollover_alias": "$[[SETUP_INDEX_PREFIX]]alert-history",
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]alert-history-00001
{
"settings": {
"refresh_interval": "5s"
},
"aliases":{
"$[[SETUP_INDEX_PREFIX]]alert-history":{
"is_write_index":true
}
},
"mappings": {
"properties" : {
"condition" : {
"properties" : {
"items" : {
"properties" : {
"expression" : {
"type" : "keyword",
"ignore_above" : 256
},
"minimum_period_match" : {
"type" : "long"
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
},
"severity" : {
"type" : "keyword",
"ignore_above" : 256
},
"values" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"operator" : {
"type" : "keyword",
"ignore_above" : 256
}
}
},
"condition_result" : {
"type" : "object",
"enabled" : false
},
"context" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"created" : {
"type" : "date"
},
"expression" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"id" : {
"type" : "keyword"
},
"is_escalated" : {
"type" : "boolean"
},
"is_notified" : {
"type" : "boolean"
},
"message" : {
"type" : "keyword",
"ignore_above" : 256
},
"objects" : {
"type" : "keyword",
"copy_to" : [
"search_text"
]
},
"resource_id" : {
"type" : "keyword"
},
"resource_name" : {
"type" : "keyword"
},
"rule_id" : {
"type" : "keyword"
},
"rule_name" : {
"type" : "keyword"
},
"search_text" : {
"type" : "text",
"analyzer" : "suggest_text_search",
"index_prefixes" : {
"min_chars" : 2,
"max_chars" : 5
},
"index_phrases" : true
},
"severity" : {
"type" : "keyword"
},
"state" : {
"type" : "keyword",
"ignore_above" : 256
},
"title" : {
"type" : "keyword"
},
"updated" : {
"type" : "date"
}
}
}
}
DELETE _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]activities-30days-retention
PUT _plugins/_ism/policies/ilm_$[[SETUP_INDEX_PREFIX]]activities-30days-retention
{
"policy": {
"description": "infini activities hot delete workflow",
"default_state": "hot",
"ism_template": {
"index_patterns": ["$[[SETUP_INDEX_PREFIX]]activities*"],
"priority": 100
},
"states": [
{
"name": "hot",
"actions": [
{
"rollover": {
"min_index_age": "30d",
"min_size": "50gb"
}
},
{
"index_priority": {
"priority": 100
}
}
],
"transitions": [
{
"state_name": "delete",
"conditions": {
"min_index_age": "30d"
}
}
]
},
{
"name": "delete",
"actions": [
{
"delete": {}
}
]
}
]
}
}
PUT _template/$[[SETUP_INDEX_PREFIX]]activities-rollover
{
"order" : 100000,
"index_patterns" : [
"$[[SETUP_INDEX_PREFIX]]activities*"
],
"settings" : {
"index" : {
"format" : "7",
"plugins.index_state_management.rollover_alias": "$[[SETUP_INDEX_PREFIX]]activities",
"codec" : "best_compression",
"number_of_shards" : "1",
"translog.durability":"async"
}
},
"mappings" : {
"dynamic_templates" : [
{
"strings" : {
"mapping" : {
"ignore_above" : 256,
"type" : "keyword"
},
"match_mapping_type" : "string"
}
}
]
},
"aliases" : { }
}
PUT $[[SETUP_INDEX_PREFIX]]activities-00001
{
"mappings": {
"dynamic_templates": [
{
"strings": {
"match_mapping_type": "string",
"mapping": {
"ignore_above": 256,
"type": "keyword"
}
}
}
],
"properties": {
"changelog": {
"type": "object",
"enabled": false
},
"id": {
"type": "keyword"
},
"metadata": {
"properties": {
"category": {
"type": "keyword",
"ignore_above": 256
},
"group": {
"type": "keyword",
"ignore_above": 256
},
"name": {
"type": "keyword",
"ignore_above": 256
},
"type": {
"type": "keyword",
"ignore_above": 256
}
}
},
"payload": {
"type": "object",
"enabled": false
},
"timestamp": {
"type": "date"
}
}
},
"settings": {
"index": {
"refresh_interval": "5s",
"mapping": {
"total_fields": {
"limit": "20000"
}
},
"max_result_window": "10000000",
"analysis": {
"analyzer": {
"suggest_text_search": {
"filter": [
"word_delimiter"
],
"tokenizer": "classic"
}
}
}
}
},
"aliases": {
"$[[SETUP_INDEX_PREFIX]]activities": {
"is_write_index": true
}
}
}

View File

@ -1,14 +0,0 @@
configs.template:
- name: "default_ingest_config"
path: ./config/ingest_config.tpl
variable:
INGEST_CLUSTER_ID: infini_default_ingest_cluster
INGEST_CLUSTER_ENDPOINT: [ "https://localhost:9200" ]
INGEST_CLUSTER_USERNAME: "admin"
CLUSTER_VER: "1.6.0"
CLUSTER_DISTRIBUTION: "easysearch"
INDEX_PREFIX: ".infini_"
#MANAGED_CONFIG_VERSION: 2
#MANAGED: true

View File

@ -1,24 +0,0 @@
configs: #define configs group
general_ingest_template: #group name
files:
- ./templates/ingest_config.tpl
- ./templates/task_config.tpl
- ./configs/ingest_config.yml
#instances: #define which config instance should fetch
# _all: #instance group
# plugins:
# - ingest
# instances:
# - ck0mkk805f5virpsejp0
# - ckjrpdg05f5lrfp8qlng
# configs:
# - general_ingest_template
# secrets:
# - ingest_cluster_password
secrets:
ingest_cluster_password: #group name
keystore:
ingest_cluster_password:
type: plaintext
value: "d7cc48e69a41dac719fb"

View File

@ -1,97 +0,0 @@
elasticsearch:
- name: $[[INGEST_CLUSTER_ID]]
enabled: true
endpoints: $[[INGEST_CLUSTER_ENDPOINT]]
discovery:
enabled: false
basic_auth:
username: $[[INGEST_CLUSTER_USERNAME]]
password: $[[keystore.ingest_cluster_password]]
metrics:
enabled: true
queue: metrics
network:
enabled: true
summary: true
details: true
memory:
metrics:
- swap
- memory
disk:
metrics:
- iops
- usage
cpu:
metrics:
- idle
- system
- user
- iowait
- load
instance:
enabled: true
elastic:
availability_check:
enabled: false
pipeline:
- name: merge_logs
auto_start: true
keep_running: true
processor:
- indexing_merge:
elasticsearch: "$[[INGEST_CLUSTER_ID]]"
index_name: ".infini_logs"
type_name: "_doc"
input_queue: "logs"
idle_timeout_in_seconds: 10
output_queue:
name: "merged_requests"
worker_size: 1
bulk_size_in_mb: 5
- name: merge_metrics
auto_start: true
keep_running: true
processor:
- indexing_merge:
elasticsearch: "$[[INGEST_CLUSTER_ID]]"
index_name: ".infini_metrics"
type_name: "_doc"
input_queue: "metrics"
output_queue:
name: "merged_requests"
worker_size: 1
bulk_size_in_mb: 5
- name: ingest_merged_requests
enabled: true
auto_start: true
keep_running: true
processor:
- bulk_indexing:
max_worker_size: 1
verbose_bulk_result: false
bulk:
batch_size_in_mb: 5
batch_size_in_docs: 5000
max_retry_times: 0
invalid_queue: ""
response_handle:
include_index_stats: false
include_action_stats: false
output_bulk_stats: false
include_error_details: true
save_error_results: true
save_success_results: false
save_busy_results: false
consumer:
fetch_max_messages: 5
queues:
type: indexing_merge
when:
cluster_available: ["$[[INGEST_CLUSTER_ID]]"]
#MANAGED_CONFIG_VERSION: 16
#MANAGED: true

View File

@ -1,90 +0,0 @@
env:
CLUSTER_PASSWORD: $[[keystore.$[[CLUSTER_ID]]_password]]
elasticsearch:
- id: $[[CLUSTER_ID]]
name: $[[CLUSTER_ID]]
enabled: true
endpoints: $[[CLUSTER_ENDPOINT]]
discovery:
enabled: false
basic_auth:
username: $[[CLUSTER_USERNAME]]
password: $[[CLUSTER_PASSWORD]]
pipeline:
#clsuter level metrics
- auto_start: $[[CLUSTER_LEVEL_TASKS_ENABLED]]
enabled: $[[CLUSTER_LEVEL_TASKS_ENABLED]]
keep_running: true
singleton: true
name: collect_$[[CLUSTER_ID]]_es_cluster_stats
retry_delay_in_ms: 10000
processor:
- es_cluster_stats:
elasticsearch: $[[CLUSTER_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
when:
cluster_available: ["$[[CLUSTER_ID]]"]
- auto_start: $[[CLUSTER_LEVEL_TASKS_ENABLED]]
enabled: $[[CLUSTER_LEVEL_TASKS_ENABLED]]
keep_running: true
singleton: true
name: collect_$[[CLUSTER_ID]]_es_index_stats
retry_delay_in_ms: 10000
processor:
- es_index_stats:
elasticsearch: $[[CLUSTER_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
when:
cluster_available: ["$[[CLUSTER_ID]]"]
- auto_start: $[[CLUSTER_LEVEL_TASKS_ENABLED]]
enabled: $[[CLUSTER_LEVEL_TASKS_ENABLED]]
keep_running: true
singleton: true
name: collect_$[[CLUSTER_ID]]_es_cluster_health
retry_delay_in_ms: 10000
processor:
- es_cluster_health:
elasticsearch: $[[CLUSTER_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
when:
cluster_available: ["$[[CLUSTER_ID]]"]
#node level metrics
- auto_start: $[[NODE_LEVEL_TASKS_ENABLED]]
enabled: $[[NODE_LEVEL_TASKS_ENABLED]]
keep_running: true
name: collect_$[[CLUSTER_ID]]_es_node_stats
retry_delay_in_ms: 10000
processor:
- es_node_stats:
elasticsearch: $[[CLUSTER_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
when:
cluster_available: ["$[[CLUSTER_ID]]"]
#node logs
- auto_start: $[[NODE_LEVEL_TASKS_ENABLED]]
enabled: $[[NODE_LEVEL_TASKS_ENABLED]]
keep_running: true
name: collect_$[[CLUSTER_ID]]_es_logs
retry_delay_in_ms: 10000
processor:
- es_logs_processor:
elasticsearch: $[[CLUSTER_ID]]
labels:
cluster_id: $[[CLUSTER_ID]]
logs_path: $[[NODE_LOGS_PATH]]
queue_name: logs
when:
cluster_available: ["$[[CLUSTER_ID]]"]
#MANAGED_CONFIG_VERSION: 11
#MANAGED: true

View File

@ -1,20 +1,16 @@
package task
import (
"bufio"
"bytes"
"crypto/md5"
"encoding/hex"
"fmt"
"infini.sh/framework/core/kv"
"infini.sh/framework/core/model"
"io"
"net/http"
uri2 "net/url"
"path"
"path/filepath"
"runtime"
"time"
keystore2 "infini.sh/framework/lib/keystore"
"infini.sh/framework/modules/security"
"strings"
log "github.com/cihub/seelog"
"github.com/valyala/fasttemplate"
"golang.org/x/crypto/bcrypt"
@ -35,8 +31,14 @@ import (
"infini.sh/framework/modules/elastic/adapter"
elastic3 "infini.sh/framework/modules/elastic/api"
elastic1 "infini.sh/framework/modules/elastic/common"
"infini.sh/framework/modules/security"
_ "infini.sh/framework/modules/security"
"infini.sh/framework/plugins/replay"
"io"
"net/http"
uri2 "net/url"
"path"
"runtime"
"time"
)
type Module struct {
@ -59,6 +61,8 @@ func (module *Module) Setup() {
api.HandleAPIMethod(api.POST, "/setup/_validate", module.validate)
api.HandleAPIMethod(api.POST, "/setup/_initialize", module.initialize)
api.HandleAPIMethod(api.POST, "/setup/_validate_secret", module.validateSecret)
api.HandleAPIMethod(api.POST, "/setup/_initialize_template", module.initializeTemplate)
elastic3.InitTestAPI()
}
@ -115,6 +119,7 @@ type SetupRequest struct {
BootstrapUsername string `json:"bootstrap_username"`
BootstrapPassword string `json:"bootstrap_password"`
CredentialSecret string `json:"credential_secret"`
InitializeTemplate string `json:"initialize_template"`
}
var GlobalSystemElasticsearchID = "infini_default_system_cluster"
@ -322,42 +327,23 @@ func (module *Module) initTempClient(r *http.Request) (error, elastic.API, Setup
func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if !global.Env().SetupRequired() {
//handle setup timeout
rkey, err := keystore.GetValue(credential.SecretKey)
if err != nil {
module.WriteError(w, err.Error(), 500)
return
}
request := SetupRequest{}
err = module.DecodeJSON(r, &request)
if err != nil {
module.WriteError(w, err.Error(), 500)
return
}
h := md5.New()
rawSecret := []byte(request.CredentialSecret)
h.Write(rawSecret)
secret := make([]byte, 32)
hex.Encode(secret, h.Sum(nil))
if bytes.Compare(rkey, secret) == 0 {
module.WriteJSON(w, util.MapStr{
"success": true,
}, 200)
}else{
module.WriteError(w, "invalid credential secret", 500)
}
module.WriteError(w, "setup not permitted", 500)
return
}
success := false
var errType string
var fixTips string
var code int
code = 200
var (
success = false
errType string
fixTips string
code = 200
secretMismatch = false
)
defer func() {
global.Env().CheckSetup()
result := util.MapStr{}
result := util.MapStr{
"secret_mismatch": secretMismatch,
}
result["success"] = success
if r := recover(); r != nil {
@ -390,8 +376,9 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
if err != nil {
panic(err)
}
request.CredentialSecret = strings.TrimSpace(request.CredentialSecret)
if request.CredentialSecret == "" {
panic("invalid credential secret")
panic("miss credential secret")
}
scheme := "http"
if r.TLS != nil {
@ -424,106 +411,58 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
//处理ORM
handler := elastic2.ElasticORM{Client: client, Config: cfg1}
orm.Register("elastic_setup_"+util.GetUUID(), &handler)
//生成凭据并保存
h := md5.New()
rawSecret := []byte(request.CredentialSecret)
h.Write(rawSecret)
secret := make([]byte, 32)
hex.Encode(secret, h.Sum(nil))
err = credential.InitSecret(nil, secret)
if err != nil {
//validate secret key
exists, err := validateCredentialSecret(&handler, request.CredentialSecret)
if err != nil && err != errSecretMismatch {
panic(err)
}
if !request.Skip {
//处理模版
elastic2.InitTemplate(true)
//处理生命周期
//TEMPLATE_NAME
//INDEX_PREFIX
ver := elastic.GetClient(GlobalSystemElasticsearchID).GetVersion()
dslTplFileName := "initialization.tpl"
if ver.Distribution == "" || ver.Distribution == elastic.Elasticsearch { //elasticsearch distribution
majorVersion := elastic.GetClient(GlobalSystemElasticsearchID).GetMajorVersion()
if majorVersion == 6 {
dslTplFileName = "initialization_v6.tpl"
} else if majorVersion <= 5 {
dslTplFileName = "initialization_v5.tpl"
}
}
dslTplFile := path.Join(global.Env().GetConfigDir(), dslTplFileName)
dslFile := path.Join(global.Env().GetConfigDir(), "initialization.dsl")
if !util.FileExists(dslTplFile) {
log.Error(filepath.Abs(dslTplFile))
panic("template file for setup was missing")
}
var dsl []byte
dsl, err = util.FileGetContent(dslTplFile)
if err == errSecretMismatch {
secretMismatch = true
}
//不存在或者密钥不匹配时保存凭据密钥
if err == errSecretMismatch || !exists{
h := md5.New()
rawSecret := []byte(request.CredentialSecret)
h.Write(rawSecret)
secret := make([]byte, 32)
hex.Encode(secret, h.Sum(nil))
err = credential.InitSecret(nil, secret)
if err != nil {
panic(err)
}
var dslWriteSuccess = false
if len(dsl) > 0 {
var tpl *fasttemplate.Template
tpl, err = fasttemplate.NewTemplate(string(dsl), "$[[", "]]")
if err != nil {
panic(err)
}
if tpl != nil {
output := tpl.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {
switch tag {
case "TEMPLATE_NAME":
return w.Write([]byte(cfg1.TemplateName))
case "INDEX_PREFIX":
return w.Write([]byte(cfg1.IndexPrefix))
case "RESOURCE_ID":
return w.Write([]byte(cfg.ID))
case "RESOURCE_NAME":
return w.Write([]byte(cfg.Name))
case "USER_ID":
return w.Write([]byte("default_user_" + request.BootstrapUsername))
case "USERNAME":
return w.Write([]byte(request.BootstrapUsername))
}
panic(errors.Errorf("unknown tag: %v", tag))
})
_, err = util.FilePutContent(dslFile, output)
if err != nil {
panic(err)
}
//处理索引
security.InitSchema() //register user index
elastic2.InitSchema()
toSaveCfg := cfg
oldCfg := elastic.ElasticsearchConfig{}
oldCfg.ID = toSaveCfg.ID
_, _ = orm.Get(&oldCfg)
//当原系统集群存在时更新配置
if oldCfg.Name != "" {
toSaveCfg = oldCfg
toSaveCfg.Endpoint = cfg.Endpoint
toSaveCfg.Schema = cfg.Schema
toSaveCfg.Host = cfg.Host
toSaveCfg.Source = cfg.Source
toSaveCfg.Version = cfg.Version
toSaveCfg.Distribution = cfg.Distribution
}
if request.Cluster.Username != "" || request.Cluster.Password != "" {
var reuseOldCred = false
if oldCfg.CredentialID != "" && !secretMismatch {
basicAuth, _ := elastic1.GetBasicAuth(&oldCfg)
if basicAuth != nil {
if basicAuth.Username == request.Cluster.Username && basicAuth.Password == request.Cluster.Password {
reuseOldCred = true
}
dslWriteSuccess = true
}
}
if dslWriteSuccess {
lines := util.FileGetLines(dslFile)
var (
username string
password string
)
if cfg.BasicAuth != nil {
username = cfg.BasicAuth.Username
password = cfg.BasicAuth.Password
}
_, err, _ := replay.ReplayLines(pipeline.AcquireContext(pipeline.PipelineConfigV2{}), lines, cfg.Schema, cfg.Host, username, password)
if err != nil {
log.Error(err)
}
}
//处理索引
elastic2.InitSchema()
//init security
security.InitSchema()
toSaveCfg := cfg
if request.Cluster.Username != "" || request.Cluster.Password != "" {
if reuseOldCred {
toSaveCfg.CredentialID = oldCfg.CredentialID
}else{
cred := credential.Credential{
Name: "INFINI_SYSTEM",
Type: credential.BasicAuth,
@ -542,44 +481,49 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
}
toSaveCfg.CredentialID = cred.ID
cfg.CredentialID = cred.ID
now := time.Now()
cred.Created = &now
err = orm.Save(nil, &cred)
if err != nil {
panic(err)
}
toSaveCfg.BasicAuth = nil
}
}
//保存默认集群
err = orm.Create(nil, &toSaveCfg)
//保存默认集群
t:=time.Now()
toSaveCfg.Created=&t
err = orm.Save(nil, &toSaveCfg)
if err != nil {
panic(err)
}
if request.BootstrapUsername != "" && request.BootstrapPassword != "" {
//Save bootstrap user
user := rbac.User{}
user.ID = "default_user_" + request.BootstrapUsername
user.Username = request.BootstrapUsername
user.Nickname = request.BootstrapUsername
var hash []byte
hash, err = bcrypt.GenerateFromPassword([]byte(request.BootstrapPassword), bcrypt.DefaultCost)
if err != nil {
panic(err)
}
if request.BootstrapUsername != "" && request.BootstrapPassword != "" {
//Save bootstrap user
user := rbac.User{}
user.ID = "default_user_" + request.BootstrapUsername
user.Username = request.BootstrapUsername
user.Nickname = request.BootstrapUsername
var hash []byte
hash, err = bcrypt.GenerateFromPassword([]byte(request.BootstrapPassword), bcrypt.DefaultCost)
if err != nil {
panic(err)
}
user.Password = string(hash)
role := []rbac.UserRole{}
role = append(role, rbac.UserRole{
ID: rbac.RoleAdminName,
Name: rbac.RoleAdminName,
})
user.Roles = role
err = orm.Create(nil, &user)
if err != nil {
panic(err)
}
user.Password = string(hash)
role := []rbac.UserRole{}
role = append(role, rbac.UserRole{
ID: rbac.RoleAdminName,
Name: rbac.RoleAdminName,
})
user.Roles = role
now := time.Now()
user.Created = &now
err = orm.Save(nil, &user)
if err != nil {
panic(err)
}
}
err = keystore.SetValue("SYSTEM_CLUSTER_PASS", []byte(cfg.BasicAuth.Password))
if err != nil {
@ -605,6 +549,227 @@ func (module *Module) initialize(w http.ResponseWriter, r *http.Request, ps http
if err != nil {
panic(err)
}
//update credential state
q := util.MapStr{
"query": util.MapStr{
"range": util.MapStr{
"created": util.MapStr{
"lte": "now-30s",
},
},
},
"script": util.MapStr{
"source": fmt.Sprintf("ctx._source['invalid'] = %v", secretMismatch),
},
}
err = orm.UpdateBy(credential.Credential{}, util.MustToJSONBytes(q))
if err != nil {
log.Error(err)
}
success = true
}
func (module *Module) validateSecret(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
err, client, request := module.initTempClient(r)
if err != nil {
module.WriteError(w, err.Error(), http.StatusInternalServerError)
return
}
handler := elastic2.ElasticORM{Client: client, Config: cfg1}
_, err = validateCredentialSecret(&handler, request.CredentialSecret)
if err != nil && err != errSecretMismatch {
module.WriteError(w, err.Error(), http.StatusInternalServerError)
return
}
module.WriteJSON(w, util.MapStr{
"success": err == nil,
}, http.StatusOK)
}
var errSecretMismatch = fmt.Errorf("invalid credential secret")
func validateCredentialSecret(ormHandler orm.ORM, credentialSecret string) (bool, error) {
rkey, err := keystore.GetValue(credential.SecretKey)
var exists bool
if err != nil && err != keystore2.ErrKeyDoesntExists {
return exists, err
}
h := md5.New()
rawSecret := []byte(credentialSecret)
h.Write(rawSecret)
secret := make([]byte, 32)
hex.Encode(secret, h.Sum(nil))
if err == nil {
exists = true
if bytes.Compare(rkey, secret) != 0 {
return exists, errSecretMismatch
}
}else {
exists = false
tempCred := credential.Credential{}
var result orm.Result
err, result = ormHandler.Search(&tempCred, &orm.Query{
Size: 1,
})
if err != nil {
return exists, err
}
if len(result.Result) > 0 {
buf := util.MustToJSONBytes(result.Result[0])
util.MustFromJSONBytes(buf, &tempCred)
tempCred.SetSecret(secret)
_, err = tempCred.Decode()
if err != nil {
return exists, errSecretMismatch
}
}
}
return exists, nil
}
func (module *Module) initializeTemplate(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {
if !global.Env().SetupRequired() {
module.WriteError(w, "setup not permitted", 500)
return
}
defer func() {
if v := recover(); v != nil {
module.WriteJSON(w, util.MapStr{
"success": false,
"log": fmt.Sprintf("%v", v),
}, http.StatusOK)
}
}()
request := SetupRequest{}
err := module.DecodeJSON(r, &request)
if err != nil {
panic(err)
}
ver := elastic.GetClient(GlobalSystemElasticsearchID).GetVersion()
if ver.Distribution == ""{
ver.Distribution=elastic.Elasticsearch
}
baseDir := path.Join(global.Env().GetConfigDir(),"setup")
var (
dslTplFileName = ""
useCommon = true
)
switch request.InitializeTemplate {
case "template_ilm":
useCommon = false
dslTplFileName = "template_ilm.tpl"
elastic2.InitTemplate(true)
case "alerting":
dslTplFileName = "alerting.tpl"
case "insight":
dslTplFileName = "insight.tpl"
case "view":
dslTplFileName = "view.tpl"
case "agent":
dslTplFileName = "agent.tpl"
default:
panic(fmt.Sprintf("unsupport template name [%s]", request.InitializeTemplate))
}
if useCommon {
baseDir = path.Join(baseDir, "common")
}else{
baseDir = path.Join(baseDir, ver.Distribution)
}
docType := "_doc"
switch ver.Distribution {
case elastic.Elasticsearch:
majorVersion := elastic.GetClient(GlobalSystemElasticsearchID).GetMajorVersion()
if !useCommon{
if majorVersion == 6 {
baseDir = path.Join(baseDir, "v6")
} else if majorVersion <= 5 {
baseDir = path.Join(baseDir, "v5")
}
}
if majorVersion < 7 {
docType = "doc"
}
break
case elastic.Easysearch:
break
case elastic.Opensearch:
break
}
dslTplFile := path.Join(baseDir ,dslTplFileName)
if !util.FileExists(dslTplFile) {
panic(errors.Errorf("template file %v for setup was missing",dslTplFile))
}
var dsl []byte
dsl, err = util.FileGetContent(dslTplFile)
if err != nil {
panic(err)
}
if len(dsl) == 0 {
panic(fmt.Sprintf("got empty template [%s]", dslTplFile))
}
var tpl *fasttemplate.Template
tpl, err = fasttemplate.NewTemplate(string(dsl), "$[[", "]]")
if err != nil {
module.WriteJSON(w, util.MapStr{
"success": false,
"log": fmt.Sprintf("new fasttemplate [%s] error: ", err.Error()),
}, http.StatusOK)
return
}
output := tpl.ExecuteFuncString(func(w io.Writer, tag string) (int, error) {
switch tag {
case "SETUP_TEMPLATE_NAME":
return w.Write([]byte(cfg1.TemplateName))
case "SETUP_INDEX_PREFIX":
return w.Write([]byte(cfg1.IndexPrefix))
case "SETUP_RESOURCE_ID":
return w.Write([]byte(cfg.ID))
case "SETUP_RESOURCE_NAME":
return w.Write([]byte(cfg.Name))
case "SETUP_USER_ID":
return w.Write([]byte("default_user_" + request.BootstrapUsername))
case "SETUP_USERNAME":
return w.Write([]byte(request.BootstrapUsername))
case "SETUP_DOC_TYPE":
return w.Write([]byte(docType))
}
//ignore unresolved variable
return w.Write([]byte("$[["+tag+"]]"))
})
br := bytes.NewReader([]byte(output))
scanner := bufio.NewScanner(br)
scanner.Buffer(make([]byte, 10*1024*1024), 10*1024*1024)
scanner.Split(bufio.ScanLines)
var lines []string
for scanner.Scan() {
lines = append(lines, scanner.Text())
}
if request.Cluster.Endpoint != "" && request.Cluster.Host == "" {
uri, err := uri2.Parse(request.Cluster.Endpoint)
if err != nil {
panic(err)
}
request.Cluster.Host = uri.Host
request.Cluster.Schema = uri.Scheme
}
_, err, _ = replay.ReplayLines(pipeline.AcquireContext(pipeline.PipelineConfigV2{}), lines, request.Cluster.Schema, request.Cluster.Host, request.Cluster.Username, request.Cluster.Password)
if err != nil {
module.WriteJSON(w, util.MapStr{
"success": false,
"log": fmt.Sprintf("initalize template [%s] error: ", err.Error()),
}, http.StatusOK)
return
}
module.WriteJSON(w, util.MapStr{
"success": true,
"log": fmt.Sprintf("initalize template [%s] succeed", request.InitializeTemplate),
}, http.StatusOK)
}