Integrate OSSEC with Splunk for centralized security monitoring and log analysis

Advanced 45 min May 01, 2026 62 views
Ubuntu 24.04 Debian 12 AlmaLinux 9 Rocky Linux 9

Set up OSSEC HIDS with Splunk Universal Forwarder to centralize security events, create monitoring dashboards, and enable real-time threat correlation across your infrastructure.

Prerequisites

  • Root access to server
  • Splunk account for downloading Universal Forwarder
  • Splunk indexer server accessible from monitored host
  • Minimum 4GB RAM and 20GB disk space

What this solves

This integration sends OSSEC security alerts and logs to Splunk for centralized analysis, correlation, and visualization. You get unified security monitoring across multiple servers with advanced search capabilities and automated alerting.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you have the latest security patches.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install OSSEC HIDS dependencies

Install the required build tools and libraries for OSSEC compilation.

sudo apt install -y build-essential gcc make wget curl zlib1g-dev libpcre2-dev libevent-dev libssl-dev
sudo dnf install -y gcc make wget curl zlib-devel pcre2-devel libevent-devel openssl-devel

Download and compile OSSEC

Download the latest OSSEC release and compile it for your system.

cd /opt
sudo wget https://github.com/ossec/ossec-hids/archive/3.7.0.tar.gz
sudo tar -xzf 3.7.0.tar.gz
sudo chown -R $(whoami):$(whoami) ossec-hids-3.7.0
cd ossec-hids-3.7.0
sudo ./install.sh

During installation, configure OSSEC as a local installation when prompted. Accept default paths and enable email notifications.

Configure OSSEC for log output

Modify OSSEC configuration to enable JSON output and configure log locations for Splunk ingestion.

