Getting Data In

Monitor is not working with Python-generated .csv

nick405060
Motivator

I have a .csv file that is being appended to every few minutes using Python. However, monitor reindexes everything each time it is written to, not just the new data. The filename and first 256 bytes are the same, so crcSalt shouldn't be an issue here.

How can I fix this?

0 Karma
1 Solution

nick405060
Motivator

Thanks to @micahkemp and @dwaddle for their assistance here. I posted this question to document the solution for the Splunk community.

micah:fez:  2:34 PM
if that file ever looks like it's less than 256 bytes, say right after it's re-created, but before it's written with the exact same content
2:35
splunk might be fast enough to catch it

duckfez:honk:  2:35 PM
p. sure it is, especially since I think inotify gets used (some) now

To solve, I just had Python write to a temp .csv and then I used shutil.move(temp.csv, myfinalfile.csv). It is possible that changing your Python code to write to the .csv using a instead of w may fix the issue as well.

View solution in original post

0 Karma

nick405060
Motivator

Thanks to @micahkemp and @dwaddle for their assistance here. I posted this question to document the solution for the Splunk community.

micah:fez:  2:34 PM
if that file ever looks like it's less than 256 bytes, say right after it's re-created, but before it's written with the exact same content
2:35
splunk might be fast enough to catch it

duckfez:honk:  2:35 PM
p. sure it is, especially since I think inotify gets used (some) now

To solve, I just had Python write to a temp .csv and then I used shutil.move(temp.csv, myfinalfile.csv). It is possible that changing your Python code to write to the .csv using a instead of w may fix the issue as well.

0 Karma
Get Updates on the Splunk Community!

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...

Extending Observability Content to Splunk Cloud

Watch Now!   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to leverage ...

More Control Over Your Monitoring Costs with Archived Metrics GA in US-AWS!

What if there was a way you could keep all the metrics data you need while saving on storage costs?This is now ...