Getting Data In

Splunk is re-indexing entire file, not just changes

thesteve
Path Finder

I have a vendor provided log file (I have no way to change it) that has both a changing header and a changing footer.

In between are log lines, 1 entry per line.

The problem I am facing is that splunk is re-indexing the entire file when it gets updated, not just the newly added lines.

I am parsing out the header and footer using two entries in transforms.conf.

[setNull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[dateAndData]
DEST_KEY = queue
REGEX    = ^(Fri|Sat|Sun|Mon|Tue|Wed|Thu).{22}
FORMAT   = indexQueue

Is there anything I can do to get splunk to recognize the data that it has already indexed? The only thing I can think of at this point is writing my own script that would extract data from the file and I'd rather not do that unless it was absolutely necessary.

0 Karma
1 Solution

lguinn2
Legend

Splunk is designed to read a file from beginning to end. Changing info in the beginning or middle of a file can cause confusion.

When Splunk opens a file, it looks at the first 256 bytes and tries to determine if it has seen the file before. If the header changes (as it seems yours does), then Splunk says "aha - a new file" and indexes the data again.

You might be able to set the following in your inputs.conf to stop this

[monitor:///yourmonitorstanza]
initCrcLength = 50
crcSalt = <SOURCE>

This assumes that the first 50 bytes will NOT change, so you might need to adjust this to an even smaller number. The crcSalt helps to ensure that Splunk will not confuse this file with another file that might have the same first 50 bytes but a different name.

View solution in original post

lguinn2
Legend

Splunk is designed to read a file from beginning to end. Changing info in the beginning or middle of a file can cause confusion.

When Splunk opens a file, it looks at the first 256 bytes and tries to determine if it has seen the file before. If the header changes (as it seems yours does), then Splunk says "aha - a new file" and indexes the data again.

You might be able to set the following in your inputs.conf to stop this

[monitor:///yourmonitorstanza]
initCrcLength = 50
crcSalt = <SOURCE>

This assumes that the first 50 bytes will NOT change, so you might need to adjust this to an even smaller number. The crcSalt helps to ensure that Splunk will not confuse this file with another file that might have the same first 50 bytes but a different name.

Get Updates on the Splunk Community!

Welcome to the Splunk Community!

(view in My Videos) We're so glad you're here! The Splunk Community is place to connect, learn, give back, and ...

Tech Talk | Elevating Digital Service Excellence: The Synergy of Splunk RUM & APM

Elevating Digital Service Excellence: The Synergy of Real User Monitoring and Application Performance ...

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 ...