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
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Can’t Make It to Boston? Stream .conf25 and Learn with Haya Husain

Boston may be buzzing this September with Splunk University and .conf25, but you don’t have to pack a bag to ...

Splunk Lantern’s Guide to The Most Popular .conf25 Sessions

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Unlock What’s Next: The Splunk Cloud Platform at .conf25

In just a few days, Boston will be buzzing as the Splunk team and thousands of community members come together ...