In this example we have a dynamic directory file path in which the directory contains today's date.
In the today's date directory, we want to monitor the latest version of every filename which gets a new file written every hour with a number increment.
Example image of directory file path and logs we are monitoring. We only want to monitor the latest version of each file which would be Prod_ProcessA-13.log, Prod_ProcessB-13.log, and Prod_ProcessC-13.log.
In the FKM Sampler setup we select “dynamicFiles” drop-down option under Source.
You click the “Dynamic files…” button which opens the Dynamic files window above.
In the Path field we put the complete file path and use the today function followed by *.log.
That way our FKM is setup to automatically monitor files in the folder with today’s date on it.
In the Regex field we put the following Regex expression:
^.*Logs\/\d+-\d+-\d+\/(.*)-\d+.log$
For the FKM sampler to grab the latest version of each file in the directory, the regex expression needs to be unique.
We do that by including the Logs\/ sub-folder in the regex expression since the Logs sub-folder will remain the same.
Followed by the pattern for the date folder:
\d+\d+\d+\/
We have a capture group (.*) in the expression that will hold a portion of the filename up until the dash (-) number portion dot (.) log. You will see in the Metrics view that the capture group is used in the name column.
The following -\d+ ensures we consider the last dash in the filename followed by the number.
The .log at the end will apply only to files with that file extension.
Below is the Metrics view of the FKM sampler displaying Prod_ProcessA-13.log, Prod_ProcessB-13.log, and Prod_ProcessC-13.log files.
-
Tags:
- fkm
- howto
Comments
0 comments
Please sign in to leave a comment.