Getting Data In

Splunk Parser Ignore Datetime and Host Fields

jmsilva9500
New Member

Hello,

I'm struggling with finding a parser in splunk for the following log:

May 20 12:22:21 127.0.0.1 {"rootId": "AXIxikL8ao-yaSvA", "requestId": "f6a873jkjjkjk:-8000:5738", "details": {"flag": false, "title": "task 1", "status": "Waiting", "group": "", "order": 0}, "operation": "Creation", "objectId": "AXIyCN5Oao-H5aYyaSvd", "startDate": 1589977341890, "objectType": "case_task", "base": true, "object": {"_routing": "AXIxikL8ao-H5aYyaSvA", "flag": false, "_type": "case_task", "title": "task 1", "createdAt": 1589977341516, "_parent": "AXIxikL8ao-H5aYyaSvA", "createdBy": "user", "_id": "AXIyCN5Oao-H5aYyaSvd", "id": "AXIyCN5Oao-H5aYyaSvd", "_version": 1, "order": 0, "status": "Waiting", "group": ""}}

The log itself is a valid json, and i can parse it well with the default _json parser. However, splunk inserts the datetime and hostname at the beginning of the log, which makes the parser stop working..

Is there any workaround for this?

Thanks!

0 Karma

to4kawa
Ultra Champion

default _json parser is INDEXED_EXTRACTION=json
This can't work on using SEDCMD

props.conf

SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)
INDEXED_EXTRACTION = none
KV_MODE = json
TRUNCATE = 0
SEDCMD-trim = s/.*?{/{/
0 Karma

richgalloway
SplunkTrust
SplunkTrust

The parser works, but it doesn't work. Please explain.
How is the data getting to Splunk?

---
If this reply helps you, Karma would be appreciated.
0 Karma

jmsilva9500
New Member

The data is being sent by remote syslog. the _json parser works for the log that is sent to splunk, but at indexing time splunk inserts at the beginning of the log the datetime and the host values, which makes the log itself no longer a valid json, therefore the parser fails

0 Karma

richgalloway
SplunkTrust
SplunkTrust

I think it's syslog that is adding the time and host values. Splunk also adds timestamp and host, but it's in metadata, not the raw data.

---
If this reply helps you, Karma would be appreciated.
0 Karma

jmsilva9500
New Member

Do you know how i can parse to log giving that the time and host values are in the beggining of it?

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Try using SEDCMD in props.conf to strip out the timestamp and host info. Should be easy with "s/^.*\{//".

---
If this reply helps you, Karma would be appreciated.
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Laser Bananas and Edge Hubs: Exploring Operational Technology (OT) Data Through a ...

  OT is a different environment to traditional IT and can have interesting challenges when interfacing the ...

Event Series: Mastering AI Tokenomics and Splunk Agent Observability

Beyond the Black Box: Correlating AI Performance and Tokenomics with Splunk Agent Observability   As ...

span_metrics: The OpenTelemetry-Idiomatic Way to See Inside Your Services

You open a trace in Splunk Observability Cloud and everything looks fine. One root span, order-pipeline, with ...