Getting Data In

Parsing appended Robocopy job logs

anewell
Path Finder

Has anybody dealt with splunking Windows Robocopy.exe logs? I'm about to dive into it, and am looking for prior art. My input files are created by scheduled robocopy jobs which append their logs to the file. I think I'm dealing with a SHOULD_LINEMERGE and needing to decide on a LINEBREAKER.

Edit: My primary goal is to be able to report & graph the "Bytes copied" and job duration values over time. In the example below, the value I'm after is 741.88 m but I'd be thrilled to extract more than that.

The first 3 lines are produced by the batch script which calls Robocopy. Lines 4 onward are robocopy itself. Indexing lines 1-3 may be ignored for purposes of arriving at a generalized robocopy solution.

================================================= 
Servername 
================================================= 
-------------------------------------------------------------------------------
   ROBOCOPY     ::     Robust File Copy for Windows     ::     Version XP010
-------------------------------------------------------------------------------

  Started : Tue Mar 01 10:00:01 2011

   Source : \\Servername\DATA\
     Dest : D:\BACKUPS\

    Files : *.*

  Options : *.* /NS /NC /NDL /NFL /S /E /COPY:DATS /PURGE /NP /R:0 /W:30 

------------------------------------------------------------------------------

                D:\BACKUPS\file1.txt
                D:\BACKUPS\file2.txt
                D:\BACKUPS\file3.dat
                # SNIP #
                D:\BACKUPS\fileN.bak


------------------------------------------------------------------------------

                Total    Copied   Skipped  Mismatch    FAILED    Extras
     Dirs :      1801         3      1798         0         0         0
    Files :     90133      3366     86767         0         0      1210
    Bytes :  24.011 g  741.88 m  23.286 g         0         0  157.96 m
    Times :   0:07:18   0:03:53                       0:00:00   0:03:25

    Speed :             3333995 Bytes/sec.
    Speed :             190.772 MegaBytes/min.

    Ended : Tue Mar 01 10:07:20 2011
0 Karma

gkanapathy
Splunk Employee
Splunk Employee

I would suggest the entire log here as a single event, then using extractions and/or multikv to get out the values you want. So

[robocopy]
SHOULD_LINEMERGE = false
TRUNCATE = 0
LINE_BREAKER = ([\r\n]+)(?=-{79}[\r\n]+\s+ROBOCOPY)
TIME_PREFIX = Started\s+:\s*
TIME_FORMAT = %a %b %d %H:%M:%S %Y
MAX_TIMESTAMP_LOOKAHEAD = 40
EXTRACT-bytes = [\r\n]+\s*Bytes\s+:\s+(?<bytestotal>[\d\.]+)\s*(?<bytestotalunits>[kmgtKMGT])?\s+(?<bytescopied>[\d\.]+)\s*(?<bytescopiedunits)[kmgtKMGT])?

If each job run is in a separate file, you could also use LINE_BREAKER = (?!), which means it will never break and the whole file is a single event.

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!

Best Practices: Splunk auto adjust pipeline queue

When you enable autoAdjustQueue in Splunk, maxSize should be understood as the queue size Splunk starts with ...

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