<ossec_config>
  <global>
    <jsonout_output>yes</jsonout_output>
    <logall>yes</logall>
    <logall_json>yes</logall_json>
    <email_notification>yes</email_notification>
    <smtp_server>localhost</smtp_server>
    <email_from>ossec@example.com</email_from>
    <email_to>admin@example.com</email_to>
  </global>
  
  <rules>
    <include>rules_config.xml</include>
    <include>pam_rules.xml</include>
    <include>sshd_rules.xml</include>
    <include>telnetd_rules.xml</include>
    <include>syslog_rules.xml</include>
    <include>arpwatch_rules.xml</include>
    <include>symantec-av_rules.xml</include>
    <include>symantec-ws_rules.xml</include>
    <include>pix_rules.xml</include>
    <include>named_rules.xml</include>
    <include>smbd_rules.xml</include>
    <include>vsftpd_rules.xml</include>
    <include>pure-ftpd_rules.xml</include>
    <include>proftpd_rules.xml</include>
    <include>ms_ftpd_rules.xml</include>
    <include>ftpd_rules.xml</include>
    <include>hordeimp_rules.xml</include>
    <include>roundcube_rules.xml</include>
    <include>wordpress_rules.xml</include>
    <include>cimserver_rules.xml</include>
    <include>vpopmail_rules.xml</include>
    <include>vmpop3d_rules.xml</include>
    <include>courier_rules.xml</include>
    <include>web_rules.xml</include>
    <include>web_appsec_rules.xml</include>
    <include>apache_rules.xml</include>
    <include>nginx_rules.xml</include>
    <include>php_rules.xml</include>
    <include>mysql_rules.xml</include>
    <include>postgresql_rules.xml</include>
    <include>ids_rules.xml</include>
    <include>squid_rules.xml</include>
    <include>firewall_rules.xml</include>
    <include>cisco-ios_rules.xml</include>
    <include>netscreenfw_rules.xml</include>
    <include>sonicwall_rules.xml</include>
    <include>postfix_rules.xml</include>
    <include>sendmail_rules.xml</include>
    <include>imapd_rules.xml</include>
    <include>mailscanner_rules.xml</include>
    <include>dovecot_rules.xml</include>
    <include>ms-exchange_rules.xml</include>
    <include>racoon_rules.xml</include>
    <include>vpn_concentrator_rules.xml</include>
    <include>spamd_rules.xml</include>
    <include>msauth_rules.xml</include>
    <include>mcafee_av_rules.xml</include>
    <include>trend-osce_rules.xml</include>
    <include>ms-se_rules.xml</include>
    <include>zeus_rules.xml</include>
    <include>solaris_bsm_rules.xml</include>
    <include>vmware_rules.xml</include>
    <include>ms_dhcp_rules.xml</include>
    <include>asterisk_rules.xml</include>
    <include>ossec_rules.xml</include>
    <include>attack_rules.xml</include>
    <include>local_rules.xml</include>
  </rules>
  
  <syscheck>
    <disabled>no</disabled>
    <frequency>7200</frequency>
    <scan_on_start>yes</scan_on_start>
    <directories check_all="yes">/etc,/usr/bin,/usr/sbin</directories>
    <directories check_all="yes">/bin,/sbin</directories>
    <directories check_all="yes">/boot</directories>
    <ignore>/etc/mtab</ignore>
    <ignore>/etc/hosts.deny</ignore>
    <ignore>/etc/mail/statistics</ignore>
    <ignore>/etc/random-seed</ignore>
    <ignore>/etc/random.seed</ignore>
    <ignore>/etc/adjtime</ignore>
    <ignore>/etc/httpd/logs</ignore>
    <ignore>/etc/utmpx</ignore>
    <ignore>/etc/wtmpx</ignore>
    <ignore>/etc/cups/certs</ignore>
    <ignore>/etc/dumpdates</ignore>
    <ignore>/etc/svc/volatile</ignore>
  </syscheck>
  
  <rootcheck>
    <disabled>no</disabled>
    <check_files>yes</check_files>
    <check_trojans>yes</check_trojans>
    <check_dev>yes</check_dev>
    <check_sys>yes</check_sys>
    <check_pids>yes</check_pids>
    <check_ports>yes</check_ports>
    <check_if>yes</check_if>
    <frequency>7200</frequency>
    <rootkit_files>/var/ossec/etc/shared/rootkit_files.txt</rootkit_files>
    <rootkit_trojans>/var/ossec/etc/shared/rootkit_trojans.txt</rootkit_trojans>
    <system_audit>/var/ossec/etc/shared/system_audit_rcl.txt</system_audit>
    <system_audit>/var/ossec/etc/shared/system_audit_ssh.txt</system_audit>
    <system_audit>/var/ossec/etc/shared/cis_debian_linux_rcl.txt</system_audit>
    <skip_nfs>yes</skip_nfs>
  </rootcheck>
  
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/messages</location>
  </localfile>
  
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/auth.log</location>
  </localfile>
  
  <localfile>
    <log_format>syslog</log_format>
    <location>/var/log/syslog</location>
  </localfile>
  
  <localfile>
    <log_format>command</log_format>
    <command>df -P</command>
    <frequency>360</frequency>
  </localfile>
  
  <localfile>
    <log_format>full_command</log_format>
    <command>netstat -tulpn | sed 's/\([[:alnum:]]\+\)[ \t]\([[:alnum:]]\+\)[ \t]\([[:alnum:]\.\/\:\\-]\+\)[ \t]\([[:alnum:]\.\/\:\\-]\+\)[ \t]\([[:alnum:]\-\/\.]\+\)[ \t]*\([[:alnum:]-\/\.]\+\)/\1 \2 \3 \4 \5 \6/' | sort</command>
    <alias>netstat listening ports</alias>
    <frequency>360</frequency>
  </localfile>
  
  <localfile>
    <log_format>full_command</log_format>
    <command>last -n 20</command>
    <frequency>360</frequency>
  </localfile>
  
  <active-response>
    <disabled>yes</disabled>
  </active-response>
</ossec_config>

Start OSSEC service

Enable and start the OSSEC daemon to begin log collection and analysis.

sudo /var/ossec/bin/ossec-control start
sudo systemctl enable ossec

Download Splunk Universal Forwarder

Download the appropriate Splunk Universal Forwarder package for your Linux distribution.

