Skip to content

Instantly share code, notes, and snippets.

@hiranp
Last active February 4, 2025 17:09
Show Gist options
  • Save hiranp/8ea7e1ada115e691a504c89f52b29264 to your computer and use it in GitHub Desktop.
Save hiranp/8ea7e1ada115e691a504c89f52b29264 to your computer and use it in GitHub Desktop.
Linux Splunk resources

Splunk User Resource Limits Setup

References:

1. Create Splunk User

useradd -m -s /bin/bash splunk

2. Configure PAM Limits

# Ref: https://linux.die.net/man/5/limits.conf
# Controls user limits in /etc/security/limits.conf
# Note: Provides basic resource control but has limitations
sudo tee -a /etc/security/limits.conf << 'EOF'
splunk soft nproc 4096
splunk hard nproc 8192
splunk soft nofile 10240
splunk hard nofile 20240
splunk soft memlock 64000
splunk hard memlock 64000
splunk soft as 16G
splunk hard as 16G
EOF

3. Configure Systemd Slice

# Ref: https://linux.die.net/man/5/systemd.slice
# Systemd slice provides more precise control:
# - CPU quota control (percentage based)
# - Real-time CPU limiting
# - Modern cgroups integration
# Note: 100% = 1 CPU core, 200% = 2 CPU cores
sudo tee /etc/systemd/system/splunk.slice << 'EOF'
[Unit]
Description=Slice for Splunk User
Before=slices.target

[Slice]
CPUQuota=200%
MemoryMax=16G
TasksMax=8192
EOF

4. Apply User Service Limits

sudo tee /etc/systemd/system/[email protected]/override.conf << 'EOF'
[Service]
Slice=splunk.slice
EOF

5. System Reload

systemctl daemon-reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment