In this video, I will show you how to monitor directory sizes in Prometheus using a Python script. Follow along with this step-by-step tutorial to set up your environment, install the necessary tools, and configure Prometheus to scrape directory size metrics.
Commands & Steps Covered:
Install pip (if not already installed):
sudo apt install pip
Install virtual environment:
sudo apt install python3.11-venv
* Activate virtual environment:
source venv/bin/activate
* Install the Python script:
pip install prometheus-dirsize-exporter
* Stop the Prometheus container to add IP and port in the scrape config:
docker stop prometheus
* Restart the Docker container for Prometheus:
docker start prometheus
* Run the grow.sh script to increase file size:
./grow.sh
* Search for metrics 'dirsize_total_size_bytes' in Prometheus:
*Start the Python script to monitor directory size:
dirsize-exporter /home 200 1
Here, the parent directory /home is monitored with 200 IOPS and refreshes every one minute.
Final Thoughts:
This Python script monitors directories under the parent directory. It's not convenient for monitoring specific directories, and only one script can be run per host. Therefore, it is useful for small environments. For a better solution with node exporter and more folders simultaneously, stay tuned for the next video.
Sources:
github.com/yuvipanda/promethe...
github.com/yuvipanda/promethe...
#Prometheus #PythonScript #DirectoryMonitoring #TechTutorial #SysAdmin #DevOps #Monitoring #PrometheusMetrics #Python #TechGuide
Негізгі бет 🔍 Advanced Directory Size Monitoring in Prometheus with Python Scripts: A Complete Guide
Пікірлер