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

  1. Settings → Data Inputs → HTTP Event Collector → Global Settings: set All Tokens to Enabled.
  2. New Token: name it (for example socket-firewall), choose the index the events should land in, and finish the wizard.
  3. 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
❗️

Set SPLUNK_SSL_VERIFY explicitly

With it false, the HEC token is sent with no certificate check to whatever answers at SPLUNK_HEC_URL.

With it true, the HEC certificate must come from a CA the firewall trusts: a public CA, or your own CA added with ssl.ca_cert in socket.yml. A CA added with ssl.ca_cert is trusted for every outbound TLS connection the firewall makes.

Use false only with a self-signed HEC in a POC.

🚧

SPLUNK_HEC_URL must resolve in DNS

The exporter resolves the hostname through the container's DNS resolver and does not use /etc/hosts or extra_hosts: entries, even though curl and getent inside the container do. For a lab without DNS, put the HEC's IP address in SPLUNK_HEC_URL.

📘

Keep the token out of socket.yml

A splunk: block in socket.yml also works, but values in that file are not shell-expanded. The environment variable keeps the token out of that file.

3. Recreate the container

docker compose up -d --force-recreate

4. 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     # blocked

Verify

In Splunk:

index=security sourcetype="socket:firewall"
  • An event for the blocked install, with purl, block_reason, and request_id
  • An event for the allowed install
  • Counts match docker compose logs socket-firewall | grep SOCKET_DECISION (requires SOCKET_IGNORE_LOG_LEVEL=warn, see Data)

Troubleshooting

SymptomFix
No events, test curl workedContainer 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 eventlodash was already in node_modules. Run the test in a fresh directory
Splunk HEC: Failed to send event: 18: self-signed certificateSPLUNK_SSL_VERIFY=true and the HEC certificate isn't trusted by the container

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


Did this page help you?