Refactoring wazuh/wazuh-kibana container

This commit is contained in:
Miguelangel Freitas
2018-04-22 10:06:16 -05:00
parent 0df2367e7a
commit 70171d490d
2 changed files with 18 additions and 32 deletions

View File

@@ -1,25 +1,18 @@
FROM docker.elastic.co/kibana/kibana:6.2.3 FROM docker.elastic.co/kibana/kibana-oss:6.2.3
ARG WAZUH_APP_VERSION=3.2.1_6.2.3 ARG WAZUH_APP_VERSION=3.2.1_6.2.3
USER root USER root
COPY ./config/kibana.yml /usr/share/kibana/config/kibana.yml
COPY config/wait-for-it.sh /wait-for-it.sh
ADD https://packages.wazuh.com/wazuhapp/wazuhapp-${WAZUH_APP_VERSION}.zip /tmp ADD https://packages.wazuh.com/wazuhapp/wazuhapp-${WAZUH_APP_VERSION}.zip /tmp
ADD https://raw.githubusercontent.com/wazuh/wazuh/3.2/extensions/elasticsearch/wazuh-elastic6-template-alerts.json /usr/share/kibana/config ADD https://raw.githubusercontent.com/wazuh/wazuh/3.2/extensions/elasticsearch/wazuh-elastic6-template-alerts.json /usr/share/kibana/config
ADD https://raw.githubusercontent.com/wazuh/wazuh/3.2/extensions/elasticsearch/wazuh-elastic6-template-monitoring.json /usr/share/kibana/config RUN NODE_OPTIONS="--max-old-space-size=3072" /usr/share/kibana/bin/kibana-plugin install file:///tmp/wazuhapp-${WAZUH_APP_VERSION}.zip &&\
chown -R kibana.kibana /usr/share/kibana &&\
rm -rf /tmp/*
ADD https://raw.githubusercontent.com/wazuh/wazuh/3.2/extensions/elasticsearch/alert_sample.json /usr/share/kibana/config COPY config/entrypoint.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh
RUN /usr/share/kibana/bin/kibana-plugin install file:///tmp/wazuhapp-${WAZUH_APP_VERSION}.zip
RUN chown -R kibana.kibana /usr/share/kibana
RUN rm -rf /tmp/*
RUN chmod 755 /wait-for-it.sh
USER kibana USER kibana
ENTRYPOINT /entrypoint.sh

View File

@@ -2,34 +2,27 @@
set -e set -e
host="$1" if [ "x${ELASTICSEARCH_URL}" = "x" ]; then
shift el_url="http://elasticsearch:9200"
cmd="kibana" else
el_url="${ELASTICSEARCH_URL}"
fi
until curl -XGET $host:9200; do until curl -XGET $el_url; do
>&2 echo "Elastic is unavailable - sleeping" >&2 echo "Elastic is unavailable - sleeping"
sleep 5 sleep 5
done done
>&2 echo "Elastic is up - executing command" >&2 echo "Elastic is up - executing command"
sleep 5
#Insert default templates #Insert default templates
cat /usr/share/kibana/config/wazuh-elastic6-template-alerts.json | curl -XPUT "http://$host:9200/_template/wazuh" -H 'Content-Type: application/json' -d @- cat /usr/share/kibana/config/wazuh-elastic6-template-alerts.json | curl -XPUT "$el_url/_template/wazuh" -H 'Content-Type: application/json' -d @-
sleep 5 sleep 5
#Insert default templates
cat /usr/share/kibana/config/wazuh-elastic6-template-monitoring.json | curl -XPUT "http://$host:9200/_template/wazuh-agent" -H 'Content-Type: application/json' -d @-
#Insert sample alert:
sleep 5
cat /usr/share/kibana/config/alert_sample.json | curl -XPUT "http://$host:9200/wazuh-alerts-3.x-"`date +%Y.%m.%d`"/wazuh/sample" -H 'Content-Type: application/json' -d @-
sleep 5
echo "Setting API credentials into Wazuh APP" echo "Setting API credentials into Wazuh APP"
CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET http://$host:9200/.wazuh/wazuh-configuration/1513629884013) CONFIG_CODE=$(curl -s -o /dev/null -w "%{http_code}" -XGET $el_url/.wazuh/wazuh-configuration/1513629884013)
if [ "x$CONFIG_CODE" = "x404" ]; then if [ "x$CONFIG_CODE" = "x404" ]; then
curl -s -XPOST http://$host:9200/.wazuh/wazuh-configuration/1513629884013 -H 'Content-Type: application/json' -d' curl -s -XPOST $el_url/.wazuh/wazuh-configuration/1513629884013 -H 'Content-Type: application/json' -d'
{ {
"api_user": "foo", "api_user": "foo",
"api_password": "YmFy", "api_password": "YmFy",
@@ -57,4 +50,4 @@ fi
sleep 5 sleep 5
exec $cmd /usr/local/bin/kibana-docker