All Apps and Add-ons

different custom fields per row in a log file

willnossiter
Engager

I have a csv log file with four different types of row entries. These are identified by the first item in each line - HR (Header), RR (Request), SR (Send), FS (Footer). Each line has different fields and a different number of fields. I'd like to process these to one index and different custom fields based on the HR/RR/SR/FS value. So far I'm succeeded in processing both lines in the example but the fields are being re-used from the HR row for the RR row. Any ideas?:

Data example (2 lines with carriage return ending the line):

HR, ID123, CredABC1, SoftwareName, StatusActive, 2011-11-15
RR, Conv123, ID123, ID456, 2011-11-15T09:01:15, RequestType1, FailurePoint40, 2011-11-15T09:02:20, ABCD-1234-EFG-567, FailureOnRetry, Error70, RecipientUnavailable, Retried5Times, ABCD-1234-EFG-561

transforms.conf:

[header]
REGEX = HR
DELIMS = ","
FIELDS = "RecordType", "SenderID", "SenderCredentials", "SoftwareInstalled", "ApplicationStatus", "ReportTimePeriod"

[request]
REGEX = RR
DELIMS = ","
FIELDS = "RecordType", "ConversationID", "RequestorID", "SenderID", "RequestTime", "RequestType", "RequestFailurePoint", "RequestFailureTime", "RequestFailureMessageID", "RequestFailureType", "RequestErrorCode", "RequestErrorDescription", "RequestRetryCount", "RequestMessageID"

props.conf

[header]
TIME_PREFIX = ^
REPORT-csv = record
MAX_TIMESTAMP_LOOKAHEAD = 30
TIME_FORMAT= %Y-%m-%d
SEGMENTATION = outer
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)

[request]
TIME_PREFIX = ^
REPORT-csv = record
MAX_TIMESTAMP_LOOKAHEAD = 30
TIME_FORMAT= %Y-%m-%d
SEGMENTATION = outer
SHOULD_LINEMERGE = false
LINE_BREAKER = ([\r\n]+)

inputs.conf

[default]
host = machine_name

[monitor://C:\Inetpub\wwwroot\splunk_logs]
disabled = false
index = main
host = abcd
sourcetype = record

Takajian
Builder

Typical csv file is static fields, so "DELIMS" setting in transforms.conf is the best way to extract field. But your csv file is not static. so, "DELIMS" setting is not appropriate.
I think you need to extract field by using regex. As for the configuration, we can refer to following manual.

http://docs.splunk.com/Documentation/Splunk/4.2.4/Knowledge/Createandmaintainsearch-timefieldextract...

0 Karma
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!

Index This | What travels the world but is also stuck in place?

April 2026 Edition  Hayyy Splunk Education Enthusiasts and the Eternally Curious!   We’re back with this ...

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...