|
|
@ -1,15 +1,15 @@
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Path to the ECS metadata file
|
|
|
|
# Check if ECS_CONTAINER_METADATA_FILE is set
|
|
|
|
METADATA_FILE=$(cat "$ECS_CONTAINER_METADATA_FILE")
|
|
|
|
if [ -z "$ECS_CONTAINER_METADATA_FILE" ]; then
|
|
|
|
|
|
|
|
echo "ECS_CONTAINER_METADATA_FILE is not set or the server is running on local deployment environment"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f "$METADATA_FILE" ]; then
|
|
|
|
|
|
|
|
# Extract HostPrivateIPv4Address from the metadata file
|
|
|
|
# Extract HostPrivateIPv4Address from the metadata file
|
|
|
|
HOST_PRIVATE_IP=$(jq -r '.HostPrivateIPv4Address' < "$METADATA_FILE")
|
|
|
|
HOST_PRIVATE_IP=$(cat $ECS_CONTAINER_METADATA_FILE | grep -oP '(?<=HostPrivateIPv4Address": ")[^"]+')
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$HOST_PRIVATE_IP" != "null" ]; then
|
|
|
|
if [ "$HOST_PRIVATE_IP" != "null" ]; then
|
|
|
|
echo "Host Private IP: $HOST_PRIVATE_IP"
|
|
|
|
echo "Host Private IP: $HOST_PRIVATE_IP"
|
|
|
|
export HOST_PRIVATE_IP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Define the input template file and output file
|
|
|
|
# Define the input template file and output file
|
|
|
|
TEMPLATE_FILE="filebeat.template.yml"
|
|
|
|
TEMPLATE_FILE="filebeat.template.yml"
|
|
|
@ -26,10 +26,7 @@ if [ -f "$METADATA_FILE" ]; then
|
|
|
|
ln -sf "/opt/logs/${HOST_PRIVATE_IP}/elk" /usr/share/filebeat/elk
|
|
|
|
ln -sf "/opt/logs/${HOST_PRIVATE_IP}/elk" /usr/share/filebeat/elk
|
|
|
|
ln -sf "/opt/filebeat-configs/${HOST_PRIVATE_IP}/filebeat.yml" /usr/share/filebeat/filebeat.yml
|
|
|
|
ln -sf "/opt/filebeat-configs/${HOST_PRIVATE_IP}/filebeat.yml" /usr/share/filebeat/filebeat.yml
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "HostPrivateIPv4Address not found in metadata file"
|
|
|
|
echo "HostPrivateIPv4Address not found"
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
echo "Metadata file does not exist"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Run the original filebeat entrypoint
|
|
|
|
# Run the original filebeat entrypoint
|
|
|
|