mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Merge pull request #767 from Security-Onion-Solutions/fix/so_index_transition
Fix/so index transition
This commit is contained in:
@@ -166,8 +166,7 @@ cat << EOF
|
|||||||
What elasticsearch index do you want to use?
|
What elasticsearch index do you want to use?
|
||||||
Below are the default Index Patterns used in Security Onion:
|
Below are the default Index Patterns used in Security Onion:
|
||||||
|
|
||||||
*:logstash-*
|
*:so-ids-*
|
||||||
*:logstash-beats-*
|
|
||||||
*:elastalert_status*
|
*:elastalert_status*
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|||||||
@@ -24,9 +24,8 @@ actions:
|
|||||||
disable_action: False
|
disable_action: False
|
||||||
filters:
|
filters:
|
||||||
- filtertype: pattern
|
- filtertype: pattern
|
||||||
kind: prefix
|
kind: regex
|
||||||
value: logstash-
|
value: '^(logstash-.*|so-.*)$'
|
||||||
exclude:
|
|
||||||
- filtertype: age
|
- filtertype: age
|
||||||
source: name
|
source: name
|
||||||
direction: older
|
direction: older
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ actions:
|
|||||||
disable_action: False
|
disable_action: False
|
||||||
filters:
|
filters:
|
||||||
- filtertype: pattern
|
- filtertype: pattern
|
||||||
kind: prefix
|
kind: regex
|
||||||
value: logstash-
|
value: '^(logstash-.*|so-.*)$'
|
||||||
- filtertype: space
|
- filtertype: space
|
||||||
source: creation_date
|
source: creation_date
|
||||||
use_age: True
|
use_age: True
|
||||||
|
|||||||
@@ -33,17 +33,17 @@ LOG="/opt/so/log/curator/so-curator-closed-delete.log"
|
|||||||
|
|
||||||
# Check for 2 conditions:
|
# Check for 2 conditions:
|
||||||
# 1. Are Elasticsearch indices using more disk space than LOG_SIZE_LIMIT?
|
# 1. Are Elasticsearch indices using more disk space than LOG_SIZE_LIMIT?
|
||||||
# 2. Are there any closed logstash- indices that we can delete?
|
# 2. Are there any closed logstash-, or so- indices that we can delete?
|
||||||
# If both conditions are true, keep on looping until one of the conditions is false.
|
# If both conditions are true, keep on looping until one of the conditions is false.
|
||||||
while [[ $(du -hs --block-size=1GB /nsm/elasticsearch/nodes | awk '{print $1}' ) -gt "{{LOG_SIZE_LIMIT}}" ]] &&
|
while [[ $(du -hs --block-size=1GB /nsm/elasticsearch/nodes | awk '{print $1}' ) -gt "{{LOG_SIZE_LIMIT}}" ]] &&
|
||||||
curl -s {{ELASTICSEARCH_HOST}}:{{ELASTICSEARCH_PORT}}/_cat/indices | grep "^ close logstash-" > /dev/null; do
|
curl -s {{ELASTICSEARCH_HOST}}:{{ELASTICSEARCH_PORT}}/_cat/indices | grep -E "^ close (logstash-|so-)" > /dev/null; do
|
||||||
|
|
||||||
# We need to determine OLDEST_INDEX.
|
# We need to determine OLDEST_INDEX.
|
||||||
# First, get the list of closed indices that are prefixed with "logstash-".
|
# First, get the list of closed indices that are prefixed with "logstash-" or "so-".
|
||||||
# For example: logstash-ids-YYYY.MM.DD
|
# For example: logstash-ids-YYYY.MM.DD
|
||||||
# Then, sort by date by telling sort to use hyphen as delimiter and then sort on the third field.
|
# Then, sort by date by telling sort to use hyphen as delimiter and then sort on the third field.
|
||||||
# Finally, select the first entry in that sorted list.
|
# Finally, select the first entry in that sorted list.
|
||||||
OLDEST_INDEX=$(curl -s {{ELASTICSEARCH_HOST}}:{{ELASTICSEARCH_PORT}}/_cat/indices | grep "^ close logstash-" | awk '{print $2}' | sort -t- -k3 | head -1)
|
OLDEST_INDEX=$(curl -s {{ELASTICSEARCH_HOST}}:{{ELASTICSEARCH_PORT}}/_cat/indices | grep -E "^ close (logstash-|so-)" | awk '{print $2}' | sort -t- -k3 | head -1)
|
||||||
|
|
||||||
# Now that we've determined OLDEST_INDEX, ask Elasticsearch to delete it.
|
# Now that we've determined OLDEST_INDEX, ask Elasticsearch to delete it.
|
||||||
curl -XDELETE {{ELASTICSEARCH_HOST}}:{{ELASTICSEARCH_PORT}}/${OLDEST_INDEX}
|
curl -XDELETE {{ELASTICSEARCH_HOST}}:{{ELASTICSEARCH_PORT}}/${OLDEST_INDEX}
|
||||||
|
|||||||
Reference in New Issue
Block a user