Getting Data In

index only part of a log?

gregwilliams
Path Finder

Is there a way to index only part of a log? These logs are custom log files from a windows server. There are thousands of files, each file belonging to an AD user, and the files are updated when a user logs onto/off of a domain machine. I don't want the entire log to be index because there is a lot of junk in there that I don't need or want to index. For example this is the structure:

Date | Time | user | macaddress | IP | Function | computer name | AD Display Name | share directory | then a bunch of other garbage | etc.

Basically I need everything but share directory, AD Display name, macaddress, and the other garbage.

The windows server that the files are sitting on is separate from the splunk server.

1 Solution

lguinn2
Legend

Here is the easiest and most efficient way to do it. On the Splunk server, put the following in

$SPLUNK_HOME/etc/system/local/props.conf

[source::nameoffiles]
TRUNCATE = 100

TRUNCATE says "only index the first 100 characters of each event." The 100 is arbitrary, but if you can figure out a reasonable value for your situation, it will work well. And if you sometimes get a a little bit of the "garbage" in there, you can just ignore it.

For the "nameoffiles", you must specify the input files that should be affected. You can use wildcards here, but be careful. And you do need to specify the full path name, etc. Take a look in the manual for more info about props.conf.
You could specify the same thing, but using the sourcetype of the data instead - if the data all has the same sourcetype:

[yoursourcetypename]
TRUNCATE = 100

There are other ways to do this, but they require more processing, etc.

View solution in original post

gregwilliams
Path Finder

Thanks! The fields are fixed length so this works perfectly for what I'm trying to do.

0 Karma

lguinn2
Legend

Here is the easiest and most efficient way to do it. On the Splunk server, put the following in

$SPLUNK_HOME/etc/system/local/props.conf

[source::nameoffiles]
TRUNCATE = 100

TRUNCATE says "only index the first 100 characters of each event." The 100 is arbitrary, but if you can figure out a reasonable value for your situation, it will work well. And if you sometimes get a a little bit of the "garbage" in there, you can just ignore it.

For the "nameoffiles", you must specify the input files that should be affected. You can use wildcards here, but be careful. And you do need to specify the full path name, etc. Take a look in the manual for more info about props.conf.
You could specify the same thing, but using the sourcetype of the data instead - if the data all has the same sourcetype:

[yoursourcetypename]
TRUNCATE = 100

There are other ways to do this, but they require more processing, etc.

Get Updates on the Splunk Community!

[Puzzles] Solve, Learn, Repeat: Dynamic formatting from XML events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

Enter the Agentic Era with Splunk AI Assistant for SPL 1.4

  🚀 Your data just got a serious AI upgrade — are you ready? Say hello to the Agentic Era with the ...

Stronger Security with Federated Search for S3, GCP SQL & Australian Threat ...

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