cd /tmp
wget -O splunkforwarder-9.1.2-b6b9c8185839-linux-2.6-amd64.deb "https://download.splunk.com/products/universalforwarder/releases/9.1.2/linux/splunkforwarder-9.1.2-b6b9c8185839-linux-2.6-amd64.deb"
Note: You need a Splunk account to download. Register at splunk.com if you don't have an account. For RHEL-based systems, download the RPM version instead.

Install Splunk Universal Forwarder

Install the Splunk Universal Forwarder package on your system.

sudo dpkg -i splunkforwarder-9.1.2-b6b9c8185839-linux-2.6-amd64.deb
sudo rpm -i splunkforwarder-9.1.2-b6b9c8185839-linux-2.6-x86_64.rpm

Configure Splunk Universal Forwarder

Start the forwarder and accept the license, then configure admin credentials.

sudo /opt/splunkforwarder/bin/splunk start --accept-license
sudo /opt/splunkforwarder/bin/splunk enable boot-start

Set admin password when prompted. Use a strong password for security.

Add forward server configuration

Configure the forwarder to send data to your Splunk indexer. Replace the IP address with your Splunk server.

sudo /opt/splunkforwarder/bin/splunk add forward-server 203.0.113.10:9997

Configure OSSEC log monitoring

Add OSSEC log files to the Splunk Universal Forwarder inputs configuration.

