How to monitor the latest version of all files whose name changes dynamically in a dated directory
Note
Use the Dynamic Files option to accomplish this within FKM.
To demonstrate, we have a dated directory and we want to monitor the latest version of every filename. Notice the screenshot below shows the latest version of each file is Prod\_ProcessA-13.log, Prod\_ProcessB-13.log, and Prod\_ProcessC-13.log.
The FKM setup would be as follows:
-
Select the dynamicFiles drop-down option under Source.
-
Click the Dynamic Files button which opens the Dynamic files window as seen below:
-
In the Path field, put the complete file path and use the today function followed by
\*.log. This allows the FKM sampler to automatically monitor files in the folder with today’s date in its name. -
In the Regex field, 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.
This is 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. The capture group is used in the name column of the dataview.
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.
For more information, see FKM - Dynamic Files and date generation function.
Below is the FKM - dynamic example sampler:
<sampler name="FKM - dynamic example">
<plugin>
<fkm>
<isPCREMode>
<data>true</data>
</isPCREMode>
<files>
<file>
<source>
<dynamicFiles>
<path>
<data>/export/home/mmuniz/fkm_dynamic_example/Logs/<today %Y-%m-%d>/*.log</data>
</path>
<pattern>
<data>
<regex>^.*Logs\/\d+-\d+-\d+\/(.*)-\d+.log$</regex>
</data>
</pattern>
</dynamicFiles>
</source>
<alias>
<data>%1</data>
</alias>
</file>
</files>
</fkm>
</plugin>
</sampler>
Note
This sampler was set up on version GA5.9.0.