Is there a way to monitor the number of files in a folder and create an alert if it exceeds

Is there a way to monitor # of files in a folder and it goes over X number to create an alert?

I can think of some ways. If I were to do it for myself, I’d probably have a cronjob running that:

  1. ln -1 | wc -l (number of files in the directory)
  2. take that output and <https://docs.datadoghq.com/api/latest/metrics/#submit-metrics|submit that> value to the metrics API
    Then once you have that as a metric, you can create an alert or whatever with it

That seems easy enough. I did find one other “directory” module that was an integrated module that is supposed to also have count on # of files for the directory. Problem is that it isnt recognizing the directory module. strange as thats 2.0 so seems like it should work.

oh hey https://docs.datadoghq.com/integrations/directory/|whatdyaknow

https://docs.datadoghq.com/integrations/directory/

it isnt recognizing the directory module
can you clarify what you mean by that?

I added conf.d/directory.d/conf.yaml its not picking it up though on restart. very odd. saying it couldn’t load the check from config directory

any chance it’s an access issue? i.e. does the user running the agent process have access to the conf file & monitored directory?

No, it has access to read it from the agent user acount

saying it couldn’t load the check from config directory
I’m not familiar with this. What’s the error?

(if you want debugging help)

able to sudo to that account and see the directory

error: Unable to load a check from instance of config ‘directory’: Core Check Loader: Check directory not found in Catalog

error: Unable to load the check: unable to load any check from config ‘directory’

which version of the agent do you have running?

datadog-agent version
Agent 7.44.0 - Commit: 09a59ab - Serialization version: v5.0.76 - Go version: go1.19.7

What does datadog-agent status give you?

oh; I thought it did more than just that. dang

how about datadog-agent check directory -l debug

or sudo -u dd-agent datadog-agent check directory -l debug if you’re not already that user

maybe this’ll give you the root issue; obv don’t share the output if it has sensitive info