Skip to content

A very simple exporter that reads files from a given directory and exports their contents as gauges.

License

Notifications You must be signed in to change notification settings

L21s/prometheus-filesystem-exporter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prometheus Filesystem Exporter

A very simple exporter that reads files from a given directory and exports their contents as untyped metrics.

Usage

The easiest way is to use docker:

docker run \ 
-v /host/metrics:/container/metrics \
-p 8080:8080 \
larscheidschmitzhermes/prometheus-filesystem-exporter:latest \
--metrics-directory /container/metrics \
--metrics-path /metrics \
--listen-addr :8080

To add a new metric, simply write a file with it's name (optionally followed by the labels you want to assign) to the metrics directory:

touch '/host/metrics/answer_to_everything;scope=universe;env=prod'

You will see that the exporter immediately picks up the metric:

curl -s http://localhost:8080/metrics | grep answer_to_everything
# HELP answer_to_everything Auto generated from filesystem path: /container/metrics/answer_to_everything
# TYPE answer_to_everything untyped
answer_to_everything{scope="universe",env="prod"} 0

Setting the value is as easy as writing to the file:

echo "42" > '/host/metrics/answer_to_everything;scope=universe;env=prod'

The update happens right away:

curl -s http://localhost:8080/metrics | grep answer_to_everything
# HELP answer_to_everything Auto generated from filesystem path: /container/metrics/answer_to_everything
# TYPE answer_to_everything gauge
answer_to_everything{scope="universe",env="prod"} 42

Configuration

The following flags can be passed to the prometheus-filesystem-exporter:

flag default description
--listen-addr :8080 The address to listen on for http requests
--metrics-directory /metrics The directory to read metrics from
--metrics-path /metrics The http path under which metrics are exposed
--silent false Silent mode - no logging of metric changes

About

A very simple exporter that reads files from a given directory and exports their contents as gauges.

Resources

License

Stars

Watchers

Forks

Packages

No packages published