# List log files for a metric

**URL:** <https://community.dynatrace.com/t/list-log-files-for-a-metric/38623>\
**Category:** Logs\
**Tags:** dynatrace-managed, log-monitoring-class\
**Created:** [February 28, 2023, 7:42am UTC](https://community.dynatrace.com/t/list-log-files-for-a-metric/38623 "2023-02-28T07:42:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandt74](https://avatars.discourse-cdn.com/v4/letter/b/c6cbf5/32.png) [@Brandt74](https://community.dynatrace.com/u/Brandt74)\
**Post date:** [February 28, 2023, 7:42am UTC](https://community.dynatrace.com/t/list-log-files-for-a-metric/38623/1 "2023-02-28T07:42:02Z")

</div>

Good day.

We building a dashboard that will show the metrics for certain error conditions, with this we want to be able to have that log line to be available on the dashboard. Let me give a easy example. Lets say one of the metrics is to show if a “File not found”. If there is a counter for it, we want to display or have a link to the log entry/s for that metric to for example see what file was not found in the log line.

Is this possible and if so, how would this be done?

Thank you.

---

<div class="post-metadata">

**Author:** ![DanielS](https://avatars.discourse-cdn.com/v4/letter/d/3ab097/32.png) [@DanielS](https://community.dynatrace.com/u/DanielS)\
**Post date:** [February 28, 2023, 12:29pm UTC](https://community.dynatrace.com/t/list-log-files-for-a-metric/38623/2 "2023-02-28T12:29:16Z")

</div>

Hi [@Brandt74](https://community.dynatrace.com/user/60127) there is an extension [https://www.dynatrace.com/hub/detail/filesystem-monitoring-extension-v2](https://www.dynatrace.com/hub/detail/filesystem-monitoring-extension-v2) which can be used to achieve this.

**Metrics** :

- File count: Number of files matching a pattern
- File age count: Number of files matching a pattern and an age
- File age: Age of a specific file (oldest or newest when returning more than 1 file)
- File size: Size of the files in bytes
- File mounted: Is a file mounted on Unix NFS

## use cases

**Path examples:**

- Count the number of log files inside /var/log/myapp  
Select check type = count  
Path = /var/log/myapp/\*.log
- Count the number of log files inside c:\temp  
Select check type = count  
Path = c:\temp\*.log
- Count the number of logs files inside /var/log/myapp and any subdirectories  
Select check type = count  
Path = /var/log/myapp/\*\*/\*.log
- Return the total size of all files files inside /var/log/myapp  
Select check type = size  
Path = /var/log/myapp/\*
- Return the age of the oldest file in /tmp/test/  
Select check type = modification age  
Unselect user newest file  
Path = /tmp/test/\*
- Return the number of log files older than 1 hour in /tmp/test  
Select check type = modification age count  
Set Age comparison operator to Older than  
Set the threshold to 60  
Path = /tmp/test/\*.log
- Check if /data/mount-data is mounted  
Select check type = mount point  
Path = /data/mount-data
- Check that today’s log has been produced: /var/mylog20222211.log  
Select check type = count  
Path = /var/mylogYYYYMMDD.log  
Accepts DDMMYYYY, DD-MM-YYYY, DD\_MM\_YYYY, YYYYMMDD. YYYY-MM-DD, YYYY\_MM\_DD.  
The date will be the local date where the OneAgent/extension is running.

---

<div class="post-metadata">

**Author:** ![mizso74](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@mizso74](https://community.dynatrace.com/u/mizso74)\
**Post date:** [February 28, 2023, 11:00pm UTC](https://community.dynatrace.com/t/list-log-files-for-a-metric/38623/3 "2023-02-28T23:00:29Z")

</div>

Hi&nbsp;[@Brandt74](https://community.dynatrace.com/user/60127)

Another solution, Switch on log monitoring v2. Set the log source where you would like to search the “file not found” pattern.

At the log viewer set a filter for the log content pattern “file not found” then:

You can create a log metric with the peviously mentioned log filter. Now your “file not found” log lines will be counted. You can vizualize this metric or you can create an alert for the metric.

or You can pin the log filter result to a dashboard, so you can see the filtered log lines on the dashboard.

Regarding the what file question: If you can define well the location of the file name in the log line, you can parse out from the logline with a simple log processing.

Some example:

Simple filter in log viewer for file not found log lines, result can be pinned to a dashboard.

 ![Mizs_0-1677623068004.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/c/0ca536cc85f42d04d7f716c38f72133b35c086ab.png)

Simple log metric with source and content pattern:

 ![Mizs_1-1677623258953.png](https://global.discourse-cdn.com/dynatrace/original/2X/c/cb2603634f446ec217fcd414ab205b9235559a26.png)

Simple parse a log attribute. Result obm.type value will&nbsp; be propagated based on the log contet after Type:

 ![Mizs_2-1677623449111.png](https://global.discourse-cdn.com/dynatrace/original/3X/0/a/0a8376e82291209ef788944c5a26c965f736bb56.png)

Above processing rule results in the log viewer if “Type:” is found in a log line:

 ![Mizs_3-1677623765247.png](https://global.discourse-cdn.com/dynatrace/original/2X/b/bf2f991b51577175923d9cb9fd2560663f222251.png)

Extra tip: log attributes can be dimensions at a more complex log metric:

At this log metic the error lines counted and the additional dimension is also added. So in data explorer you can split or filer by log attributes (by dimensions)

 ![Mizs_4-1677624129924.png](https://global.discourse-cdn.com/dynatrace/original/3X/3/5/354fdfe0d460dfe6fd88a4859bd669cb0076e133.png)

Here is a simple example for log monitoring dashboard:

 ![Mizs_5-1677625200764.png](https://global.discourse-cdn.com/dynatrace/original/3X/1/a/1ada4e734910a5a1607f5621327e750ecda5e4e1.png)

I hope it helps.

Best regards,

Mizső
