Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Wazuh-Elasticsearch #106

Merged
merged 11 commits into from
Feb 1, 2019
Merged

Add Wazuh-Elasticsearch #106

merged 11 commits into from
Feb 1, 2019

Conversation

SitoRBJ
Copy link
Contributor

@SitoRBJ SitoRBJ commented Jan 30, 2019

Hello team,

This PR solves #108 and creates the Wazuh-Elasticsearch module. This is done to properly separate the tasks concerning each container. The configurations of each container only depend on itself and not on another container.

To this end, we have transferred the modifications made to the Elasticsearch container from the Kibana container.

We have also added the option of configuring API credentials using environment variables so that they are not embedded in the code.

We have performed tests of various types:

  • Clean deployment.
  • Deployment with new API credentials.
  • Deployment enabling volumes for Elasticsearch and Wazuh.
  • Registration of agents.
  • Verification of the persistence of agent registration, configuration changes and alerts through the use of volumes.
  • Verification of the functioning of the environment after removing the Elasticsearch container and creating it again.

All tests have been successful.

Best regards,

Alfonso Ruiz-Bravo

ENV API_USER="foo" \
API_PASS="bar"

ADD https://github.com/wazuh/wazuh/3.8/extensions/elasticsearch/wazuh-elastic6-template-alerts.json /usr/share/elasticsearch/config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add variable for version. It should be the tag, not the branch.


set -m

# Add elasticsearch as command if needed
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain command.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is certainly unnecessary, it is replaced by set -e so that the script aborts when it gets output responses other than 0.

el_url="${ELASTICSEARCH_URL}"
fi

# Run as user "elasticsearch" if the command is "elasticsearch"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this section is unnecessary, this entry belongs to the script that updates the settings.

# Run as user "elasticsearch" if the command is "elasticsearch"
if [ "$1" = 'elasticsearch' -a "$(id -u)" = '0' ]; then
set -- su-exec eulasticsearch "$@"
ES_JAVA_OPTS="-Des.network.host=$NETWORK_HOST -Des.logger.level=$LOG_LEVEL -Xms$HEAP_SIZE -Xmx$HEAP_SIZE" "$@" &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the HEAP_SIZE variable?. Use default values if it is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is done to run the Elasticsearch CMD. It is not the practice performed by Elasticsearch but emulates it.

We have decided to change the entrypoint so that it is in tune with the official Elasticsearch entrypoint, performing the tasks we need as they do.

@SitoRBJ
Copy link
Contributor Author

SitoRBJ commented Feb 1, 2019

Hello team,

To perform good practices as done in other repositories, we have adapted the Elasticsearch Dockerfile to launch an Elasticsearch CMD.

The entrypoint.sh contains the options to execute the command independently of the user who launches it. If it is root the command generates problems, that's why, when it is root, a different execution is contemplated specifying the user with UID=1000.

This way of proceeding is obtained from the Elasticsearch repository:

https://github.com/elastic/elasticsearch-docker/blob/6.5.4/build/elasticsearch/bin/docker-entrypoint.sh

Best regards,

Alfonso Ruiz-Bravo

@jesuslinares jesuslinares merged commit cb2e49e into 3.8.2_6.5.4 Feb 1, 2019
@jesuslinares jesuslinares deleted the devel-elasticsearch branch February 1, 2019 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants