I'm looking to write a prometheus rule to constantly check for message queue length(exim mail relay) which is the total number of files in a directory in an app's container and alert a slack channel via alert manager. Is this possible at all with Prometheus/Alert manager ?
2 Answers
Yes, it can be done using Prometheus and Alert manager but you will something to export the metric that you want to monitor to promethes. In your case script_exporter will work. You would have to setup the exporter inside that container and configure it to execute something like ls | wc -l
in the folder you want to monitor.

- 323
- 1
- 8
Is this possible at all with Prometheus/Alert manager ?
Yes.
But firstly, you need to expose the metric (file count). It can be done with Prometheus Client libraries (https://prometheus.io/docs/instrumenting/clientlibs/).
It supports many programming language:
Go
Java or Scala
Python
Ruby
Bash
C
C++
Common Lisp
Dart
Elixir
Erlang
Haskell
Lua for Nginx
Lua for Tarantool
.NET / C#
Node.js
Perl
PHP
R
Rust
I prefer Python (https://github.com/prometheus/client_python). If you need an example, here is my exporter that exposes the metric I need (curl to http endpoint to get the value): https://github.com/tinhgin/eos-last-irreversible-block-num-exporter/blob/master/exporter.py

- 21
- 3