[monitor:///var/ossec/logs/alerts/alerts.log]
disabled = false
index = ossec
sourcetype = ossec:alerts
host_segment = 3

[monitor:///var/ossec/logs/alerts/alerts.json]
disabled = false
index = ossec
sourcetype = ossec:alerts:json
host_segment = 3

[monitor:///var/ossec/logs/ossec.log]
disabled = false
index = ossec
sourcetype = ossec:log
host_segment = 3

[monitor:///var/ossec/logs/archives/archives.log]
disabled = false
index = ossec
sourcetype = ossec:archives
host_segment = 3

Create OSSEC index on Splunk

Create the dedicated OSSEC index configuration for your Splunk deployment.

[ossec]
homePath = $SPLUNK_DB/ossec/db
coldPath = $SPLUNK_DB/ossec/colddb
thawedPath = $SPLUNK_DB/ossec/thaweddb
maxDataSize = auto_high_volume
maxHotBuckets = 10
maxWarmDBCount = 300
maxMemMB = 20
maxConcurrentOptimizes = 6
maxHotIdleSecs = 86400
maxHotSpanSecs = 7776000
compressRawdata = true
repFactor = auto

Configure log rotation for OSSEC

Set up log rotation to prevent disk space issues with OSSEC logs.

/var/ossec/logs/.log /var/ossec/logs//*.log {
    daily
    missingok
    rotate 52
    compress
    notifempty
    create 0660 ossec ossec
    postrotate
        /var/ossec/bin/ossec-control restart > /dev/null 2>&1 || true
    endscript
}

Restart services

Restart both OSSEC and Splunk Universal Forwarder to apply the new configurations.

sudo /var/ossec/bin/ossec-control restart
sudo /opt/splunkforwarder/bin/splunk restart

Configure Splunk props and transforms

Configure field extraction and parsing for OSSEC data in Splunk.

[ossec:alerts]
SHOULD_LINEMERGE = false
LINE_BREAKER = (\r?\n)\\ Alert ([0-9]+)

[ossec:alerts:json]
SHOULD_LINEMERGE = false
LINE_BREAKER = (\r?\n){"timestamp"
KV_MODE = json
TIME_PREFIX = "timestamp":"
TIME_FORMAT = %Y %b %d %H:%M:%S
MAX_TIMESTAMP_LOOKAHEAD = 25
TRUNCATE = 10000

[ossec:log]
SHOULD_LINEMERGE = false
LINE_BREAKER = (\r?\n)\d{4}/\d{2}/\d{2}\s\d{2}:\d{2}:\d{2}
TIME_PREFIX = ^\d{4}/\d{2}/\d{2}\s
TIME_FORMAT = %Y/%m/%d %H:%M:%S
MAX_TIMESTAMP_LOOKAHEAD = 19

[ossec:archives]
SHOULD_LINEMERGE = false
LINE_BREAKER = (\r?\n)\d{4}\s\w{3}\s\d{2}\s\d{2}:\d{2}:\d{2}
TIME_PREFIX = ^\d{4}\s\w{3}\s\d{2}\s
TIME_FORMAT = %Y %b %d %H:%M:%S
MAX_TIMESTAMP_LOOKAHEAD = 20

Set up Splunk dashboards and alerts

Create OSSEC security dashboard

Build a comprehensive dashboard for OSSEC security monitoring in Splunk.

index=ossec sourcetype=ossec:alerts:json 
| stats count by rule.description, rule.level 
| sort -count 
| head 20

Use this search to create panels showing top security alerts, rule distributions, and severity levels.

Configure real-time security alerts

Set up automated alerts for high-priority security events from OSSEC.

index=ossec sourcetype=ossec:alerts:json rule.level>=10 
| eval severity=case(rule.level>=12,"Critical",rule.level>=10,"High",rule.level>=7,"Medium",1==1,"Low") 
| table _time, agent.name, rule.description, rule.level, severity, full_log

Configure this as a real-time alert to trigger email or webhook notifications for critical security events.

Create file integrity monitoring dashboard

Monitor file system changes detected by OSSEC syscheck.

index=ossec sourcetype=ossec:alerts:json rule.groups="syscheck" 
| eval change_type=case(match(rule.description,"added"),"File Added",match(rule.description,"modified"),"File Modified",match(rule.description,"deleted"),"File Deleted",1==1,"Other") 
| stats count by change_type, syscheck.path, agent.name 
| sort -count

Set up rootkit detection alerts

Configure alerts for rootkit detection and system anomalies.

index=ossec sourcetype=ossec:alerts:json rule.groups="rootcheck" 
| table _time, agent.name, rule.description, title, full_log 
| sort -_time

Create authentication monitoring dashboard

Monitor authentication events and potential brute force attacks.

index=ossec sourcetype=ossec:alerts:json (rule.groups="authentication_success" OR rule.groups="authentication_failed" OR rule.groups="authentication_failures") 
| eval auth_result=case(match(rule.groups,"success"),"Success",match(rule.groups,"fail"),"Failed",1==1,"Other") 
| stats count by auth_result, agent.name, srcip 
| sort -count

Verify your setup

Test the integration by checking log flow and generating test alerts.

# Check OSSEC status
sudo /var/ossec/bin/ossec-control status

Check Splunk forwarder status

sudo /opt/splunkforwarder/bin/splunk status

Generate test alert

sudo /var/ossec/bin/ossec-logtest

Verify log files are being written

sudo tail -f /var/ossec/logs/alerts/alerts.json

Check Splunk connection

sudo /opt/splunkforwarder/bin/splunk list forward-server

In Splunk, verify data ingestion:

index=ossec | head 10

Common issues

SymptomCauseFix
No data in SplunkForwarder not connectedCheck network connectivity and verify forward-server configuration
OSSEC alerts not generatingConfiguration syntax errorRun sudo /var/ossec/bin/ossec-control status and check /var/ossec/logs/ossec.log
Permission denied on log filesIncorrect file ownershipRun sudo chown -R ossec:ossec /var/ossec/logs and chmod 755 /var/ossec/logs
Splunk index not createdMissing index configurationCreate index manually in Splunk web interface or restart Splunk services
JSON parsing errorsMalformed JSON in logsVerify OSSEC JSON output format and check props.conf configuration
High disk usageLogs not rotatingVerify logrotate configuration and run sudo logrotate -f /etc/logrotate.d/ossec

Next steps

Running this in production?

Want this handled for you? Running OSSEC and Splunk at scale adds complexity around capacity planning, data retention policies, alert tuning, and 24/7 incident response. See how we run security infrastructure like this for European teams.

Automated install script

Run this to automate the entire setup

Need help?

Don't want to manage this yourself?

We handle infrastructure security hardening for businesses that depend on uptime. From initial setup to ongoing operations.