Splunk Enterprise

Is there a way to forward the Splunk parsed data logs in JSON format to TCP port?

Elysium
Loves-to-Learn

Hi,

I have an use case that I need to forward the logs to TCP listener (third party system) as and when the logs load to splunk.

For the, I am loading windows security logs to splunk from windows machine using Splunk Forward service. Then configured splunk forwarder to forward raw logs to TCP listner as below.

================= props.conf ===============

[ tcp:9080]
TRUNCATE = 0

[default]
# unless a more specific stanza clears the value of this class, the transform will be run
TRANSFORMS-selectiveIndexing = selectiveIndexing


[WinEventLog:Security]
TRANSFORMS-routing=transforms-windows-security-logs
# note the empty list of transforms to run in this class, overridden from the [default]
TRANSFORMS-selectiveIndexing =

=========================================

 

================ transforms.conf ===========

[transforms-windows-security-logs]
REGEX = .
DEST_KEY = _TCP_ROUTING
FORMAT = windows-security-routing

=========================================

 

================ output.conf ===============

[indexAndForward]
index = true

[tcpout]
defaultGroup=everythingElseGroup

[tcpout:windows-security-routing]
server=xx.xx.xxx.xxx:9522
sendCookedData=false

========================================

Now, I have Logstash listener which is listening on port 9522 and writing the data to file. I see the logs being written to file as below

=============== Windows security logs forwarded to third party system =========

{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"LogName=Security","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"EventType=0","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"SourceName=Microsoft Windows security auditing.","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"RecordNumber=24054056","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"TaskCategory=Process Termination","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"Message=A process has exited.\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"Subject:\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"\tAccount Name:\t\tBDELYSYS07$\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"\tLogon ID:\t\t0x3E7\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"Process Information:\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"\tProcess Name:\tC:\\Program Files\\SplunkUniversalForwarder\\bin\\splunk-winevtlog.exe\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.680Z","@version":"1","port":33332,"message":"05/23/2022 08:51:21 PM","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"EventCode=4689","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"ComputerName=BDELYSYS07.bdelysium.internal","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"Type=Information","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"Keywords=Audit Success","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"OpCode=Info","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"\tSecurity ID:\t\tS-1-5-18\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"\tAccount Domain:\t\tBDELYSIUM\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"\tProcess ID:\t0x2798\r","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"\tExit Status:\t0x0","host":"xx.xx.xxx.xxx"}
{"@timestamp":"2022-05-24T10:15:57.681Z","@version":"1","port":33332,"message":"LogName=Security","host":"xx.xx.xxx.xxx"}

=================================================

Going through the logs, it seems like logs are not forwarded event by event. 

I would like to know with the above setup, how can I forward the logs to TCP listener event by event.

Also, is there a way to forward the splunk parsed data logs in JSON format to TCP port.

0 Karma

PickleRick
SplunkTrust
SplunkTrust

If you're forwarding events on a plain tcp connection, multiline events (and windows events are such ones) can be split by receiver into multiple separate events and there's not much splunk can do about it if the destination system is not able to handle the events correctly. That's why splunk has many line-breaking setting which allow it to ingest multiline events. Your external system might simply not be able to handle them properly.

There is no way to separately handle mesages destined for different outputs ("split" the pipeline). You could try getting events from windows in XML format instead of the traditional one and/or sending them out on http output instead of plain tcp. Your receiving solution would have to handle HEC-compliant POST requests.

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...