# How do I collect directory-related disk metrics?

You can collect the directory-related disk metrics by configuring the directory check on your agent. This check will collect metrics related to directories':

• number of files
• file size
• age of the last modification
• age of the creation

On Mac OSX or Linux:

To set up the directory check on OSX or Linux, follow these configuration instructions.

On Windows:

For recent versions of the agent, the Directory check will be one of the configurations listed by default on the left-most side of the Datadog Agent Manager--from there you can configure and enable your Directory check.

For older versions of the agent, to configure your directory.yaml, you will have to navigate to the conf.d directory, this should be located here by default:

On Windows <= 2008: C:\Documents and Settings\All Users\Application Data\Datadog\conf.d

From within the conf.d folder configure the following file in notepad or a similar editor, and then remove ".example" from the filename:

directory.yaml.example

Your path might be in a different location, in which case you can find it by selecting the "Logs and Status" button in the corner of your Datadog Agent Manager and choosing "Agent Status". In the Agent Status view, you can find your conf.d directory under "Collector >> Path to conf.d".

Having found this file, you will want to configure it to collect (and optionally tag) those directories you want to collect metrics for. On Windows, an example could look as simple as:

init_config:instances:  - directory: "C:\\path\\to\\directory"

When configuring your directory.yaml, be sure to follow the formatting exactly as shown - if formatting is not correct the check will fail.

When you're done editing the file save it as directory.yaml

Any time you modify a Datadog configuration file, you’ll need to restart the Datadog Service. You can do this from services.msc or from the Datadog Agent Manager via the Actions button.

You can verify that the new check is working properly if in the Datadog Agent Manager you select "Log and Status >> Agent Status". After refreshing the view, under Checks you should see a Directory section reporting OK.

Again, due to the sensitivity of yaml, if you've tried the above and cannot get it to work, use the attached file to get yourself started and confirm your syntax, and double-check that all your directories are using double-backslashes instead of single-backslashes.

For reference, here's a basic example of what your correctly configured directory.yaml might look like in Windows' Datadog Agent Manager:

Double-Backslashes?

Note that on Windows when you add your directory, you will have to use double-backslashes (“C:\\path\\to\\directory”) instead of single-backslashes (“C:\path\to\directory”) for the check to run. Otherwise, the directory check will fail with traceback ending in the error: ‘found unknown escape character in "<string>"’.

This is because the agent is written in Python, which reserves backslashes (“\”) for character escaping, while Windows (unlike UNIX) uses backslashes to delimit directory paths. For Python strings, a single-backslash is indicated by writing a double-backslash.