Splunk config
Send every firewall decision straight to Splunk with the built-in HEC exporter.
The firewall has a native Splunk HTTP Event Collector (HEC) exporter. No webhook or forwarder is needed.
1. Create a HEC token in Splunk
- Settings → Data Inputs → HTTP Event Collector → Global Settings: set All Tokens to Enabled.
- New Token: name it (for example
socket-firewall), choose the index the events should land in, and finish the wizard. - Copy the token value.
Confirm Splunk accepts events before involving the firewall:
curl -k https://splunk.example.com:8088/services/collector/event \
-H "Authorization: Splunk YOUR_HEC_TOKEN" \
-d '{"event":"socket firewall hec test","sourcetype":"socket:firewall"}'Expect {"text":"Success","code":0}.
2. Add the variables
Append to the firewall's .env:
SPLUNK_ENABLED=true
SPLUNK_HEC_URL=https://splunk.example.com:8088/services/collector/event
SPLUNK_HEC_TOKEN=YOUR_HEC_TOKEN
SPLUNK_INDEX=security
SPLUNK_SOURCETYPE=socket:firewall
SPLUNK_SSL_VERIFY=true
SetSPLUNK_SSL_VERIFYexplicitlyThe shipped default is
false, so without this line the HEC token is sent to whatever answers atSPLUNK_HEC_URL, with no certificate check. The exporter has no setting for adding a CA, so:
trueneeds a HEC certificate from a publicly trusted CA. IfSPLUNK_HEC_URLuses an IP address, the certificate needs that IP in its SAN.falseis the only option for a self-signed HEC. Use it for a POC only, deliberately, and note it.
SPLUNK_HEC_URLmust resolve in DNSThe exporter resolves the hostname through the container's DNS resolver and does not use
/etc/hostsorextra_hosts:entries, even thoughcurlandgetentinside the container do. For a lab without DNS, put the HEC's IP address inSPLUNK_HEC_URL. Don't add a127.0.0.1 splunk...line to the firewall host's/etc/hosts: the firewall would then connect to itself.
Keep the token out ofsocket.ymlA
splunk:block insocket.ymlalso works, but values in that file are not shell-expanded and the file usually lives in version control. The environment variable keeps the token out of both.
3. Recreate the container
docker compose up -d --force-recreate4. Generate events
From a client pointed at the firewall:
Use a fresh directory: if lodash is already in node_modules, npm downloads nothing and no event is sent.
cd "$(mktemp -d)"
npm cache clean --force
npm install lodash # clean allow
npm install lodahs # blockedVerify
In Splunk:
index=security sourcetype="socket:firewall"
- An event for the blocked install, with
purl,block_reason, andrequest_id - An event for the allowed install
- Counts match
docker compose logs socket-firewall | grep SOCKET_DECISION(requiresSOCKET_IGNORE_LOG_LEVEL=warn, see Data)
Troubleshooting
| Symptom | Fix |
|---|---|
| No events, test curl worked | Container not recreated after editing .env, or the container can't reach Splunk on 8088 |
Splunk HEC: Failed to send event: ... could not be resolved (3: Host not found) | The HEC hostname isn't in DNS. Add a DNS record or use the IP address |
| Allowed install produces no event | lodash was already in node_modules. Run the test in a fresh directory |
Splunk HEC: Failed to send event: 18: self-signed certificate | SPLUNK_SSL_VERIFY=true and the HEC certificate isn't trusted by the container |
HEC returns Invalid token | Token disabled, or All Tokens is off in Global Settings |
| Events in the wrong index | The token's allowed indexes don't include SPLUNK_INDEX |
Check the firewall side with docker compose logs socket-firewall | grep -i splunk. Successful sends log nothing, so empty output is normal. Only failures appear.
Reference
- Data for the event fields
- Configuration Reference
Updated 8 days ago