Add index template to ES for docker
This commit is contained in:
@ -8,7 +8,6 @@ services:
|
||||
- bootstrap.memory_lock=true
|
||||
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
|
||||
- xpack.security.enabled=false
|
||||
|
||||
ulimits:
|
||||
memlock:
|
||||
soft: -1
|
||||
@ -46,6 +45,7 @@ services:
|
||||
volumes:
|
||||
- ./resources/elk6/init_kibana.sh:/opt/init_kibana.sh
|
||||
- ./resources/elk6/kibana_APIonly.json:/opt/kibana_APIonly.json
|
||||
- ./resources/elk6/logstash-vulnwhisperer-template.json:/opt/index-template.json
|
||||
command: sh -c "apk add --no-cache curl bash && chmod +x /opt/init_kibana.sh && chmod +r /opt/kibana_APIonly.json && cd /opt/ && /bin/bash /opt/init_kibana.sh" # /opt/kibana_APIonly.json"
|
||||
networks:
|
||||
esnet:
|
||||
|
@ -2,14 +2,28 @@
|
||||
|
||||
#kibana_url="localhost:5601"
|
||||
kibana_url="kibana.local:5601"
|
||||
add_saved_objects="curl -u elastic:changeme -k -XPOST 'http://"$kibana_url"/api/saved_objects/_bulk_create' -H 'Content-Type: application/json' -H \"kbn-xsrf: true\" -d @"
|
||||
elasticsearch_url="elasticsearch.local:9200"
|
||||
add_saved_objects="curl -s -u elastic:changeme -k -XPOST 'http://"$kibana_url"/api/saved_objects/_bulk_create' -H 'Content-Type: application/json' -H \"kbn-xsrf: true\" -d @"
|
||||
|
||||
#Create all saved objects - including index pattern
|
||||
saved_objects_file="kibana_APIonly.json"
|
||||
|
||||
#if [ `curl -I localhost:5601/status | head -n1 |cut -d$' ' -f2` -eq '200' ]; then echo "Loading VulnWhisperer Saved Objects"; eval $(echo $add_saved_objects$saved_objects_file); else echo "waiting for kibana"; fi
|
||||
|
||||
until [ "`curl -I "$kibana_url"/status | head -n1 |cut -d$' ' -f2`" == "200" ]; do
|
||||
until curl -s "$elasticsearch_url/_cluster/health?pretty" | grep '"status"' | grep -qE "green|yellow"; do
|
||||
curl -s "$elasticsearch_url/_cluster/health?pretty"
|
||||
echo "Waiting for Elasticsearch"
|
||||
sleep 5
|
||||
done
|
||||
|
||||
echo "Loading VulnWhisperer index template"
|
||||
if curl -s --fail -XPUT "http://$elasticsearch_url/_template/vulnwhisperer" -H 'Content-Type: application/json' -d '@/opt/index-template.json'; then
|
||||
echo -e "\nVulnWhisperer index template loaded successfully!"
|
||||
else
|
||||
echo -e "\nFAILED to load VulnWhisperer index template"
|
||||
fi
|
||||
|
||||
until [ "`curl -s -I "$kibana_url"/status | head -n1 |cut -d$' ' -f2`" == "200" ]; do
|
||||
curl -I "$kibana_url"/status
|
||||
echo "Waiting for Kibana"
|
||||
sleep 5
|
||||
@ -30,4 +44,3 @@ eval $(echo $add_saved_objects$saved_objects_file)
|
||||
#Create jira index pattern, separated for not fill of crap variables the Discover tab by default
|
||||
#index_name = "logstash-jira-*"
|
||||
#os.system(add_index+index_name+"' '-d{\"attributes\":{\"title\":\""+index_name+"\",\"timeFieldName\":\"@timestamp\"}}'")
|
||||
|
||||
|
Reference in New Issue
Block a user