mirror of
https://repository.entgra.net/community/entgra-elk.git
synced 2025-09-16 23:32:20 +00:00
Fix issues in custom filebeat image
This commit is contained in:
parent
0510968173
commit
aee6ab81a2
@ -6,4 +6,8 @@ USER root
|
|||||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||||
RUN chmod +x /usr/local/bin/entrypoint.sh
|
RUN chmod +x /usr/local/bin/entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
# Set the entry point to your custom script using tini
|
||||||
|
ENTRYPOINT ["/usr/bin/tini", "--", "/usr/local/bin/entrypoint.sh"]
|
||||||
|
|
||||||
|
# Set the CMD to pass the environment argument to Filebeat
|
||||||
|
CMD ["-environment", "container"]
|
||||||
|
|||||||
17
docker-compose.yml
Normal file
17
docker-compose.yml
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
version: "3.8"
|
||||||
|
|
||||||
|
services:
|
||||||
|
entgra-filebeat:
|
||||||
|
image: filebeat:8.2.0-entgra-v2
|
||||||
|
container_name: entgra-filebeat
|
||||||
|
restart: unless-stopped
|
||||||
|
extra_hosts:
|
||||||
|
- "host.docker.internal:host-gateway"
|
||||||
|
volumes:
|
||||||
|
- ./files/iots/logs/:/opt/logs
|
||||||
|
- ./files/filebeat/opt/filebeat-configs:/opt/filebeat-configs
|
||||||
|
command: ["--strict.perms=false"]
|
||||||
|
environment:
|
||||||
|
- TZ=Asia/Colombo
|
||||||
|
- LOGSTASH_HOST=logstash
|
||||||
|
- LOGSTASH_PORT=5044
|
||||||
@ -16,9 +16,13 @@ if [ "$HOST_PRIVATE_IP" != "null" ]; then
|
|||||||
OUTPUT_FILE="filebeat.yml"
|
OUTPUT_FILE="filebeat.yml"
|
||||||
|
|
||||||
mkdir -p /opt/filebeat-configs/${HOST_PRIVATE_IP}
|
mkdir -p /opt/filebeat-configs/${HOST_PRIVATE_IP}
|
||||||
|
cp /opt/filebeat-configs/$TEMPLATE_FILE /opt/filebeat-configs/${HOST_PRIVATE_IP}/$OUTPUT_FILE
|
||||||
|
|
||||||
# Replace the placeholder with the actual node name and write to the output file
|
# Replace the placeholder with the actual node name and write to the output file
|
||||||
sed "s/{{HOST_PRIVATE_IP}}/${HOST_PRIVATE_IP}/g" "/opt/filebeat-configs/$TEMPLATE_FILE" > "/opt/filebeat-configs/${HOST_PRIVATE_IP}/$OUTPUT_FILE"
|
sed -i 's/${HOST_PRIVATE_IP}/'$HOST_PRIVATE_IP'/g' /opt/filebeat-configs/${HOST_PRIVATE_IP}/$OUTPUT_FILE
|
||||||
|
sed -i 's/${LOGSTASH_HOST}/'$LOGSTASH_HOST'/g' /opt/filebeat-configs/${HOST_PRIVATE_IP}/$OUTPUT_FILE
|
||||||
|
sed -i 's/${LOGSTASH_PORT}/'$LOGSTASH_PORT'/g' /opt/filebeat-configs/${HOST_PRIVATE_IP}/$OUTPUT_FILE
|
||||||
|
|
||||||
echo "Filebeat configuration file created: $OUTPUT_FILE"
|
echo "Filebeat configuration file created: $OUTPUT_FILE"
|
||||||
|
|
||||||
# Create symlinks
|
# Create symlinks
|
||||||
@ -29,5 +33,5 @@ else
|
|||||||
echo "HostPrivateIPv4Address not found"
|
echo "HostPrivateIPv4Address not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the original filebeat entrypoint
|
# Execute the original Filebeat entry point with passed arguments
|
||||||
exec /usr/bin/tini -- /usr/local/bin/docker-entrypoint "$@"
|
exec /usr/local/bin/docker-entrypoint "$@"
|
||||||
19
files/filebeat/opt/filebeat-configs/filebeat.template.yml
Normal file
19
files/filebeat/opt/filebeat-configs/filebeat.template.yml
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
filebeat.inputs:
|
||||||
|
- type: log
|
||||||
|
enabled: true
|
||||||
|
tags: ["SwitchGearLogs"]
|
||||||
|
paths:
|
||||||
|
- /usr/share/filebeat/elk/switchgear.log
|
||||||
|
exclude_files: [".gz$"]
|
||||||
|
exclude_lines: ["^.*TRACE.*$"]
|
||||||
|
|
||||||
|
output.logstash:
|
||||||
|
hosts: ["${LOGSTASH_HOST}:${LOGSTASH_PORT}"]
|
||||||
|
|
||||||
|
processors:
|
||||||
|
- add_docker_metadata:
|
||||||
|
host: "unix:///host_docker/docker.sock"
|
||||||
|
- add_fields:
|
||||||
|
target: ""
|
||||||
|
fields:
|
||||||
|
node.name: "${HOST_PRIVATE_IP}" #custom node name
|
||||||
Loading…
Reference in New Issue
Block a user