Coder Social home page Coder Social logo

mac133k / zfs_exporter Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 1.0 53 KB

ZFS metric exporter for Prometheus

License: GNU General Public License v3.0

Python 81.25% Shell 18.75%
python3 zfsonlinux prometheus prometheus-exporter prometheus-client prometheus-metrics

zfs_exporter's Introduction

zfs_exporter

ZFS metric exporter for Prometheus

Note: Alternative available

ZFS metrics were added to PCP v5.2.4 in Feb 2021. Metrics are collected via linux_zfs PMDA written in C by @mac133k and include the same selection as this ZFS Exporter plus the new metrics introduced in OpenZFS v2. PCP suite supports OpenMetrics and provides Prometheus client, so I strongly recommend it to Linux users as it is a more robust solution, and provides a large number of monitoring tools and features. Switching from ZFS Exporter should be easy, because metric names follow the same convention.

Overview

Small app that uses Python Prometheus Client to serve ZSF metrics to Prometheus or other compatible metric collector. It is designed to run on Linux servers and it takes all metrics from /proc.

Installation

To install ZFS Exporter follow these steps:

pip3 install prometheus_client gunicorn flask
git clone https://github.com/mac133k/zfs_exporter.git
cd zfs_exporter
cp conf/env.sh.template conf/env.sh

Starting and stopping

Use the scripts provided:

./start.sh
./stop.sh

Running as a SystemD service

Having ZFS Exported set up as a SystemD unit makes it easy to make sure it starts automatically after system reboot. Assuming that it was installed in /opt one can create a service file in /usr/lib/systemd/system/zfs-exporter.service or some other path depending on the distro, ie.:

[Unit]
Description=ZFS metrics exporter for Prometheus

[Service]
Type=forking
ExecStart=/bin/bash /opt/zfs_exporter/start.sh
ExecStop=/bin/bash /opt/zfs_exporter/stop.sh
PIDFile=/opt/zfs_exporter/var/pid

[Install]
WantedBy=multi-user.target

Next run these few commands to complete the installation:

/opt/zfs_exporter/stop.sh # if needed
chmod 644 /usr/lib/systemd/system/zfs-exporter.service
systemctl daemon-reload
systemctl enable zfs-exporter
systemctl start zfs-exporter

Testing

Check the URL to make sure the app is running:

curl localhost:20080/metrics

The pid file is the local var folder, the logs in var/log/messages.log.

Prometheus configuration

Add the scrape job to your Prometheus config file:

- job_name: zsfstats
  honor_timestamps: true
  scrape_interval: 1m
  scrape_timeout: 10s
  metrics_path: /metrics
  scheme: http
  static_configs:
  - targets: [...]

Metrics

Metrics are imported from the files in /proc/spl/kstat/zfs/ and are generally named after the file they were extracted from with the zfs_ prefix, ie. zfs_arc_hits, zfs_arc_misses, etc. Additionally the per pool metrics zfs_pool_state and zfs_pool_io_* have additional label pool which holds the name of the corresponding pool.

For the sake of simplicity each metric is of the gauge type with an unspecified unit, so it is up to the user to properly handle the semantics of interesing statistics where it comes to plotting them of graphs or referring to in alert rules etc.

PromQL

Calculate the cache hit percentage:

100 * rate(zfs_arc_hits[5m]) / (rate(zfs_arc_hits[5m]) + rate(zfs_arc_misses[5m]))

zfs_exporter's People

Contributors

mac133k avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

em-winterschon

zfs_exporter's Issues

Grafana

Do you know of any grafana templates for your exporter?

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.