From 118d52abbce1d1e413679a6dca9469b08614de8f Mon Sep 17 00:00:00 2001 From: Kunal Shroff Date: Thu, 2 Dec 2021 13:41:30 -0500 Subject: [PATCH] #2072 cleanup unnecessary startup scripts and updated readme --- services/alarm-logger/README.md | 12 +- .../delete_alarm_index.sh | 0 .../delete_alarm_template.sh | 0 .../startup/create_alarm_index.sh | 133 ------------------ .../startup/create_alarm_template.sh | 133 ------------------ 5 files changed, 6 insertions(+), 272 deletions(-) rename services/alarm-logger/{startup => data_management}/delete_alarm_index.sh (100%) rename services/alarm-logger/{startup => data_management}/delete_alarm_template.sh (100%) delete mode 100644 services/alarm-logger/startup/create_alarm_index.sh delete mode 100644 services/alarm-logger/startup/create_alarm_template.sh diff --git a/services/alarm-logger/README.md b/services/alarm-logger/README.md index 820cec4508..44846b75a8 100644 --- a/services/alarm-logger/README.md +++ b/services/alarm-logger/README.md @@ -14,11 +14,6 @@ elasticsearch defaults to port 9200, however if elasticsearch is configured to u /src/main/resources/alarm_logging_preferences.properties - -### Create an elasticsearch index - -Use `/startup/create_alarm_template.sh` if you indent to create a new index each day, week or month. - ### Run the alarm logging service #### Build the alarm server @@ -77,7 +72,12 @@ curl -X GET 'http://localhost:9200/accelerator_alarms_state_2019-02-01/_search?f ## Data Management -The two most common aspects for effectively configuring the alarm logger are: +The most common aspects for effectively configuring the alarm logger are: + +### Creating an elasticsearch index + +The new elastic indices are created based on the templates which are automatically created +when the service is first launched. ### Index period diff --git a/services/alarm-logger/startup/delete_alarm_index.sh b/services/alarm-logger/data_management/delete_alarm_index.sh similarity index 100% rename from services/alarm-logger/startup/delete_alarm_index.sh rename to services/alarm-logger/data_management/delete_alarm_index.sh diff --git a/services/alarm-logger/startup/delete_alarm_template.sh b/services/alarm-logger/data_management/delete_alarm_template.sh similarity index 100% rename from services/alarm-logger/startup/delete_alarm_template.sh rename to services/alarm-logger/data_management/delete_alarm_template.sh diff --git a/services/alarm-logger/startup/create_alarm_index.sh b/services/alarm-logger/startup/create_alarm_index.sh deleted file mode 100644 index e4d1110483..0000000000 --- a/services/alarm-logger/startup/create_alarm_index.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/sh -if [ $# -ne 1 ] -then - echo "Usage: create_alarm_index.sh accelerator" - exit 1 -fi - -es_host=localhost -es_port=9200 - -# Create the elastic index with the correct mapping for alarm state messages. -# Create the Index -# Set the mapping -curl -H 'Content-Type: application/json' -XPUT http://${es_host}:${es_port}/${1}_alarms_state?include_type_name=true -d' -{ - "mappings" : { - "alarm" : { - "properties" : { - "APPLICATION-ID" : { - "type" : "text" - }, - "config" : { - "type" : "keyword" - }, - "pv" : { - "type" : "keyword" - }, - "severity" : { - "type" : "keyword" - }, - "latch" : { - "type" : "boolean" - }, - "message" : { - "type" : "keyword" - }, - "value" : { - "type" : "keyword" - }, - "time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - }, - "message_time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - }, - "current_severity" : { - "type" : "keyword" - }, - "current_message" : { - "type" : "keyword" - }, - "mode" : { - "type" : "keyword" - } - } - } - } -} -' - -# Create the elastic index with the correct mapping for alarm command messages. -# Create the Index -# Set the mapping -curl -H 'Content-Type: application/json' -XPUT http://${es_host}:${es_port}/${1}_alarms_cmd?include_type_name=true -d' -{ - "mappings" : { - "alarm_cmd" : { - "properties" : { - "APPLICATION-ID" : { - "type" : "text" - }, - "config" : { - "type" : "keyword" - }, - "user" : { - "type" : "keyword" - }, - "host" : { - "type" : "keyword" - }, - "command" : { - "type" : "keyword" - }, - "message_time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - } - } - } - } -} -' - -# Create the elastic index with the correct mapping for alarm config messages. -# Create the Index -# Set the mapping -curl -H 'Content-Type: application/json' -XPUT http://${es_host}:${es_port}/${1}_alarms_config?include_type_name=true -d' -{ - "mappings" : { - "alarm_config" : { - "properties" : { - "APPLICATION-ID" : { - "type" : "text" - }, - "config" : { - "type" : "keyword" - }, - "user" : { - "type" : "keyword" - }, - "host" : { - "type" : "keyword" - }, - "enabled" : { - "type" : "keyword" - }, - "latching" : { - "type" : "keyword" - }, - "config_msg" : { - "type" : "keyword" - }, - "message_time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - } - } - } - } -} -' diff --git a/services/alarm-logger/startup/create_alarm_template.sh b/services/alarm-logger/startup/create_alarm_template.sh deleted file mode 100644 index 13c982e2c3..0000000000 --- a/services/alarm-logger/startup/create_alarm_template.sh +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/sh - -es_host=localhost -es_port=9200 - -# The mapping names used in here need to match those used in the ElasticClientHelper: -# "alarm", ""alarm_cmd", "alarm_config" - -# Create the elastic template with the correct mapping for alarm state messages. -curl -XPUT http://${es_host}:${es_port}/_template/alarms_state_template?include_type_name=true -H 'Content-Type: application/json' -d' -{ - "index_patterns":["*_alarms_state*"], - "mappings" : { - "alarm" : { - "properties" : { - "APPLICATION-ID" : { - "type" : "text" - }, - "config" : { - "type" : "keyword" - }, - "pv" : { - "type" : "keyword" - }, - "severity" : { - "type" : "keyword" - }, - "latch" : { - "type" : "boolean" - }, - "message" : { - "type" : "keyword" - }, - "value" : { - "type" : "keyword" - }, - "time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - }, - "message_time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - }, - "current_severity" : { - "type" : "keyword" - }, - "current_message" : { - "type" : "keyword" - }, - "mode" : { - "type" : "keyword" - } - } - } - } -} -' - -# Create the elastic template with the correct mapping for alarm command messages. -curl -XPUT http://${es_host}:${es_port}/_template/alarms_cmd_template?include_type_name=true -H 'Content-Type: application/json' -d' -{ - "index_patterns":["*_alarms_cmd*"], - "mappings" : { - "alarm_cmd" : { - "properties" : { - "APPLICATION-ID" : { - "type" : "text" - }, - "config" : { - "type" : "keyword" - }, - "user" : { - "type" : "keyword" - }, - "host" : { - "type" : "keyword" - }, - "command" : { - "type" : "keyword" - }, - "message_time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - } - } - } - } -} -' - -# Create the elastic template with the correct mapping for alarm config messages. -curl -XPUT http://${es_host}:${es_port}/_template/alarms_config_template?include_type_name=true -H 'Content-Type: application/json' -d' -{ - "index_patterns":["*_alarms_config*"], - "mappings" : { - "alarm_config" : { - "properties" : { - "APPLICATION-ID" : { - "type" : "text" - }, - "config" : { - "type" : "keyword" - }, - "user" : { - "type" : "keyword" - }, - "host" : { - "type" : "keyword" - }, - "enabled" : { - "type" : "keyword" - }, - "latching" : { - "type" : "keyword" - }, - "config_msg" : { - "type" : "keyword" - }, - "message_time" : { - "type" : "date", - "format" : "yyyy-MM-dd HH:mm:ss.SSS" - } - } - } - } -} -' - - -echo "Alarm templates:" -curl -X GET "${es_host}:${es_port}/_template/*alarm*" -