Skip to content

Prometheus metrics exporter, Grafana dashboards, and QNAP notification sink for QNAP NAS devices.

Notifications You must be signed in to change notification settings

jkager/qnapexporter

 
 

Repository files navigation

Build

qnapexporter

qnapexporter is a simple Go program meant to be run in the background on a QNAP NAS in order to export relevant metrics to Prometheus. It exposes an HTTP /metrics endpoint which generates a standard Prometheus metrics file, and a /notifications endpoint which can simulate an SMSC endpoint for QNAP notifications.

The data produced by this exporter can be used to create Grafana dashboards such as the following:

Grafana dashboard sample

UPS Grafana dashboard sample

The Grafana dashboard sources are in the /dashboards directory.

Installation

  1. Download the latest qnapexporter executable from the Releases page

  2. Run qnapexporter

    ./qnapexporter

    Normally it should be run as a background task. Unfortunately this is not easy on a QNAP NAS. See for example this forum post for ideas on how to achieve it.

  3. Add target to scrape_configs section of prometheus.ini

    - job_name: 'qnap'
      scrape_interval: 10s
      honor_labels: true
      static_configs:
      - targets: ['localhost:9094']

Customization

qnapexporter supports the following command line flags:

Flag Default value Description
--port :9094 Address/port where to serve the metrics
--ping-target 1.1.1.1 Host to periodically ping
--healthcheck N/A Healthcheck service to ping every 5 minutes (currently supported: healthchecks.io:<check-id>)
--grafana-url N/A Grafana host (e.g.: https://grafana.example.com), also settable through GRAFANA_URL environment variable
--grafana-auth-token N/A Grafana API token for annotations, also settable through GRAFANA_AUTH_TOKEN environment variable
--grafana-tags nas List of Grafana tags for annotations, also settable through GRAFANA_TAGS environment variable
--log N/A Path to log file (defaults to standard output)

Configuring support for QNAP events as Grafana annotations

qnapexporter can expose QNAP events as Grafana annotations, to make it easy to understand what is happening on the NAS. To configure the support:

  1. Log in to the NAS web interface
  2. Open Notification Center, then Service Account and Device Pairing
  3. In the SMS tab, click the Add SMSC Service button
    1. In SMS service provider, select custom
    2. Set Alias to qnapexporter
    3. Set URL template text to http://localhost:9094/notification?phone_number=@@PhoneNumber@@&text=@@Text@@. Customize the port to match whatever is passed to --port.
    4. Confirm the settings.
  4. In the Grafana web UI, go to Configuration, API Keys
    1. Press Add API key
    2. Set Key name to qnapexporter
    3. Set Role to Editor
    4. Press Add
    5. Take note of the created token (this will be passed to qnapexporter with --grafana-auth-token)

Tips

The root endpoint exposes information about the current status of the program (useful for debugging):

Status page

About

Prometheus metrics exporter, Grafana dashboards, and QNAP notification sink for QNAP NAS devices.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 98.7%
  • Makefile 1.2%
  • Procfile 0.1%