Skip to content

Commit

Permalink
Merge pull request #111 from wazuh/disable-xpack
Browse files Browse the repository at this point in the history
Adding the option to disable some xpack features
  • Loading branch information
manuasir authored Feb 7, 2019
2 parents ffe3dde + a6b7d6e commit 4687360
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 2 deletions.
2 changes: 2 additions & 0 deletions elasticsearch/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ ENV ALERTS_SHARDS="1" \
ENV API_USER="foo" \
API_PASS="bar"

ENV XPACK_ML="true"

ENV TEMPLATE_VERSION=v3.8.2

ADD https://raw.githubusercontent.com/wazuh/wazuh/$TEMPLATE_VERSION/extensions/elasticsearch/wazuh-elastic6-template-alerts.json /usr/share/elasticsearch/config
Expand Down
22 changes: 22 additions & 0 deletions elasticsearch/config/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,28 @@ run_as_other_user_if_needed() {
fi
}


#Disabling xpack features

elasticsearch_config_file="/usr/share/elasticsearch/config/elasticsearch.yml"
if grep -Fq "#xpack features" "$elasticsearch_config_file";
then
declare -A CONFIG_MAP=(
[xpack.ml.enabled]=$XPACK_ML
)
for i in "${!CONFIG_MAP[@]}"
do
if [ "${CONFIG_MAP[$i]}" != "" ]; then
sed -i 's/.'"$i"'.*/'"$i"': '"${CONFIG_MAP[$i]}"'/' $elasticsearch_config_file
fi
done
else
echo "
#xpack features
xpack.ml.enabled: $XPACK_ML
" >> $elasticsearch_config_file
fi

# Run load settings script.

./load_settings.sh &
Expand Down
1 change: 1 addition & 0 deletions elasticsearch/config/load_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ curl -XPUT "$el_url/_cluster/settings" -H 'Content-Type: application/json' -d'
}
'


echo "Elasticsearch is ready."
13 changes: 12 additions & 1 deletion kibana/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,14 @@ ENV PATTERN="" \
WAZUH_MONITORING_FREQUENCY="" \
WAZUH_MONITORING_SHARDS="" \
WAZUH_MONITORING_REPLICAS="" \
ADMIN_PRIVILEGES=""
ADMIN_PRIVILEGES=""\
XPACK_CANVAS="true"\
XPACK_LOGS="true"\
XPACK_INFRA="true"\
XPACK_ML="true"\
XPACK_DEVTOOLS="true"\
XPACK_MONITORING="true"\
XPACK_APM="true"


COPY --chown=kibana:kibana ./config/wazuh_app_config.sh ./
Expand All @@ -50,5 +57,9 @@ COPY --chown=kibana:kibana ./config/kibana_settings.sh ./

RUN chmod +x ./kibana_settings.sh

COPY --chown=kibana:kibana ./config/xpack_config.sh ./

RUN chmod +x ./xpack_config.sh

ENTRYPOINT /entrypoint.sh

4 changes: 4 additions & 0 deletions kibana/config/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ done

sleep 5

./xpack_config.sh

./kibana_settings.sh &



/usr/local/bin/kibana-docker
2 changes: 1 addition & 1 deletion kibana/config/kibana_settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ sleep 5
# Do not ask user to help providing usage statistics to Elastic
curl -POST "http://kibana:5601/api/telemetry/v1/optIn" -H "Content-Type: application/json" -H "kbn-xsrf: true" -d '{"enabled":false}'

echo "End settings"
echo "End settings"
36 changes: 36 additions & 0 deletions kibana/config/xpack_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

kibana_config_file="/usr/share/kibana/config/kibana.yml"
if grep -Fq "#xpack features" "$kibana_config_file";
then
declare -A CONFIG_MAP=(
[xpack.apm.ui.enabled]=$XPACK_APM
[xpack.grokdebugger.enabled]=$XPACK_DEVTOOLS
[xpack.searchprofiler.enabled]=$XPACK_DEVTOOLS
[xpack.ml.enabled]=$XPACK_ML
[xpack.canvas.enabled]=$XPACK_CANVAS
[xpack.logstash.enabled]=$XPACK_LOGS
[xpack.infra.enabled]=$XPACK_INFRA
[xpack.monitoring.enabled]=$XPACK_MONITORING
[console.enabled]=$XPACK_DEVTOOLS
)
for i in "${!CONFIG_MAP[@]}"
do
if [ "${CONFIG_MAP[$i]}" != "" ]; then
sed -i 's/.'"$i"'.*/'"$i"': '"${CONFIG_MAP[$i]}"'/' $kibana_config_file
fi
done
else
echo "
#xpack features
xpack.apm.ui.enabled: $XPACK_APM
xpack.grokdebugger.enabled: $XPACK_DEVTOOLS
xpack.searchprofiler.enabled: $XPACK_DEVTOOLS
xpack.ml.enabled: $XPACK_ML
xpack.canvas.enabled: $XPACK_CANVAS
xpack.logstash.enabled: $XPACK_LOGS
xpack.infra.enabled: $XPACK_INFRA
xpack.monitoring.enabled: $XPACK_MONITORING
console.enabled: $XPACK_DEVTOOLS
" >> $kibana_config_file
fi

0 comments on commit 4687360

Please sign in to comment.