Commit 568a0cbf authored by Mathias Ettinger's avatar Mathias Ettinger

Automatically add logstash index pattern into kibana

parent e9504fb8
......@@ -164,7 +164,8 @@ limit_java_memory(){
}
fail_opensand_db(){
INFLUXDB_PORT="$1"
db_get opensand-collector/influxdb/port
INFLUXDB_PORT="${RET}"
echo "Failed to connect to local InfluxDB server on port ${INFLUXDB_PORT}"
echo "This may be due to a lack of available memory. Check the status of the influxdb service and restart it."
echo "The database to hold OpenSAND probes could no be created. Please run:"
......@@ -176,7 +177,35 @@ create_opensand_db(){
db_get opensand-collector/influxdb/port
INFLUXDB_PORT="${RET}"
echo "Waiting for influxdb starts to accepting requests..."
timeout 120 bash -c "until echo > /dev/tcp/localhost/${INFLUXDB_PORT}; do sleep 0.5; done" > /dev/null 2>&1 && curl -i -XPOST http://localhost:${INFLUXDB_PORT}/query --data-urlencode "q=CREATE DATABASE opensand" || fail_opensand_db ${INFLUXDB_PORT}
timeout 120 bash -c "until echo > /dev/tcp/localhost/${INFLUXDB_PORT}; do sleep 0.5; done" > /dev/null 2>&1 && curl -i -XPOST http://localhost:${INFLUXDB_PORT}/query --data-urlencode "q=CREATE DATABASE opensand" || fail_opensand_db
}
fail_index_pattern(){
db_get opensand-collector/elasticsearch/port
ELASTICSEARCH_PORT="${RET}"
db_get opensand-collector/kibana/port
KIBANA_PORT="${RET}"
echo "Failed to connect to local ElasticSearch server on port ${ELASTICSEARCH_PORT}"
echo "This may be due to a lack of available memory. Check the status of the elasticsearch service and restart it."
echo "The default index pattern in Kibana could not be created properly. Please open the page at:"
echo -e "\thttp://localhost:${KIBANA_PORT}/"
echo "and follow the instructions at:"
echo -e "\thttps://www.elastic.co/guide/en/kibana/6.2/tutorial-define-index.html"
echo "to create it once the problem is solved."
}
create_index_pattern(){
db_get opensand-collector/elasticsearch/port
ELASTICSEARCH_PORT="${RET}"
curl -XPUT http://localhost:${ELASTICSEARCH_PORT}/.kibana/index-pattern/logstash_default -d '{"title" : "logstash*", "timeFieldName": "@timestamp"}'
curl -XPUT http://localhost:${ELASTICSEARCH_PORT}/.kibana/config/6.2.4 -d '{"defaultIndex" : "logstash_default"}'
}
create_kibana_index_pattern(){
db_get opensand-collector/elasticsearch/port
ELASTICSEARCH_PORT="${RET}"
echo "Waiting for elasticsearch starts to accepting requests..."
timeout 120 bash -c "until echo > /dev/tcp/localhost/${ELASTICSEARCH_PORT}; do sleep 0.5; done" > /dev/null 2>&1 && create_index_pattern || fail_index_pattern
}
install_logstash_plugin(){
......@@ -219,6 +248,7 @@ case "$1" in
if [ "${RECONFIGURE}" = "false" ]; then
create_opensand_db
create_kibana_index_pattern
fi
;;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment