fixes fixes fixes but more needed
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 39s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 39s
This commit is contained in:
@@ -3,6 +3,16 @@
|
||||
# Generate Filebeat configuration from template
|
||||
# This script creates a filebeat.yml configuration file with proper authentication
|
||||
|
||||
# Check required variables
|
||||
if [ -z "$LOGSERVER_HOST" ] || [ -z "$LOGSERVER_PORT" ]; then
|
||||
echo "ERROR: Required environment variables not set"
|
||||
echo " LOGSERVER_HOST: ${LOGSERVER_HOST:-NOT SET}"
|
||||
echo " LOGSERVER_PORT: ${LOGSERVER_PORT:-NOT SET}"
|
||||
echo ""
|
||||
echo "Please set these in config/service.env before running install"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Determine config directory - use CONFIG_PATH from dropshell or fallback
|
||||
if [ -n "$CONFIG_PATH" ]; then
|
||||
CONFIG_DIR="$CONFIG_PATH"
|
||||
@@ -15,8 +25,15 @@ fi
|
||||
# Ensure config directory exists
|
||||
mkdir -p "$CONFIG_DIR"
|
||||
|
||||
# Generate filebeat.yml configuration
|
||||
cat > "$CONFIG_DIR/filebeat.yml" << EOF
|
||||
# Set defaults for variables if not set
|
||||
BULK_MAX_SIZE=${BULK_MAX_SIZE:-2048}
|
||||
WORKER_THREADS=${WORKER_THREADS:-1}
|
||||
QUEUE_SIZE=${QUEUE_SIZE:-4096}
|
||||
MAX_BACKOFF=${MAX_BACKOFF:-60s}
|
||||
|
||||
# Generate filebeat.yml configuration with variable substitution
|
||||
(
|
||||
cat << 'TEMPLATE_EOF'
|
||||
# Filebeat Configuration for LogClient
|
||||
# Generated by generate-config.sh
|
||||
|
||||
@@ -64,30 +81,30 @@ processors:
|
||||
|
||||
# ======================== Output Configuration ===============================
|
||||
output.logstash:
|
||||
hosts: ["${LOGSERVER_HOST}:${LOGSERVER_PORT}"]
|
||||
hosts: ["__LOGSERVER_HOST__:__LOGSERVER_PORT__"]
|
||||
# SSL/TLS configuration
|
||||
ssl.enabled: false # Set to true when using TLS
|
||||
ssl.verification_mode: none # Set to full in production with proper certs
|
||||
|
||||
# Performance settings
|
||||
bulk_max_size: ${BULK_MAX_SIZE:-2048}
|
||||
worker: ${WORKER_THREADS:-1} # Must be >= 1
|
||||
bulk_max_size: __BULK_MAX_SIZE__
|
||||
worker: __WORKER_THREADS__ # Must be >= 1
|
||||
compression_level: 3
|
||||
|
||||
# Retry configuration
|
||||
max_retries: 3
|
||||
backoff.init: 1s
|
||||
backoff.max: ${MAX_BACKOFF:-60s}
|
||||
backoff.max: __MAX_BACKOFF__
|
||||
|
||||
# ======================== Global Fields =======================================
|
||||
# Add API key as a field to all events
|
||||
fields:
|
||||
api_key: "${API_KEY}"
|
||||
api_key: "__API_KEY__"
|
||||
fields_under_root: false
|
||||
|
||||
# ======================== Queue Configuration ================================
|
||||
queue.mem:
|
||||
events: ${QUEUE_SIZE:-4096}
|
||||
events: __QUEUE_SIZE__
|
||||
flush.min_events: 512
|
||||
flush.timeout: 5s
|
||||
|
||||
@@ -109,14 +126,25 @@ http.port: 5066
|
||||
# ======================== File Permissions ====================================
|
||||
# Set strict permissions (disabled for Docker)
|
||||
# filebeat.config.modules.path: ${path.config}/modules.d/*.yml
|
||||
EOF
|
||||
TEMPLATE_EOF
|
||||
) | sed -e "s|__LOGSERVER_HOST__|${LOGSERVER_HOST}|g" \
|
||||
-e "s|__LOGSERVER_PORT__|${LOGSERVER_PORT}|g" \
|
||||
-e "s|__API_KEY__|${API_KEY}|g" \
|
||||
-e "s|__BULK_MAX_SIZE__|${BULK_MAX_SIZE}|g" \
|
||||
-e "s|__WORKER_THREADS__|${WORKER_THREADS}|g" \
|
||||
-e "s|__QUEUE_SIZE__|${QUEUE_SIZE}|g" \
|
||||
-e "s|__MAX_BACKOFF__|${MAX_BACKOFF}|g" > "$CONFIG_DIR/filebeat.yml"
|
||||
|
||||
echo "Filebeat configuration generated at: $CONFIG_DIR/filebeat.yml"
|
||||
echo "Configuration:"
|
||||
echo " LOGSERVER_HOST: ${LOGSERVER_HOST}"
|
||||
echo " LOGSERVER_PORT: ${LOGSERVER_PORT}"
|
||||
echo " API_KEY: ${API_KEY:+[SET]}"
|
||||
echo " WORKER_THREADS: ${WORKER_THREADS}"
|
||||
|
||||
# Validate that required environment variables are set
|
||||
if [ -z "$LOGSERVER_HOST" ] || [ -z "$LOGSERVER_PORT" ] || [ -z "$API_KEY" ]; then
|
||||
echo "WARNING: Required environment variables not set"
|
||||
echo " LOGSERVER_HOST: ${LOGSERVER_HOST:-NOT SET}"
|
||||
echo " LOGSERVER_PORT: ${LOGSERVER_PORT:-NOT SET}"
|
||||
echo " API_KEY: ${API_KEY:+SET}"
|
||||
# Additional warning if API_KEY is not set
|
||||
if [ -z "$API_KEY" ]; then
|
||||
echo ""
|
||||
echo "WARNING: API_KEY is not set - logs may be rejected by the server"
|
||||
echo "Get an API key from the LogServer admin using generate-api-key.sh"
|
||||
fi
|
Reference in New Issue
Block a user