Git Product home page Git Product logo

directory-exporter's Introduction

directory-exporter

A Prometheus exporter to count the number of files in multiple directories and expose them as Prometheus metrics. This exporter supports counting empty files, file with specific extension etc. Supports Windows, linux and MacOS

Usage

Testing

git clone https://github.com/bharathalleni/directory-exporter.git
cd directory-exporter
pip install -r requirements.txt
python3 main.py

The script will start monitoring the specified directories in the configuration file and expose the Prometheus metric at http://localhost:9028/metrics.

Build for Windows, Linux and MacOS

pip3 install pyinstaller
pyinstaller --onefile ./main.py

The installer will be created in dist directory. You can install it as a Windows service using NSSM or run it as a service using systemd in Linux.

Note: PyInstaller is capable of generating executables for Windows, Linux, and macOS platforms individually, but it does not support cross-compilation. Consequently, you cannot create an executable targeting one operating system from another operating system. To distribute executables across multiple operating systems, you will require a dedicated build machine for each supported platform.

Prometheus Integration

To scrape the metrics exposed by the Directory exporter, configure Prometheus to scrape the /metrics endpoint of the script. Add the following job configuration to your Prometheus prometheus.yml file:

scrape_configs:
 - job_name: directory-exporter
   static_configs:
     - targets: ['localhost:9028']

Sample metrics

# HELP file_count Number of files in directory
# TYPE file_count gauge
file_count{path="/Users/Username/data/exporters/file-count-exporter/",server="127.0.0.1"} 4.0
file_count{path="/Users/Username/data/POS",server="127.0.0.1"} 14.0
# HELP file_count_by_extension Count of files with extension
# TYPE file_count_by_extension gauge
file_count_by_extension{extension=".py",path="/Users/Username/data/exporters/file-count-exporter/",server="127.0.0.1"} 1.0
file_count_by_extension{extension=".txt",path="/Users/Username/data",server="127.0.0.1"} 1.0
# HELP empty_file_count Number of empty files
# TYPE empty_file_count gauge
empty_file_count{path="/Users/Username/data/file-count-exporter/",server="127.0.0.1"} 1.0
empty_file_count{path="/Users/Username/data/POS",server="127.0.0.1"} 0.0

directory-exporter's People

Contributors

bharathalleni avatar iamarya2k24 avatar

Stargazers

 avatar Bram De Jaegher avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.