Journald
Steps
Install vector in your target environment.
curl --proto '=https' --tlsv1.2 -sSfL https://sh.vector.dev | bash -s -- -y
Install the nimbus configuration
NOTE: you'll need to replace
$YOUR_NIMBUS_ENDPOINT
with your specific endpoint
cat << EOF > /usr/local/etc/
data_dir: /tmp/
api:
address: 0.0.0.0:8686
enabled: true
playground: false
sources:
source/journald:
type: journald
current_boot_only: true
sinks:
sink/nimbus:
type: http
encoding:
codec: json
compression: gzip
inputs:
- source/*
uri: $YOUR_NIMBUS_ENDPOINT
EOF
Create the systemd script
cat << EOF > /tmp/nimsetup.sh
#!/bin/bash
# Define the binary and service names
BINARY_PATH=$1
BINARY_NAME="vector"
SERVICE_NAME="vector.service"
# Copy the binary to /usr/local/bin
echo "Copying $BINARY_PATH to /usr/local/bin..."
cp "$BINARY_PATH" "/usr/local/bin/$BINARY_NAME"
chmod +x "/usr/local/bin/$BINARY_NAME"
# updating config file
chmod a+r /usr/local/etc/vector-config.yaml
# Create a systemd service file
SERVICE_FILE_PATH="/etc/systemd/system/$SERVICE_NAME"
echo "Creating $SERVICE_FILE_PATH..."
cat <<EOF1 > "$SERVICE_FILE_PATH"
[Unit]
Description=Nimbus Collector
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/$BINARY_NAME -c /usr/local/etc/vector-config.yaml
Restart=on-abort
[Install]
WantedBy=multi-user.target
EOF1
# Reload systemd to recognize the new service
echo "Reloading systemd manager configuration..."
systemctl daemon-reload
# Enable the service to start on boot
echo "Enabling $SERVICE_NAME..."
systemctl enable "$SERVICE_NAME"
# Start the service
echo "Starting $SERVICE_NAME..."
systemctl start "$SERVICE_NAME"
echo "$SERVICE_NAME is now running."
EOF
Execute
. ~/.zprofile
chmod +x /tmp/nimsetup.sh
sudo /tmp/nimsetup.sh `which vector`
Verify
systemctl status vector
vector.service - Nimbus Collector
Loaded: loaded (/etc/systemd/system/vector.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2024-02-29 22:41:32 UTC; 6min ago
Main PID: 3505 (vector)
Tasks: 6 (limit: 18945)
Memory: 16.5M
Last updated