Skip to content

Latest commit

 

History

History
64 lines (50 loc) · 1.76 KB

filesystem-metrics-sampling.md

File metadata and controls

64 lines (50 loc) · 1.76 KB

Filesystem Metrics sampling

since v0.6.0

;; Leiningen project
[com.brunobonacci/mulog-filesystem-metrics "x.x.x"]

;; deps.edn format
{:deps { com.brunobonacci/mulog-filesystem-metrics {:mvn/version "x.x.x"}}}

Current version: Clojars Project

It is possible to sample filesystem metrics such as total and available disk space for each mounted filesystem using a special publisher.

;; configuration options
{:type :filesystem-metrics

 ;; the interval in millis between two samples (default: 60s)
 :sampling-interval 60000

 ;; Transformation to apply to the samples before publishing.
 ;;
 ;; It is a function that takes a sequence of samples and
 ;; returns and updated sequence of samples:
 ;; `transform-samples -> sample-seq -> sample-seq`
 ;; (e.g. filter only volumes over 1 GB)
 :transform-samples
 (partial filter #(> (:total-bytes %) 1e9))}

Sample usage:

(μ/start-publisher! {:type :filesystem-metrics})

NOTE: with Java 16+ you need to add the following in your project.clj:

  :jvm-opts
  ["--add-opens"   "java.base/sun.nio.fs=ALL-UNNAMED"]

Here an example of the metrics sampled for one filesystem

{:mulog/event-name :mulog/filesystem-metrics-sampled,
 :mulog/timestamp 1601629811722,
 :mulog/trace-id #mulog/flake "4YcWozKEUcfE9JxfQMnuwb-NnO8ygEpE",
 :filesystem-metrics
 {:name "/dev/disk1s1"
  :type "apfs"
  :path "/"
  :readonly? false
  :total-bytes 499963170816
  :unallocated-bytes 40646381568
  :usable-bytes 30255194112}}

NOTE: values will change depending on available disks.